Index: src/Boo.Lang.Compiler/Steps/ProcessMethodBodies.cs =================================================================== --- src/Boo.Lang.Compiler/Steps/ProcessMethodBodies.cs (revision 1913) +++ src/Boo.Lang.Compiler/Steps/ProcessMethodBodies.cs (working copy) @@ -2036,7 +2036,15 @@ } else { - memberRef.Target = new SelfLiteralExpression(node.LexicalInfo); + //check if found entity can't possibly be a member of self: + if (member.DeclaringType != CurrentType && + !(CurrentType.IsSubclassOf(member.DeclaringType))) + { + Error(CompilerErrorFactory.InstanceRequired(node, + member.DeclaringType.ToString(), + member.Name)); + } + memberRef.Target = new SelfLiteralExpression(node.LexicalInfo); } Bind(memberRef, member); @@ -2872,8 +2880,8 @@ break; } case UnaryOperatorType.LogicalNot: - { - LeaveLogicalNot(node); + { + LeaveLogicalNot(node); break; } @@ -2887,15 +2895,15 @@ } case UnaryOperatorType.UnaryNegation: - { - LeaveUnaryNegation(node); + { + LeaveUnaryNegation(node); break; } - case UnaryOperatorType.OnesComplement: - { - LeaveOnesComplement(node); - break; + case UnaryOperatorType.OnesComplement: + { + LeaveOnesComplement(node); + break; } default: @@ -2904,52 +2912,52 @@ break; } } - } - - private void LeaveOnesComplement(UnaryExpression node) - { - if (IsPrimitiveOnesComplementOperand(node.Operand)) - { - BindExpressionType(node, GetExpressionType(node.Operand)); - } - else - { - ProcessOperatorOverload(node); - } - } - - private bool IsPrimitiveOnesComplementOperand(Expression operand) - { - IType type = GetExpressionType(operand); - return TypeSystemServices.IsIntegerNumber(type); - } - - private void LeaveLogicalNot(UnaryExpression node) - { + } + + private void LeaveOnesComplement(UnaryExpression node) + { + if (IsPrimitiveOnesComplementOperand(node.Operand)) + { + BindExpressionType(node, GetExpressionType(node.Operand)); + } + else + { + ProcessOperatorOverload(node); + } + } + + private bool IsPrimitiveOnesComplementOperand(Expression operand) + { + IType type = GetExpressionType(operand); + return TypeSystemServices.IsIntegerNumber(type); + } + + private void LeaveLogicalNot(UnaryExpression node) + { node.Operand = CheckBoolContext(node.Operand); - BindExpressionType(node, TypeSystemServices.BoolType); - } - - private void LeaveUnaryNegation(UnaryExpression node) - { + BindExpressionType(node, TypeSystemServices.BoolType); + } + + private void LeaveUnaryNegation(UnaryExpression node) + { if (IsPrimitiveNumber(node.Operand)) { BindExpressionType(node, GetExpressionType(node.Operand)); - } - else - { - ProcessOperatorOverload(node); - } - } - - private void ProcessOperatorOverload(UnaryExpression node) - { + } + else + { + ProcessOperatorOverload(node); + } + } + + private void ProcessOperatorOverload(UnaryExpression node) + { if (! ResolveOperator(node)) { InvalidOperatorForType(node); - } - } - + } + } + override public bool EnterBinaryExpression(BinaryExpression node) { if (BinaryOperatorType.Assign == node.Operator) Index: tests/testcases/errors/BCE0020-2.boo =================================================================== --- tests/testcases/errors/BCE0020-2.boo (revision 0) +++ tests/testcases/errors/BCE0020-2.boo (revision 0) @@ -0,0 +1,15 @@ +""" +BCE0020-2.boo(11,19): BCE0020: An instance of type 'foo' is required to access non static member 'types'. +""" +class foo: + types = ['hello', 'world!'] + def fu(): + b = self.bar() + b.fark() + class bar: + def fark(): + print types + +f = foo() +f.fu() +