Fix header scope for secondary constructors

Add companion object's scope and nested classes

 #KT-6996 fixed
This commit is contained in:
Denis Zharkov
2015-03-17 19:34:47 +03:00
parent 977b743f3d
commit bd5dbb665e
6 changed files with 93 additions and 4 deletions
@@ -277,20 +277,22 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
thisScope.setImplicitReceiver(this.getThisAsReceiverParameter());
thisScope.changeLockLevel(WritableScope.LockLevel.READING);
ClassDescriptor companionObjectDescriptor = getCompanionObjectDescriptor();
JetScope companionObjectAdapterScope = (companionObjectDescriptor != null) ? new CompanionObjectMixinScope(companionObjectDescriptor) : JetScope.Empty.INSTANCE$;
return new ChainedScope(
this,
"ScopeForMemberDeclarationResolution: " + getName(),
thisScope,
getScopeForMemberLookup(),
getScopeForClassHeaderResolution(),
companionObjectAdapterScope,
getCompanionObjectScope(),
getStaticScope()
);
}
private JetScope getCompanionObjectScope() {
ClassDescriptor companionObjectDescriptor = getCompanionObjectDescriptor();
return (companionObjectDescriptor != null) ? new CompanionObjectMixinScope(companionObjectDescriptor) : JetScope.Empty.INSTANCE$;
}
@Override
@NotNull
public JetScope getScopeForInitializerResolution() {
@@ -346,6 +348,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
this,
"ScopeForSecondaryConstructorHeaderResolution: " + getName(),
getScopeForClassHeaderResolution(),
getCompanionObjectScope(),
DescriptorUtils.getStaticNestedClassesScope(this),
getStaticScope()
);
}