Introduce ClassDescriptor#getStaticScope()

Will be used to exterminate hacks related to static Java methods in our
codebase: synthetic class object for enum, synthetic package for static members
of Java classes, etc.
This commit is contained in:
Alexander Udalov
2014-09-03 12:03:13 +04:00
parent 7ad88f7799
commit 75df4a9ad8
10 changed files with 98 additions and 3 deletions
@@ -57,8 +57,9 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
private final WritableScope scopeForMemberResolution;
// This scope contains type parameters but does not contain inner classes
private final WritableScope scopeForSupertypeResolution;
private WritableScope scopeForInitializers = null; //contains members + primary constructor value parameters + map for backing fields
private WritableScope scopeForInitializers; //contains members + primary constructor value parameters + map for backing fields
private JetScope scopeForMemberLookup;
private final JetScope staticScope = new StaticScopeForKotlinClass(this);
public MutableClassDescriptor(
@NotNull DeclarationDescriptor containingDeclaration,
@@ -295,6 +296,12 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
return (WritableScope) scopeForMemberLookup;
}
@NotNull
@Override
public JetScope getStaticScope() {
return staticScope;
}
public void lockScopes() {
getScopeForMemberLookupAsWritableScope().changeLockLevel(WritableScope.LockLevel.READING);
if (classObjectDescriptor instanceof MutableClassDescriptor) {
@@ -88,6 +88,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
private final MemoizedFunctionToNotNull<JetClassObject, ClassDescriptor> extraClassObjectDescriptors;
private final LazyClassMemberScope unsubstitutedMemberScope;
private final JetScope staticScope = new StaticScopeForKotlinClass(this);
private final NotNullLazyValue<JetScope> scopeForClassHeaderResolution;
private final NotNullLazyValue<JetScope> scopeForMemberDeclarationResolution;
@@ -300,6 +301,12 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
scope, getScopeForMemberDeclarationResolution());
}
@NotNull
@Override
public JetScope getStaticScope() {
return staticScope;
}
@NotNull
@Override
public Collection<ConstructorDescriptor> getConstructors() {