| Index: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
|
| diff --git a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
|
| index 58375300f96342c32b0209c344a0326cac0b3c04..e82aec45a3829ca334ab8a8e08526037f80c012a 100644
|
| --- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
|
| +++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
|
| @@ -171,6 +171,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
| private final DartCompilerContext context;
|
| private final Types types;
|
| private Type expected;
|
| + private MethodElement currentMethod;
|
| private InterfaceType currentClass;
|
| private final InterfaceType boolType;
|
| private final InterfaceType numType;
|
| @@ -1231,6 +1232,9 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
|
|
| @Override
|
| public Type visitMethodInvocation(DartMethodInvocation node) {
|
| + if (node.getFunctionName().isResolutionAlreadyReportedThatTheMethodCouldNotBeFound()) {
|
| + return dynamicType;
|
| + }
|
| DartIdentifier nameNode = node.getFunctionName();
|
| String name = node.getFunctionNameString();
|
| Element element = node.getElement();
|
| @@ -1245,6 +1249,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
| Member member = lookupMember(receiver, name, nameNode);
|
| if (member != null) {
|
| Element methodElement = member.getElement();
|
| + checkIllegalPrivateAccess(node.getFunctionName(), methodElement, name);
|
| node.setElement(methodElement);
|
| if (nameNode != null) {
|
| nameNode.setElement(methodElement);
|
| @@ -1255,6 +1260,18 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
| return checkInvocation(node, nameNode, name, methodType);
|
| }
|
|
|
| + private void checkIllegalPrivateAccess(DartNode diagnosticNode, Element element, String name) {
|
| + if (DartIdentifier.isPrivateName(name)) {
|
| + if (element != null) {
|
| + Element enclosingLibrary = Elements.getLibraryElement(currentMethod);
|
| + Element identifierEnclosingLibrary = Elements.getLibraryElement(element);
|
| + if (!enclosingLibrary.equals(identifierEnclosingLibrary)) {
|
| + onError(diagnosticNode, TypeErrorCode.ILLEGAL_ACCESS_TO_PRIVATE, name);
|
| + }
|
| + }
|
| + }
|
| + }
|
| +
|
| @Override
|
| public Type visitSuperConstructorInvocation(DartSuperConstructorInvocation node) {
|
| return checkConstructorForwarding(node, node.getElement());
|
| @@ -1766,8 +1783,14 @@ public class TypeAnalyzer implements DartCompilationPhase {
|
| typeError(returnTypeNode, TypeErrorCode.OPERATOR_INDEX_ASSIGN_VOID_RETURN_TYPE);
|
| }
|
| }
|
| - // done
|
| - return typeAsVoid(node);
|
| + // visit children
|
| + MethodElement prevMethod = currentMethod;
|
| + currentMethod = methodElement;
|
| + try {
|
| + return typeAsVoid(node);
|
| + } finally {
|
| + currentMethod = prevMethod;
|
| + }
|
| }
|
|
|
| /**
|
|
|