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
This commit is contained in:
Dmitry Savvinov
2021-02-25 17:49:46 +03:00
parent 9616eb94fd
commit 168c692a27
2 changed files with 3 additions and 2 deletions
@@ -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<D>,
exactDescriptorClass: Class<out D>
) {
c.kotlinTypeChecker.overridingUtil.generateOverridesInFunctionGroup(
NewKotlinTypeCheckerImpl(kotlinTypeRefiner).overridingUtil.generateOverridesInFunctionGroup(
name,
fromSupertypes,
ArrayList(result),
+1 -1
View File
@@ -1,3 +1,3 @@
package sample
public <!ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED!>class Concrete<!> : Base()
public class Concrete : Base()