Fir incorrect usage of AbstractExpectActualCompatibilityChecker.getCallablesCompatibility API
^KT-62027 Fixed `getCallablesCompatibility` requires parentSubstitutor as a parameter, but we created a member-level substitutor `getCallablesCompatibility` will create member-level substitutor itself, no need to create member-level substitutor on the call site. IndexOutOfBounds was happening in an attempt of creating member-level substitutor I will refactor the `createExpectActualTypeParameterSubstitutor` API in the following commits later. It will help to avoid problems like that
This commit is contained in:
+6
@@ -640,6 +640,12 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectVarargParameterOverload.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt62027.kt")
|
||||
public void testKt62027() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/kt62027.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberScopeMismatch_oldLanguageVersion.kt")
|
||||
public void testMemberScopeMismatch_oldLanguageVersion() throws Exception {
|
||||
|
||||
+6
@@ -640,6 +640,12 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectVarargParameterOverload.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt62027.kt")
|
||||
public void testKt62027() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/kt62027.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberScopeMismatch_oldLanguageVersion.kt")
|
||||
public void testMemberScopeMismatch_oldLanguageVersion() throws Exception {
|
||||
|
||||
+4
-6
@@ -137,6 +137,9 @@ private fun calculateExpectActualScopeDiff(
|
||||
actual: ClassDescriptor,
|
||||
): Set<ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>> {
|
||||
val matchingContext = ClassicExpectActualMatchingContext(actual.module)
|
||||
// It's responsibility of AbstractExpectActualCompatibilityChecker to report that. Most probably this check is redundant,
|
||||
// because we can't reach this line if expect and actual don't match, but let's have it for safety
|
||||
if (expect.declaredTypeParameters.size != actual.declaredTypeParameters.size) return emptySet()
|
||||
val classTypeSubstitutor = matchingContext.createExpectActualTypeParameterSubstitutor(
|
||||
expect.declaredTypeParameters,
|
||||
actual.declaredTypeParameters,
|
||||
@@ -156,15 +159,10 @@ private fun calculateExpectActualScopeDiff(
|
||||
} else {
|
||||
potentialExpects
|
||||
.map { expectMember ->
|
||||
val substitutor = matchingContext.createExpectActualTypeParameterSubstitutor(
|
||||
expectMember.typeParameters,
|
||||
actualMember.typeParameters,
|
||||
classTypeSubstitutor
|
||||
)
|
||||
AbstractExpectActualCompatibilityChecker.getCallablesCompatibility(
|
||||
expectMember,
|
||||
actualMember,
|
||||
substitutor,
|
||||
classTypeSubstitutor,
|
||||
expect,
|
||||
actual,
|
||||
matchingContext
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect open class Foo {
|
||||
fun <T> foo(t: T)
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open class Foo {
|
||||
actual fun <T> foo(t: T) {}
|
||||
fun foo(t: String) {}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect open class Foo {
|
||||
fun <T> foo(t: T)
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual open <!ACTUAL_CLASSIFIER_MUST_HAVE_THE_SAME_MEMBERS_AS_NON_FINAL_EXPECT_CLASSIFIER!>class Foo<!> {
|
||||
actual fun <T> foo(t: T) {}
|
||||
fun <!NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION!>foo<!>(t: String) {}
|
||||
}
|
||||
Generated
+6
@@ -23641,6 +23641,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/injectVarargParameterOverload.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt62027.kt")
|
||||
public void testKt62027() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/actualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker/kt62027.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("memberScopeMismatch_oldLanguageVersion.kt")
|
||||
public void testMemberScopeMismatch_oldLanguageVersion() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user