Erroneous fix reverted. Test added
This commit is contained in:
@@ -25,11 +25,12 @@ import java.util.Set;
|
||||
protected final Map<JetNamespace, WritableScope> namespaceScopes = Maps.newHashMap();
|
||||
protected final Map<JetNamespace, NamespaceDescriptorImpl> namespaceDescriptors = Maps.newHashMap();
|
||||
|
||||
private final Map<JetDeclaration, JetScope> declaringScopes = Maps.newHashMap();
|
||||
|
||||
private final Map<JetNamedFunction, FunctionDescriptorImpl> functions = Maps.newLinkedHashMap();
|
||||
private final Map<JetDeclaration, ConstructorDescriptor> constructors = Maps.newLinkedHashMap();
|
||||
private final Map<JetProperty, PropertyDescriptor> properties = Maps.newLinkedHashMap();
|
||||
private final Set<PropertyDescriptor> primaryConstructorParameterProperties = Sets.newHashSet();
|
||||
private final Map<JetDeclaration, JetScope> declaringScopes = Maps.newHashMap();
|
||||
|
||||
public TopDownAnalysisContext(JetSemanticServices semanticServices, BindingTrace trace) {
|
||||
this.trace = new ObservableBindingTrace(trace);
|
||||
|
||||
@@ -18,44 +18,14 @@ public class TopDownAnalyzer {
|
||||
|
||||
private TopDownAnalyzer() {}
|
||||
|
||||
public static void processObject(
|
||||
public static void process(
|
||||
@NotNull JetSemanticServices semanticServices,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope outerScope,
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull JetObjectDeclaration object) {
|
||||
process(semanticServices, trace, outerScope, new NamespaceLike.Adapter(containingDeclaration) {
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptorImpl getNamespace(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassifierDescriptor(@NotNull MutableClassDescriptor classDescriptor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyDescriptor(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptor classObjectDescriptor) {
|
||||
return ClassObjectStatus.NOT_ALLOWED;
|
||||
}
|
||||
}, Collections.<JetDeclaration>singletonList(object), JetControlFlowDataTraceFactory.EMPTY, true);
|
||||
NamespaceLike owner,
|
||||
@NotNull List<? extends JetDeclaration> declarations,
|
||||
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
process(semanticServices, trace, outerScope, owner, declarations, flowDataTraceFactory, false);
|
||||
}
|
||||
|
||||
private static void process(
|
||||
@@ -75,16 +45,6 @@ public class TopDownAnalyzer {
|
||||
new DeclarationsChecker(context).process();
|
||||
new ControlFlowAnalyzer(context, flowDataTraceFactory, declaredLocally).process();
|
||||
}
|
||||
|
||||
public static void process(
|
||||
@NotNull JetSemanticServices semanticServices,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope outerScope,
|
||||
NamespaceLike owner,
|
||||
@NotNull List<? extends JetDeclaration> declarations,
|
||||
@NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||
process(semanticServices, trace, outerScope, owner, declarations, flowDataTraceFactory, false);
|
||||
}
|
||||
|
||||
public static void processStandardLibraryNamespace(
|
||||
@NotNull JetSemanticServices semanticServices,
|
||||
@@ -93,6 +53,8 @@ public class TopDownAnalyzer {
|
||||
TopDownAnalysisContext context = new TopDownAnalysisContext(semanticServices, trace);
|
||||
context.getNamespaceScopes().put(namespace, standardLibraryNamespace.getMemberScope());
|
||||
context.getNamespaceDescriptors().put(namespace, standardLibraryNamespace);
|
||||
context.getDeclaringScopes().put(namespace, outerScope);
|
||||
|
||||
new TypeHierarchyResolver(context).process(outerScope, standardLibraryNamespace, namespace.getDeclarations());
|
||||
new DeclarationResolver(context).process();
|
||||
new DelegationResolver(context).process();
|
||||
@@ -105,6 +67,46 @@ public class TopDownAnalyzer {
|
||||
new BodyResolver(context).resolveBehaviorDeclarationBodies();
|
||||
}
|
||||
|
||||
public static void processObject(
|
||||
@NotNull JetSemanticServices semanticServices,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull JetScope outerScope,
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull JetObjectDeclaration object) {
|
||||
process(semanticServices, trace, outerScope, new NamespaceLike.Adapter(containingDeclaration) {
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptorImpl getNamespace(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassifierDescriptor(@NotNull MutableClassDescriptor classDescriptor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPropertyDescriptor(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptor classObjectDescriptor) {
|
||||
return ClassObjectStatus.NOT_ALLOWED;
|
||||
}
|
||||
}, Collections.<JetDeclaration>singletonList(object), JetControlFlowDataTraceFactory.EMPTY, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WriteThroughScope;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
@@ -38,6 +39,8 @@ public class TypeHierarchyResolver {
|
||||
public void process(@NotNull JetScope outerScope, NamespaceLike owner, @NotNull List<? extends JetDeclaration> declarations) {
|
||||
collectNamespacesAndClassifiers(outerScope, owner, declarations); // namespaceScopes, classes
|
||||
|
||||
processTypeImports();
|
||||
|
||||
createTypeConstructors(); // create type constructors for classes and generic parameters, supertypes are not filled in
|
||||
resolveTypesInClassHeaders(); // Generic bounds and types in supertype lists (no expressions or constructor resolution)
|
||||
|
||||
@@ -82,8 +85,9 @@ public class TypeHierarchyResolver {
|
||||
|
||||
WriteThroughScope namespaceScope = new WriteThroughScope(outerScope, namespaceDescriptor.getMemberScope(), new TraceBasedRedeclarationHandler(context.getTrace()));
|
||||
context.getNamespaceScopes().put(namespace, namespaceScope);
|
||||
context.getDeclaringScopes().put(namespace, outerScope);
|
||||
|
||||
processImports(namespace, namespaceScope, outerScope);
|
||||
// processImports(namespace, namespaceScope, outerScope);
|
||||
|
||||
collectNamespacesAndClassifiers(namespaceScope, namespaceDescriptor, namespace.getDeclarations());
|
||||
}
|
||||
@@ -205,12 +209,17 @@ public class TypeHierarchyResolver {
|
||||
return ClassKind.CLASS;
|
||||
}
|
||||
|
||||
private void processImports(@NotNull JetNamespace namespace, @NotNull WriteThroughScope namespaceScope, @NotNull JetScope outerScope) {
|
||||
private void processTypeImports() {
|
||||
for (JetNamespace jetNamespace : context.getNamespaceDescriptors().keySet()) {
|
||||
processImports(jetNamespace, context.getNamespaceScopes().get(jetNamespace), context.getDeclaringScopes().get(jetNamespace));
|
||||
}
|
||||
}
|
||||
|
||||
private void processImports(@NotNull JetNamespace namespace, @NotNull WritableScope namespaceScope, @NotNull JetScope outerScope) {
|
||||
List<JetImportDirective> importDirectives = namespace.getImportDirectives();
|
||||
for (JetImportDirective importDirective : importDirectives) {
|
||||
if (importDirective.isAbsoluteInRootNamespace()) {
|
||||
// context.getTrace().getErrorHandler().genericError(namespace.getNode(), "Unsupported by TDA"); // TODO
|
||||
context.getTrace().report(UNSUPPORTED.on(namespace, "TypeHierarchyResolver")); // TODO
|
||||
context.getTrace().report(UNSUPPORTED.on(importDirective, "TypeHierarchyResolver")); // TODO
|
||||
continue;
|
||||
}
|
||||
if (importDirective.isAllUnder()) {
|
||||
|
||||
@@ -33,4 +33,8 @@ public interface WritableScope extends JetScope {
|
||||
void importScope(@NotNull JetScope imported);
|
||||
|
||||
void setImplicitReceiver(@NotNull ReceiverDescriptor implicitReceiver);
|
||||
|
||||
void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor);
|
||||
|
||||
void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor);
|
||||
}
|
||||
|
||||
+2
@@ -106,11 +106,13 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
||||
return currentIndividualImportScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) {
|
||||
getCurrentIndividualImportScope().addClassifierAlias(importedClassifierName, classifierDescriptor);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor) {
|
||||
getCurrentIndividualImportScope().addNamespaceAlias(aliasName, namespaceDescriptor);
|
||||
}
|
||||
|
||||
@@ -167,4 +167,9 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
}
|
||||
return allDescriptors;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetScope getOuterScope() {
|
||||
return getWorkerScope();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// KT-355 Resolve imports after all symbols are built
|
||||
|
||||
namespace a {
|
||||
import b.*
|
||||
val x : X = X()
|
||||
}
|
||||
|
||||
namespace b {
|
||||
class X() {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user