Review fixes:
Use `StorageManager.createLazyValue` instead of default lazy delegate Introduce `initialize` method instead of exposing type parameters
This commit is contained in:
committed by
Leonid Startsev
parent
666553e413
commit
01b40d4d02
+10
-4
@@ -50,15 +50,21 @@ class SyntheticClassOrObjectDescriptor(
|
|||||||
val syntheticDeclaration: KtPureClassOrObject = SyntheticDeclaration(parentClassOrObject, name.asString())
|
val syntheticDeclaration: KtPureClassOrObject = SyntheticDeclaration(parentClassOrObject, name.asString())
|
||||||
|
|
||||||
private val thisDescriptor: SyntheticClassOrObjectDescriptor get() = this // code readability
|
private val thisDescriptor: SyntheticClassOrObjectDescriptor get() = this // code readability
|
||||||
var typeParameters: List<TypeParameterDescriptor> = emptyList()
|
|
||||||
|
|
||||||
|
private lateinit var typeParameters: List<TypeParameterDescriptor>
|
||||||
private val typeConstructor = SyntheticTypeConstructor(c.storageManager)
|
private val typeConstructor = SyntheticTypeConstructor(c.storageManager)
|
||||||
private val resolutionScopesSupport = ClassResolutionScopesSupport(thisDescriptor, c.storageManager, c.languageVersionSettings, { outerScope })
|
private val resolutionScopesSupport = ClassResolutionScopesSupport(thisDescriptor, c.storageManager, c.languageVersionSettings, { outerScope })
|
||||||
private val syntheticSupertypes =
|
private val syntheticSupertypes =
|
||||||
mutableListOf<KotlinType>().apply { c.syntheticResolveExtension.addSyntheticSupertypes(thisDescriptor, this) }
|
mutableListOf<KotlinType>().apply { c.syntheticResolveExtension.addSyntheticSupertypes(thisDescriptor, this) }
|
||||||
private val unsubstitutedMemberScope =
|
private val unsubstitutedMemberScope =
|
||||||
LazyClassMemberScope(c, SyntheticClassMemberDeclarationProvider(syntheticDeclaration), this, c.trace)
|
LazyClassMemberScope(c, SyntheticClassMemberDeclarationProvider(syntheticDeclaration), this, c.trace)
|
||||||
private val _unsubstitutedPrimaryConstructor by lazy { createUnsubstitutedPrimaryConstructor(constructorVisibility) }
|
private val _unsubstitutedPrimaryConstructor =
|
||||||
|
c.storageManager.createLazyValue { createUnsubstitutedPrimaryConstructor(constructorVisibility) }
|
||||||
|
|
||||||
|
@JvmOverloads
|
||||||
|
fun initialize(typeParameters: List<TypeParameterDescriptor> = emptyList()) {
|
||||||
|
this.typeParameters = typeParameters
|
||||||
|
}
|
||||||
|
|
||||||
override val annotations: Annotations get() = Annotations.EMPTY
|
override val annotations: Annotations get() = Annotations.EMPTY
|
||||||
|
|
||||||
@@ -74,8 +80,8 @@ class SyntheticClassOrObjectDescriptor(
|
|||||||
|
|
||||||
override fun getCompanionObjectDescriptor(): ClassDescriptorWithResolutionScopes? = null
|
override fun getCompanionObjectDescriptor(): ClassDescriptorWithResolutionScopes? = null
|
||||||
override fun getTypeConstructor(): TypeConstructor = typeConstructor
|
override fun getTypeConstructor(): TypeConstructor = typeConstructor
|
||||||
override fun getUnsubstitutedPrimaryConstructor() = _unsubstitutedPrimaryConstructor
|
override fun getUnsubstitutedPrimaryConstructor() = _unsubstitutedPrimaryConstructor()
|
||||||
override fun getConstructors() = listOf(_unsubstitutedPrimaryConstructor)
|
override fun getConstructors() = listOf(_unsubstitutedPrimaryConstructor())
|
||||||
override fun getDeclaredTypeParameters() = typeParameters
|
override fun getDeclaredTypeParameters() = typeParameters
|
||||||
override fun getStaticScope() = MemberScope.Empty
|
override fun getStaticScope() = MemberScope.Empty
|
||||||
override fun getUnsubstitutedMemberScope() = unsubstitutedMemberScope
|
override fun getUnsubstitutedMemberScope() = unsubstitutedMemberScope
|
||||||
|
|||||||
+3
-1
@@ -435,11 +435,13 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
Name syntheticCompanionName = c.getSyntheticResolveExtension().getSyntheticCompanionObjectNameIfNeeded(this);
|
Name syntheticCompanionName = c.getSyntheticResolveExtension().getSyntheticCompanionObjectNameIfNeeded(this);
|
||||||
if (syntheticCompanionName == null)
|
if (syntheticCompanionName == null)
|
||||||
return null;
|
return null;
|
||||||
return new SyntheticClassOrObjectDescriptor(c,
|
SyntheticClassOrObjectDescriptor companionDescriptor = new SyntheticClassOrObjectDescriptor(c,
|
||||||
/* parentClassOrObject= */ classOrObject,
|
/* parentClassOrObject= */ classOrObject,
|
||||||
this, syntheticCompanionName, getSource(),
|
this, syntheticCompanionName, getSource(),
|
||||||
/* outerScope= */ getOuterScope(),
|
/* outerScope= */ getOuterScope(),
|
||||||
Modality.FINAL, PUBLIC, PRIVATE, ClassKind.OBJECT, true);
|
Modality.FINAL, PUBLIC, PRIVATE, ClassKind.OBJECT, true);
|
||||||
|
companionDescriptor.initialize();
|
||||||
|
return companionDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
Reference in New Issue
Block a user