Minor: use more clear and specific naming for LazyClassContext.typeChecker (relevant for MPP with type refinement)
This commit is contained in:
@@ -45,8 +45,24 @@ interface LazyClassContext {
|
||||
val syntheticResolveExtension: SyntheticResolveExtension
|
||||
val delegationFilter: DelegationFilter
|
||||
val wrappedTypeFactory: WrappedTypeFactory
|
||||
val kotlinTypeChecker: NewKotlinTypeChecker
|
||||
val samConversionResolver: SamConversionResolver
|
||||
val additionalClassPartsProvider: AdditionalClassPartsProvider
|
||||
val sealedClassInheritorsProvider: SealedClassInheritorsProvider
|
||||
|
||||
/**
|
||||
* Important notice!
|
||||
*
|
||||
* This is the type checker of *owner* module, i.e. the module which has declared the class.
|
||||
*
|
||||
* In MPP, we have different "views" on the one and the same class. I.e. if we have a common 'class Foo : Expect',
|
||||
* and on JVM we have 'actual typealias Expect = CharSequence', then from "common view" Foo isn't assigneable to CharSequence,
|
||||
* while from the "JVM view" it is.
|
||||
*
|
||||
* LazyClassContext is usually shared across all such views, so be careful - using this typechecker in "platform views" is not correct.
|
||||
* Relevant entities usually have a separate instance of KotlinTypeChecker/KotlinTypeRefiner, see for example
|
||||
* [org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassMemberScope].
|
||||
*
|
||||
* See also KT-44898 for example of issues which might happen if the wrong typechecker is used in "platform view".
|
||||
*/
|
||||
val kotlinTypeCheckerOfOwnerModule: NewKotlinTypeChecker
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NewKotlinTypeChecker getKotlinTypeChecker() {
|
||||
public NewKotlinTypeChecker getKotlinTypeCheckerOfOwnerModule() {
|
||||
return kotlinTypeChecker;
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -327,16 +327,15 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
return ScopesHolderForClass.Companion.create(
|
||||
this,
|
||||
c.getStorageManager(),
|
||||
c.getKotlinTypeChecker().getKotlinTypeRefiner(),
|
||||
kotlinTypeRefiner -> {
|
||||
c.getKotlinTypeCheckerOfOwnerModule().getKotlinTypeRefiner(),
|
||||
kotlinTypeRefinerForDependentModule -> {
|
||||
LazyClassMemberScope scopeForDeclaredMembers =
|
||||
!kotlinTypeRefiner.isRefinementNeededForModule(c.getModuleDescriptor())
|
||||
!kotlinTypeRefinerForDependentModule.isRefinementNeededForModule(c.getModuleDescriptor())
|
||||
? null
|
||||
// TODO: or kotlinTypeRefiner.getModuleDescriptor()
|
||||
: scopesHolderForClass.getScope(c.getKotlinTypeChecker().getKotlinTypeRefiner());
|
||||
: scopesHolderForClass.getScope(c.getKotlinTypeCheckerOfOwnerModule().getKotlinTypeRefiner()); // essentially, a scope for owner-module
|
||||
|
||||
return new LazyClassMemberScope(
|
||||
c, declarationProvider, this, c.getTrace(), kotlinTypeRefiner,
|
||||
c, declarationProvider, this, c.getTrace(), kotlinTypeRefinerForDependentModule,
|
||||
scopeForDeclaredMembers
|
||||
);
|
||||
}
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ open class LazyClassMemberScope(
|
||||
declarationProvider: ClassMemberDeclarationProvider,
|
||||
thisClass: ClassDescriptorWithResolutionScopes,
|
||||
trace: BindingTrace,
|
||||
private val kotlinTypeRefiner: KotlinTypeRefiner = c.kotlinTypeChecker.kotlinTypeRefiner,
|
||||
private val kotlinTypeRefiner: KotlinTypeRefiner = c.kotlinTypeCheckerOfOwnerModule.kotlinTypeRefiner,
|
||||
scopeForDeclaredMembers: LazyClassMemberScope? = null
|
||||
) : AbstractLazyMemberScope<ClassDescriptorWithResolutionScopes, ClassMemberDeclarationProvider>(
|
||||
c, declarationProvider, thisClass, trace, scopeForDeclaredMembers
|
||||
|
||||
+1
-1
@@ -184,7 +184,7 @@ class LocalClassDescriptorHolder(
|
||||
override val syntheticResolveExtension = this@LocalClassDescriptorHolder.syntheticResolveExtension
|
||||
override val delegationFilter: DelegationFilter = this@LocalClassDescriptorHolder.delegationFilter
|
||||
override val wrappedTypeFactory: WrappedTypeFactory = this@LocalClassDescriptorHolder.wrappedTypeFactory
|
||||
override val kotlinTypeChecker: NewKotlinTypeChecker = this@LocalClassDescriptorHolder.kotlinTypeChecker
|
||||
override val kotlinTypeCheckerOfOwnerModule: NewKotlinTypeChecker = this@LocalClassDescriptorHolder.kotlinTypeChecker
|
||||
override val samConversionResolver: SamConversionResolver = this@LocalClassDescriptorHolder.samConversionResolver
|
||||
override val additionalClassPartsProvider: AdditionalClassPartsProvider =
|
||||
this@LocalClassDescriptorHolder.additionalClassPartsProvider
|
||||
|
||||
+2
-2
@@ -148,11 +148,11 @@ class LazyScriptDescriptor(
|
||||
override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R =
|
||||
visitor.visitScriptDescriptor(this, data)
|
||||
|
||||
override fun createMemberScope(
|
||||
override fun createScopesHolderForClass(
|
||||
c: LazyClassContext,
|
||||
declarationProvider: ClassMemberDeclarationProvider
|
||||
): ScopesHolderForClass<LazyClassMemberScope> =
|
||||
ScopesHolderForClass.create(this, c.storageManager, c.kotlinTypeChecker.kotlinTypeRefiner) {
|
||||
ScopesHolderForClass.create(this, c.storageManager, c.kotlinTypeCheckerOfOwnerModule.kotlinTypeRefiner) {
|
||||
LazyScriptClassMemberScope(
|
||||
// Must be a ResolveSession for scripts
|
||||
c as ResolveSession,
|
||||
|
||||
Reference in New Issue
Block a user