From 168c692a273fe1c9ad7221b0fb40a75b72171b77 Mon Sep 17 00:00:00 2001 From: Dmitry Savvinov Date: Thu, 25 Feb 2021 17:49:46 +0300 Subject: [PATCH] Use overriding util with proper typechecker for overriding in LazyClassMemberScope Note that LazyClassMemberScope actually has a separate field for KotlinTypeRefiner, and it might be actually different from the one in c.kotlinTypeChecker. The one in c.kotlinTypeChecker is the refiner of *owner* module, i.e. a module in which the class has been declared. If we have a class Foo : Expect in common, then the refiner will be from common, and thus it won't be able to refine supertypes to their platform-dependent values. The one passed in constructor is actual refiner of dependant-module. Say, if we're looking at Foo from the point of view of jvmMain, then we'll create a (view-dependent) LCMS for that, and it will contain refiner for jvmMain. It is important to use proper refiner, otherwise the idea of having "module-dependent view" breaks, and we might suddenly mismatch some overrides with expect-classes in their signatures. ^KT-44898 Fixed --- .../kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt | 3 ++- idea/testData/multiplatform/kt44898/jvm/Concrete.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt index 6cb62886d62..5eb085fc77f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt @@ -43,6 +43,7 @@ import org.jetbrains.kotlin.storage.NullableLazyValue import org.jetbrains.kotlin.storage.getValue import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner +import org.jetbrains.kotlin.types.checker.NewKotlinTypeCheckerImpl import org.jetbrains.kotlin.types.refinement.TypeRefinement import org.jetbrains.kotlin.utils.addToStdlib.flatMapToNullable import java.util.* @@ -202,7 +203,7 @@ open class LazyClassMemberScope( result: MutableCollection, exactDescriptorClass: Class ) { - c.kotlinTypeChecker.overridingUtil.generateOverridesInFunctionGroup( + NewKotlinTypeCheckerImpl(kotlinTypeRefiner).overridingUtil.generateOverridesInFunctionGroup( name, fromSupertypes, ArrayList(result), diff --git a/idea/testData/multiplatform/kt44898/jvm/Concrete.kt b/idea/testData/multiplatform/kt44898/jvm/Concrete.kt index bd7c05229cb..5fe05c41227 100644 --- a/idea/testData/multiplatform/kt44898/jvm/Concrete.kt +++ b/idea/testData/multiplatform/kt44898/jvm/Concrete.kt @@ -1,3 +1,3 @@ package sample -public class Concrete : Base() +public class Concrete : Base()