[FIR] Don't traverse expect hierarchy to check DefaultArgumentsInExpectActualizedByFakeOverride
^KT-63860 Fixed Review: https://jetbrains.team/p/kt/reviews/13334/timeline The previous code was nonsense (I wrote it). It doesn't make sense to subtract actualOverriddenDeclarations from expectOverriddenDeclarations. Default parameters are mentioned on the expect side. So default params in expect/actual supertypes won't be subtracted from expectOverriddenDeclarations (but should be)
This commit is contained in:
+12
@@ -24066,6 +24066,18 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt60902.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63860.kt")
|
||||
public void testKt63860() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt63860.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63860_2.kt")
|
||||
public void testKt63860_2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt63860_2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyImplMemberNotImplemented.kt")
|
||||
public void testManyImplMemberNotImplemented() throws Exception {
|
||||
|
||||
+12
@@ -24066,6 +24066,18 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt60902.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63860.kt")
|
||||
public void testKt63860() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt63860.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63860_2.kt")
|
||||
public void testKt63860_2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt63860_2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyImplMemberNotImplemented.kt")
|
||||
public void testManyImplMemberNotImplemented() throws Exception {
|
||||
|
||||
+12
@@ -313,6 +313,18 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt60902.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63860.kt")
|
||||
public void testKt63860() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt63860.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63860_2.kt")
|
||||
public void testKt63860_2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt63860_2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyImplMemberNotImplemented.kt")
|
||||
public void testManyImplMemberNotImplemented() throws Exception {
|
||||
|
||||
+12
@@ -313,6 +313,18 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt60902.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63860.kt")
|
||||
public void testKt63860() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt63860.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63860_2.kt")
|
||||
public void testKt63860_2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt63860_2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyImplMemberNotImplemented.kt")
|
||||
public void testManyImplMemberNotImplemented() throws Exception {
|
||||
|
||||
+9
-8
@@ -373,20 +373,21 @@ object AbstractExpectActualChecker {
|
||||
// "parameters" checks are required only for functions, because only functions can have parameters
|
||||
actualDeclaration is FunctionSymbolMarker && expectDeclaration is FunctionSymbolMarker
|
||||
) {
|
||||
val expectOverriddenDeclarations =
|
||||
expectDeclaration.allRecursivelyOverriddenDeclarationsIncludingSelf(expectContainingClass).toSet()
|
||||
val actualOverriddenDeclarations =
|
||||
actualDeclaration.allRecursivelyOverriddenDeclarationsIncludingSelf(actualContainingClass).toSet()
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.ProhibitDefaultArgumentsInExpectActualizedByFakeOverride) &&
|
||||
// If expect declaration is a fake-override then default params came from common
|
||||
// supertypes of actual class and expect class. It's a valid code.
|
||||
!expectDeclaration.isFakeOverride(expectContainingClass) &&
|
||||
(actualDeclaration.isFakeOverride(actualContainingClass) || actualDeclaration.isDelegatedMember) &&
|
||||
// If default params came from common supertypes of actual class and expect class then it's a valid code.
|
||||
// Here we filter out such default params.
|
||||
(expectOverriddenDeclarations - actualOverriddenDeclarations).flatMap { it.valueParameters }
|
||||
.any { it.hasDefaultValueNonRecursive }
|
||||
expectDeclaration.valueParameters.any { it.hasDefaultValueNonRecursive }
|
||||
) {
|
||||
return ExpectActualCheckingCompatibility.DefaultArgumentsInExpectActualizedByFakeOverride
|
||||
}
|
||||
|
||||
val expectOverriddenDeclarations =
|
||||
expectDeclaration.allRecursivelyOverriddenDeclarationsIncludingSelf(expectContainingClass).toSet()
|
||||
val actualOverriddenDeclarations =
|
||||
actualDeclaration.allRecursivelyOverriddenDeclarationsIncludingSelf(actualContainingClass)
|
||||
|
||||
// Actual annotation constructors can have default argument values; their consistency with arguments in the expected annotation
|
||||
// is checked in ExpectedActualDeclarationChecker.checkAnnotationConstructors
|
||||
if (!actualDeclaration.isAnnotationConstructor() &&
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// FIR_IDENTICAL
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect interface SdkBufferedSink {
|
||||
public fun write(arg: String = "default")
|
||||
}
|
||||
|
||||
abstract class AbstractBufferedSinkAdapter() : SdkBufferedSink {
|
||||
override fun write(arg: String) {
|
||||
}
|
||||
}
|
||||
|
||||
expect class BufferedSinkAdapter() : SdkBufferedSink {
|
||||
override fun write(arg: String)
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual interface SdkBufferedSink {
|
||||
public actual fun write(arg: String): Unit
|
||||
}
|
||||
|
||||
actual class BufferedSinkAdapter actual constructor() : AbstractBufferedSinkAdapter(), SdkBufferedSink {
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// FIR_IDENTICAL
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
expect interface SdkBufferedSink {
|
||||
public fun write(arg: String = "default")
|
||||
}
|
||||
|
||||
abstract class AbstractBufferedSinkAdapter() {
|
||||
fun write(arg: String) {
|
||||
}
|
||||
}
|
||||
|
||||
expect class BufferedSinkAdapter() : SdkBufferedSink {
|
||||
override fun write(arg: String)
|
||||
}
|
||||
|
||||
// MODULE: m2-jvm()()(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
actual interface SdkBufferedSink {
|
||||
public actual fun write(arg: String): Unit
|
||||
}
|
||||
|
||||
actual class BufferedSinkAdapter actual constructor() : AbstractBufferedSinkAdapter(), SdkBufferedSink {
|
||||
}
|
||||
Generated
+12
@@ -24066,6 +24066,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt60902.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63860.kt")
|
||||
public void testKt63860() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt63860.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt63860_2.kt")
|
||||
public void testKt63860_2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multiplatform/kt63860_2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyImplMemberNotImplemented.kt")
|
||||
public void testManyImplMemberNotImplemented() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user