All tests pass

This commit is contained in:
Andrey Breslav
2011-05-16 20:48:51 +04:00
parent f61b776c10
commit 0f63489f7c
5 changed files with 219 additions and 198 deletions
@@ -19,17 +19,19 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
private final WritableFunctionGroup constructors = new WritableFunctionGroup("<init>");
private final Set<FunctionDescriptor> functions = Sets.newHashSet();
private final Set<PropertyDescriptor> properties = Sets.newHashSet();
private final Set<MutableClassDescriptor> classes = Sets.newHashSet();
private TypeConstructor typeConstructor;
private final WritableScope scopeForMemberResolution;
private final WritableScope scopeForMemberLookup;
// This scope contains type parameters but does not contain inner classes
private final WritableScope scopeForSupertypeResolution;
public MutableClassDescriptor(@NotNull BindingTrace trace, @NotNull DeclarationDescriptor containingDeclaration, @NotNull JetScope outerScope) {
super(containingDeclaration);
this.scopeForMemberResolution = new WritableScopeImpl(outerScope, this, trace.getErrorHandler(), null);
this.scopeForMemberLookup = new WritableScopeImpl(scopeForMemberResolution, this, trace.getErrorHandler(), null);
this.scopeForMemberLookup = new WritableScopeImpl(JetScope.EMPTY, this, trace.getErrorHandler(), null);
this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, trace.getErrorHandler(), null);
this.scopeForMemberResolution = new WritableScopeImpl(scopeForSupertypeResolution, this, trace.getErrorHandler(), null);
// this.scopeForMemberLookup = new WritableScopeImpl(scopeForMemberResolution, this, trace.getErrorHandler(), new DeclarationDescriptorVisitor<Void, WritableScope>() {
// @Override
// public Void visitPropertyDescriptor(PropertyDescriptor descriptor, WritableScope data) {
@@ -100,7 +102,6 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
@Override
public void addClassifierDescriptor(@NotNull MutableClassDescriptor classDescriptor) {
classes.add(classDescriptor);
scopeForMemberLookup.addClassifierDescriptor(classDescriptor);
scopeForMemberResolution.addClassifierDescriptor(classDescriptor);
}
@@ -178,4 +179,14 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
public String toString() {
return DescriptorRenderer.TEXT.render(this) + "[" + getClass().getCanonicalName() + "@" + System.identityHashCode(this) + "]";
}
public void addSupertype(@NotNull JetType supertype) {
scopeForMemberLookup.importScope(supertype.getMemberScope());
scopeForMemberResolution.importScope(supertype.getMemberScope());
}
@NotNull
public WritableScope getScopeForSupertypeResolution() {
return scopeForSupertypeResolution;
}
}
@@ -81,7 +81,7 @@ public class ClassDescriptorResolver {
descriptor.setName(JetPsiUtil.safeName(classElement.getName()));
descriptor.getScopeForMemberResolution().addLabeledDeclaration(descriptor);
WritableScope scopeForMemberResolution = descriptor.getScopeForMemberResolution();
WritableScope scopeForMemberResolution = descriptor.getScopeForSupertypeResolution();
// TODO : Where-clause
List<TypeParameterDescriptor> typeParameters = Lists.newArrayList();
@@ -126,7 +126,7 @@ public class ClassDescriptorResolver {
TypeParameterDescriptor typeParameterDescriptor = parameters.get(i);
JetTypeReference extendsBound = jetTypeParameter.getExtendsBound();
if (extendsBound != null) {
typeParameterDescriptor.addUpperBound(typeResolverNotCheckingBounds.resolveType(classDescriptor.getScopeForMemberResolution(), extendsBound));
typeParameterDescriptor.addUpperBound(typeResolverNotCheckingBounds.resolveType(classDescriptor.getScopeForSupertypeResolution(), extendsBound));
}
else {
typeParameterDescriptor.addUpperBound(JetStandardClasses.getDefaultBound());
@@ -140,13 +140,12 @@ public class ClassDescriptorResolver {
// TODO : assuming that the hierarchy is acyclic
Collection<? extends JetType> superclasses = delegationSpecifiers.isEmpty()
? Collections.singleton(JetStandardClasses.getAnyType())
: resolveDelegationSpecifiers(descriptor.getScopeForMemberResolution(), delegationSpecifiers, typeResolverNotCheckingBounds);
: resolveDelegationSpecifiers(descriptor.getScopeForSupertypeResolution(), delegationSpecifiers, typeResolverNotCheckingBounds);
((TypeConstructorImpl) descriptor.getTypeConstructor()).getSupertypes().addAll(superclasses);
// TODO : remove the importing
for (JetType superclass : superclasses) {
descriptor.getScopeForMemberResolution().importScope(superclass.getMemberScope());
descriptor.addSupertype(superclass);
}
}
@@ -154,7 +153,7 @@ public class ClassDescriptorResolver {
descriptor.setName(JetPsiUtil.safeName(classElement.getName()));
descriptor.getScopeForMemberResolution().addLabeledDeclaration(descriptor);
WritableScope parameterScope = descriptor.getScopeForMemberResolution();
WritableScope parameterScope = descriptor.getScopeForSupertypeResolution();
// This call has side-effects on the parameterScope (fills it in)
List<TypeParameterDescriptor> typeParameters
@@ -266,174 +266,174 @@ public class TopDownAnalyzer {
resolveBehaviorDeclarationBodies();
}
@NotNull
public JetScope process(@NotNull JetScope outerScope, @NotNull List<JetDeclaration> declarations) {
final WritableScope toplevelScope = new WritableScopeImpl(outerScope, outerScope.getContainingDeclaration(), trace.getErrorHandler(), null); // TODO ?!
collectTypeDeclarators(toplevelScope, declarations);
resolveTypeDeclarations();
processBehaviorDeclarators(toplevelScope, declarations);
readyToProcessExpressions = true;
resolveBehaviorDeclarationBodies();
return toplevelScope;
}
// @NotNull
// public JetScope process(@NotNull JetScope outerScope, @NotNull List<JetDeclaration> declarations) {
// final WritableScope toplevelScope = new WritableScopeImpl(outerScope, outerScope.getContainingDeclaration(), trace.getErrorHandler(), null); // TODO ?!
//
// collectTypeDeclarators(toplevelScope, declarations);
// resolveTypeDeclarations();
// processBehaviorDeclarators(toplevelScope, declarations);
// readyToProcessExpressions = true;
// resolveBehaviorDeclarationBodies();
// return toplevelScope;
// }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private void collectTypeDeclarators(
@NotNull final WritableScope declaringScope,
List<JetDeclaration> declarations) {
for (JetDeclaration declaration : declarations) {
declaration.accept(new JetVisitor() {
@Override
public void visitNamespace(JetNamespace namespace) {
List<JetImportDirective> importDirectives = namespace.getImportDirectives();
String name = namespace.getName();
if (name == null) {
name = "<no name provided>";
}
NamespaceDescriptorImpl namespaceDescriptor = (NamespaceDescriptorImpl) declaringScope.getDeclaredNamespace(name);
if (namespaceDescriptor == null) {
namespaceDescriptor = new NamespaceDescriptorImpl(
declaringScope.getContainingDeclaration(),
Collections.<Annotation>emptyList(), // TODO
name
);
namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, trace.getErrorHandler(), null));
declaringScope.addNamespace(namespaceDescriptor);
trace.recordDeclarationResolution(namespace, namespaceDescriptor);
}
WritableScope namespaceScope = new WriteThroughScope(declaringScope, (WritableScope) namespaceDescriptor.getMemberScope());
namespaceScopes.put(namespace, namespaceScope);
for (JetImportDirective importDirective : importDirectives) {
if (importDirective.isAbsoluteInRootNamespace()) {
throw new UnsupportedOperationException();
}
if (importDirective.isAllUnder()) {
JetExpression importedReference = importDirective.getImportedReference();
if (importedReference != null) {
JetType type = semanticServices.getTypeInferrer(trace, JetFlowInformationProvider.THROW_EXCEPTION).getTypeWithNamespaces(namespaceScope, importedReference, false);
if (type != null) {
namespaceScope.importScope(type.getMemberScope());
}
}
} else {
throw new UnsupportedOperationException();
}
}
collectTypeDeclarators(namespaceScope, namespace.getDeclarations());
}
@Override
public void visitClass(JetClass klass) {
MutableClassDescriptor mutableClassDescriptor = new MutableClassDescriptor(trace, declaringScope.getContainingDeclaration(), declaringScope);
mutableClassDescriptor.setName(JetPsiUtil.safeName(klass.getName()));
declaringScope.addClassifierDescriptor(mutableClassDescriptor);
classes.put(klass, mutableClassDescriptor);
declaringScopes.put(klass, declaringScope);
WritableScope classScope = mutableClassDescriptor.getScopeForMemberLookup();
collectTypeDeclarators(classScope, klass.getDeclarations());
}
@Override
public void visitTypedef(JetTypedef typedef) {
trace.getErrorHandler().genericError(typedef.getNode(), "Unsupported [TopDownAnalyzer]");
}
@Override
public void visitExtension(JetExtension extension) {
trace.getErrorHandler().genericError(extension.getNode(), "Unsupported [TopDownAnalyzer]");
}
@Override
public void visitDeclaration(JetDeclaration dcl) {
// Other declarations do not declare visible types
}
});
}
}
// private void collectTypeDeclarators(
// @NotNull final WritableScope declaringScope,
// List<JetDeclaration> declarations) {
// for (JetDeclaration declaration : declarations) {
// declaration.accept(new JetVisitor() {
// @Override
// public void visitNamespace(JetNamespace namespace) {
// List<JetImportDirective> importDirectives = namespace.getImportDirectives();
//
// String name = namespace.getName();
// if (name == null) {
// name = "<no name provided>";
// }
// NamespaceDescriptorImpl namespaceDescriptor = (NamespaceDescriptorImpl) declaringScope.getDeclaredNamespace(name);
// if (namespaceDescriptor == null) {
// namespaceDescriptor = new NamespaceDescriptorImpl(
// declaringScope.getContainingDeclaration(),
// Collections.<Annotation>emptyList(), // TODO
// name
// );
// namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, trace.getErrorHandler(), null));
// declaringScope.addNamespace(namespaceDescriptor);
// trace.recordDeclarationResolution(namespace, namespaceDescriptor);
// }
//
// WritableScope namespaceScope = new WriteThroughScope(declaringScope, (WritableScope) namespaceDescriptor.getMemberScope());
// namespaceScopes.put(namespace, namespaceScope);
//
// for (JetImportDirective importDirective : importDirectives) {
// if (importDirective.isAbsoluteInRootNamespace()) {
// throw new UnsupportedOperationException();
// }
// if (importDirective.isAllUnder()) {
// JetExpression importedReference = importDirective.getImportedReference();
// if (importedReference != null) {
// JetType type = semanticServices.getTypeInferrer(trace, JetFlowInformationProvider.THROW_EXCEPTION).getTypeWithNamespaces(namespaceScope, importedReference, false);
// if (type != null) {
// namespaceScope.importScope(type.getMemberScope());
// }
// }
// } else {
// throw new UnsupportedOperationException();
// }
// }
//
// collectTypeDeclarators(namespaceScope, namespace.getDeclarations());
// }
//
// @Override
// public void visitClass(JetClass klass) {
// MutableClassDescriptor mutableClassDescriptor = new MutableClassDescriptor(trace, declaringScope.getContainingDeclaration(), declaringScope);
// mutableClassDescriptor.setName(JetPsiUtil.safeName(klass.getName()));
//
// declaringScope.addClassifierDescriptor(mutableClassDescriptor);
//
// classes.put(klass, mutableClassDescriptor);
// declaringScopes.put(klass, declaringScope);
//
// WritableScope classScope = mutableClassDescriptor.getScopeForMemberLookup();
// collectTypeDeclarators(classScope, klass.getDeclarations());
// }
//
// @Override
// public void visitTypedef(JetTypedef typedef) {
// trace.getErrorHandler().genericError(typedef.getNode(), "Unsupported [TopDownAnalyzer]");
// }
//
// @Override
// public void visitExtension(JetExtension extension) {
// trace.getErrorHandler().genericError(extension.getNode(), "Unsupported [TopDownAnalyzer]");
// }
//
// @Override
// public void visitDeclaration(JetDeclaration dcl) {
// // Other declarations do not declare visible types
// }
// });
// }
// }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private void resolveTypeDeclarations() {
for (Map.Entry<JetClass, MutableClassDescriptor> entry : classes.entrySet()) {
JetClass jetClass = entry.getKey();
MutableClassDescriptor descriptor = entry.getValue();
classDescriptorResolver.resolveMutableClassDescriptor(declaringScopes.get(jetClass), jetClass, descriptor);
}
}
// private void resolveTypeDeclarations() {
// for (Map.Entry<JetClass, MutableClassDescriptor> entry : classes.entrySet()) {
// JetClass jetClass = entry.getKey();
// MutableClassDescriptor descriptor = entry.getValue();
// classDescriptorResolver.resolveMutableClassDescriptor(declaringScopes.get(jetClass), jetClass, descriptor);
// }
// }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private void processBehaviorDeclarators(@NotNull final WritableScope declaringScope, List<JetDeclaration> declarations) {
for (JetDeclaration declaration : declarations) {
declaration.accept(new JetVisitor() {
@Override
public void visitClass(JetClass klass) {
MutableClassDescriptor mutableClassDescriptor = classes.get(klass);
processPrimaryConstructor(mutableClassDescriptor, klass);
processBehaviorDeclarators(mutableClassDescriptor.getScopeForMemberLookup(), klass.getDeclarations());
}
@Override
public void visitClassObject(JetClassObject classObject) {
processClassObject(classObject);
processBehaviorDeclarators(declaringScope, classObject.getObject().getDeclarations());
}
@Override
public void visitNamespace(JetNamespace namespace) {
WritableScope namespaceScope = namespaceScopes.get(namespace);
processBehaviorDeclarators(namespaceScope, namespace.getDeclarations());
}
@Override
public void visitFunction(JetFunction function) {
processFunction(declaringScope, function);
}
@Override
public void visitProperty(JetProperty property) {
processProperty(declaringScope, property);
}
@Override
public void visitConstructor(JetConstructor constructor) {
DeclarationDescriptor containingDeclaration = declaringScope.getContainingDeclaration();
if (containingDeclaration instanceof ClassDescriptor) {
processSecondaryConstructor((MutableClassDescriptor) containingDeclaration, constructor);
}
else {
trace.getErrorHandler().genericError(constructor.getNode(), "Constructors are only allowed inside classes");
}
}
@Override
public void visitAnonymousInitializer(JetClassInitializer initializer) {
// Nothing
}
@Override
public void visitDeclaration(JetDeclaration dcl) {
trace.getErrorHandler().genericError(dcl.getNode(), "[TopDownAnalyzer] Unsupported declaration: " + dcl); // TODO
}
});
}
}
// private void processBehaviorDeclarators(@NotNull final WritableScope declaringScope, List<JetDeclaration> declarations) {
// for (JetDeclaration declaration : declarations) {
// declaration.accept(new JetVisitor() {
// @Override
// public void visitClass(JetClass klass) {
// MutableClassDescriptor mutableClassDescriptor = classes.get(klass);
// processPrimaryConstructor(mutableClassDescriptor, klass);
// processBehaviorDeclarators(mutableClassDescriptor.getScopeForMemberLookup(), klass.getDeclarations());
// }
//
// @Override
// public void visitClassObject(JetClassObject classObject) {
// processClassObject(classObject);
// processBehaviorDeclarators(declaringScope, classObject.getObject().getDeclarations());
// }
//
// @Override
// public void visitNamespace(JetNamespace namespace) {
// WritableScope namespaceScope = namespaceScopes.get(namespace);
// processBehaviorDeclarators(namespaceScope, namespace.getDeclarations());
// }
//
// @Override
// public void visitFunction(JetFunction function) {
// processFunction(declaringScope, function);
// }
//
// @Override
// public void visitProperty(JetProperty property) {
// processProperty(declaringScope, property);
// }
//
// @Override
// public void visitConstructor(JetConstructor constructor) {
// DeclarationDescriptor containingDeclaration = declaringScope.getContainingDeclaration();
// if (containingDeclaration instanceof ClassDescriptor) {
// processSecondaryConstructor((MutableClassDescriptor) containingDeclaration, constructor);
// }
// else {
// trace.getErrorHandler().genericError(constructor.getNode(), "Constructors are only allowed inside classes");
// }
// }
//
// @Override
// public void visitAnonymousInitializer(JetClassInitializer initializer) {
// // Nothing
// }
//
// @Override
// public void visitDeclaration(JetDeclaration dcl) {
// trace.getErrorHandler().genericError(dcl.getNode(), "[TopDownAnalyzer] Unsupported declaration: " + dcl); // TODO
// }
// });
// }
//
// }
private void processPrimaryConstructor(MutableClassDescriptor classDescriptor, JetClass klass) {
if (!klass.hasPrimaryConstructor()) return;
// TODO : not all the parameters are real properties
WritableScope memberScope = classDescriptor.getScopeForMemberLookup(); // TODO : this is REALLY questionable
WritableScope memberScope = classDescriptor.getScopeForMemberResolution(); // TODO : this is REALLY questionable
ConstructorDescriptor constructorDescriptor = classDescriptorResolver.resolvePrimaryConstructorDescriptor(memberScope, classDescriptor, klass);
for (JetParameter parameter : klass.getPrimaryConstructorParameters()) {
PropertyDescriptor propertyDescriptor = classDescriptorResolver.resolvePrimaryConstructorParameterToAProperty(
@@ -441,8 +441,7 @@ public class TopDownAnalyzer {
memberScope,
parameter
);
memberScope.addVariableDescriptor(
propertyDescriptor);
classDescriptor.addPropertyDescriptor(propertyDescriptor);
primaryConstructorParameterProperties.add(propertyDescriptor);
}
if (constructorDescriptor != null) {
@@ -452,7 +451,7 @@ public class TopDownAnalyzer {
private void processSecondaryConstructor(MutableClassDescriptor classDescriptor, JetConstructor constructor) {
ConstructorDescriptor constructorDescriptor = classDescriptorResolver.resolveSecondaryConstructorDescriptor(
classDescriptor.getScopeForMemberLookup(),
classDescriptor.getScopeForMemberResolution(),
classDescriptor,
constructor);
classDescriptor.addConstructor(constructorDescriptor);
@@ -460,25 +459,25 @@ public class TopDownAnalyzer {
declaringScopes.put(constructor, classDescriptor.getScopeForMemberLookup());
}
private void processFunction(@NotNull WritableScope declaringScope, JetFunction function) {
declaringScopes.put(function, declaringScope);
FunctionDescriptorImpl descriptor = classDescriptorResolver.resolveFunctionDescriptor(declaringScope.getContainingDeclaration(), declaringScope, function);
declaringScope.addFunctionDescriptor(descriptor);
functions.put(function, descriptor);
}
private void processProperty(WritableScope declaringScope, JetProperty property) {
declaringScopes.put(property, declaringScope);
// TODO : Do not infer the type from the initializer here: the scope is wrong, and not ready anyway
PropertyDescriptor descriptor = classDescriptorResolver.resolvePropertyDescriptor(declaringScope.getContainingDeclaration(), declaringScope, property);
declaringScope.addVariableDescriptor(descriptor);
declaringScopesToProperties.put(declaringScope.getContainingDeclaration(), descriptor);
properties.put(property, descriptor);
}
private void processClassObject(JetClassObject classObject) {
trace.getErrorHandler().genericError(classObject.getNode(), "Class objects are not supported yet"); // TODO
}
// private void processFunction(@NotNull WritableScope declaringScope, JetFunction function) {
// declaringScopes.put(function, declaringScope);
// FunctionDescriptorImpl descriptor = classDescriptorResolver.resolveFunctionDescriptor(declaringScope.getContainingDeclaration(), declaringScope, function);
// declaringScope.addFunctionDescriptor(descriptor);
// functions.put(function, descriptor);
// }
//
// private void processProperty(WritableScope declaringScope, JetProperty property) {
// declaringScopes.put(property, declaringScope);
// // TODO : Do not infer the type from the initializer here: the scope is wrong, and not ready anyway
// PropertyDescriptor descriptor = classDescriptorResolver.resolvePropertyDescriptor(declaringScope.getContainingDeclaration(), declaringScope, property);
// declaringScope.addVariableDescriptor(descriptor);
// declaringScopesToProperties.put(declaringScope.getContainingDeclaration(), descriptor);
// properties.put(property, descriptor);
// }
//
// private void processClassObject(JetClassObject classObject) {
// trace.getErrorHandler().genericError(classObject.getNode(), "Class objects are not supported yet"); // TODO
// }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -550,7 +549,9 @@ public class TopDownAnalyzer {
final JetClass jetClass = entry.getKey();
final MutableClassDescriptor descriptor = entry.getValue();
final ConstructorDescriptor primaryConstructor = descriptor.getUnsubstitutedPrimaryConstructor();
final JetScope scopeForConstructor = primaryConstructor == null ? null : getInnerScopeForConstructor(primaryConstructor, descriptor.getScopeForMemberLookup());
final JetScope scopeForConstructor = primaryConstructor == null
? null
: getInnerScopeForConstructor(primaryConstructor, descriptor.getScopeForMemberResolution());
final JetTypeInferrer typeInferrer = semanticServices.getTypeInferrer(traceForConstructors, JetFlowInformationProvider.NONE); // TODO : flow
for (JetDelegationSpecifier delegationSpecifier : jetClass.getDelegationSpecifiers()) {
@@ -559,7 +560,7 @@ public class TopDownAnalyzer {
public void visitDelegationByExpressionSpecifier(JetDelegatorByExpressionSpecifier specifier) {
JetExpression delegateExpression = specifier.getDelegateExpression();
if (delegateExpression != null) {
JetScope scope = scopeForConstructor == null ? descriptor.getScopeForMemberLookup() : scopeForConstructor;
JetScope scope = scopeForConstructor == null ? descriptor.getScopeForMemberResolution() : scopeForConstructor;
JetType type = typeInferrer.getType(scope, delegateExpression, false);
JetType supertype = trace.resolveTypeReference(specifier.getTypeReference());
if (type != null && !semanticServices.getTypeChecker().isSubtypeOf(type, supertype)) { // TODO : Convertible?
@@ -625,7 +626,7 @@ public class TopDownAnalyzer {
if (jetClass.hasPrimaryConstructor()) {
ConstructorDescriptor primaryConstructor = classDescriptor.getUnsubstitutedPrimaryConstructor();
assert primaryConstructor != null;
final JetScope scopeForConstructor = getInnerScopeForConstructor(primaryConstructor, classDescriptor.getScopeForMemberLookup());
final JetScope scopeForConstructor = getInnerScopeForConstructor(primaryConstructor, classDescriptor.getScopeForMemberResolution());
JetTypeInferrer typeInferrer = semanticServices.getTypeInferrer(traceForConstructors, JetFlowInformationProvider.NONE); // TODO : flow
for (JetClassInitializer anonymousInitializer : anonymousInitializers) {
typeInferrer.getType(scopeForConstructor, anonymousInitializer.getBody(), true);
@@ -725,7 +726,7 @@ public class TopDownAnalyzer {
@NotNull
private JetScope getInnerScopeForConstructor(@NotNull ConstructorDescriptor descriptor, @NotNull JetScope declaringScope) {
WritableScope constructorScope = new WritableScopeImpl(declaringScope, declaringScope.getContainingDeclaration(), trace.getErrorHandler(), null);
for (PropertyDescriptor propertyDescriptor : declaringScopesToProperties.get(descriptor.getContainingDeclaration())) {
for (PropertyDescriptor propertyDescriptor : ((MutableClassDescriptor) descriptor.getContainingDeclaration()).getProperties()) {
constructorScope.addPropertyDescriptorByFieldName("$" + propertyDescriptor.getName(), propertyDescriptor);
}
return FunctionDescriptorUtil.getFunctionInnerScope(constructorScope, descriptor, trace);
@@ -752,7 +753,7 @@ public class TopDownAnalyzer {
trace.getErrorHandler().genericError(initializer.getNode(), "Property initializers are not allowed when no primary constructor is present");
}
else {
JetScope scope = getInnerScopeForConstructor(primaryConstructor, classDescriptor.getScopeForMemberLookup());
JetScope scope = getInnerScopeForConstructor(primaryConstructor, classDescriptor.getScopeForMemberResolution());
resolvePropertyInitializer(property, propertyDescriptor, initializer, scope);
}
}
@@ -183,13 +183,14 @@ public class WritableScopeImpl extends WritableScopeWithImports {
@Override
public void addTypeParameterDescriptor(@NotNull TypeParameterDescriptor typeParameterDescriptor) {
String name = typeParameterDescriptor.getName();
Map<String, ClassifierDescriptor> classifierDescriptors = getClassifierDescriptors();
ClassifierDescriptor originalDescriptor = classifierDescriptors.get(name);
if (originalDescriptor != null) {
errorHandler.redeclaration(originalDescriptor, typeParameterDescriptor);
}
classifierDescriptors.put(name, typeParameterDescriptor);
notifyListeners(typeParameterDescriptor);
addClassifierAlias(name, typeParameterDescriptor);
// Map<String, ClassifierDescriptor> classifierDescriptors = getClassifierDescriptors();
// ClassifierDescriptor originalDescriptor = classifierDescriptors.get(name);
// if (originalDescriptor != null) {
// errorHandler.redeclaration(originalDescriptor, typeParameterDescriptor);
// }
// classifierDescriptors.put(name, typeParameterDescriptor);
// notifyListeners(typeParameterDescriptor);
}
@NotNull
@@ -0,0 +1,9 @@
var xxxx = 1
~SimpleClass~class SimpleClass(x : Int) {
fun foo() = x
}
fun foo() {
new `SimpleClass`SimpleClass(1).`!`xxxx
}