diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolverUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolverUtil.java index 44bb0618819..34f856a3f4e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolverUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolverUtil.java @@ -183,6 +183,6 @@ public class CallResolverUtil { } return new JetTypeImpl( receiverType.getAnnotations(), receiverType.getConstructor(), receiverType.isNullable(), - fakeTypeArguments, receiverType.getMemberScope()); + fakeTypeArguments, ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true)); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java index ac80c845231..ccd90c59bad 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java @@ -126,6 +126,102 @@ public class ErrorUtils { public Collection getOwnDeclaredDescriptors() { return Collections.emptyList(); } + + @Override + public String toString() { + return "ErrorScope{" + debugMessage + '}'; + } + } + + private static class ThrowingScope implements JetScope { + private final String debugMessage; + + private ThrowingScope(String message) { + debugMessage = message; + } + + @Nullable + @Override + public ClassifierDescriptor getClassifier(@NotNull Name name) { + throw new IllegalStateException(); + } + + @Nullable + @Override + public ClassDescriptor getObjectDescriptor(@NotNull Name name) { + throw new IllegalStateException(); + } + + @NotNull + @Override + public Collection getObjectDescriptors() { + throw new IllegalStateException(); + } + + @Nullable + @Override + public NamespaceDescriptor getNamespace(@NotNull Name name) { + throw new IllegalStateException(); + } + + @NotNull + @Override + public Collection getProperties(@NotNull Name name) { + throw new IllegalStateException(); + } + + @Nullable + @Override + public VariableDescriptor getLocalVariable(@NotNull Name name) { + throw new IllegalStateException(); + } + + @NotNull + @Override + public Collection getFunctions(@NotNull Name name) { + throw new IllegalStateException(); + } + + @NotNull + @Override + public DeclarationDescriptor getContainingDeclaration() { + return ERROR_MODULE; + } + + @NotNull + @Override + public Collection getDeclarationsByLabel(@NotNull LabelName labelName) { + throw new IllegalStateException(); + } + + @Nullable + @Override + public PropertyDescriptor getPropertyByFieldReference(@NotNull Name fieldName) { + throw new IllegalStateException(); + } + + @NotNull + @Override + public Collection getAllDescriptors() { + throw new IllegalStateException(); + } + + @NotNull + @Override + public List getImplicitReceiversHierarchy() { + throw new IllegalStateException(); + } + + @NotNull + @Override + public Collection getOwnDeclaredDescriptors() { + throw new IllegalStateException(); + } + + @Override + public String toString() { + return "ThrowingScope{" + debugMessage + '}'; + } } private static final ClassDescriptorImpl ERROR_CLASS = new ClassDescriptorImpl(ERROR_MODULE, Collections.emptyList(), Modality.OPEN, Name.special("")) { @@ -158,6 +254,13 @@ public class ErrorUtils { } public static JetScope createErrorScope(String debugMessage) { + return createErrorScope(debugMessage, false); + } + + public static JetScope createErrorScope(String debugMessage, boolean throwExceptions) { + if (throwExceptions) { + return new ThrowingScope(debugMessage); + } return new ErrorScope(debugMessage); }