K2: repeat K1 behavior around multiple inheritance by delegation
#KT-56720 Fixed
This commit is contained in:
committed by
Space Team
parent
ab883d91c8
commit
45e78455b2
+7
-1
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED
|
||||
import org.jetbrains.kotlin.fir.containingClassLookupTag
|
||||
import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.*
|
||||
import org.jetbrains.kotlin.fir.delegatedWrapperData
|
||||
@@ -71,7 +72,12 @@ object FirNotImplementedOverrideChecker : FirClassChecker() {
|
||||
val delegatedTo = delegatedWrapperData.wrapped.unwrapFakeOverrides().symbol
|
||||
|
||||
if (symbol.multipleDelegatesWithTheSameSignature == true) {
|
||||
manyImplementationsDelegationSymbols.add(symbol)
|
||||
if (directOverriddenMembersWithBaseScope.isNotEmpty() &&
|
||||
// We should report here if either 2+ members or single member with non-enhancement origin
|
||||
directOverriddenMembersWithBaseScope.singleOrNull()?.member?.origin != FirDeclarationOrigin.Enhancement
|
||||
) {
|
||||
manyImplementationsDelegationSymbols.add(symbol)
|
||||
}
|
||||
}
|
||||
|
||||
val firstFinal = filteredOverriddenMembers.firstOrNull { it.isFinal }
|
||||
|
||||
+12
@@ -18445,6 +18445,18 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
||||
runTest("compiler/testData/codegen/box/fir/LookupTags.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyImplFromOneJavaInterfaceWithDelegation.kt")
|
||||
public void testManyImplFromOneJavaInterfaceWithDelegation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/manyImplFromOneJavaInterfaceWithDelegation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyImplFromOneJavaInterfaceWithDelegation2.kt")
|
||||
public void testManyImplFromOneJavaInterfaceWithDelegation2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/manyImplFromOneJavaInterfaceWithDelegation2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NameHighlighter.kt")
|
||||
public void testNameHighlighter() throws Exception {
|
||||
|
||||
+12
@@ -18445,6 +18445,18 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
||||
runTest("compiler/testData/codegen/box/fir/LookupTags.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyImplFromOneJavaInterfaceWithDelegation.kt")
|
||||
public void testManyImplFromOneJavaInterfaceWithDelegation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/manyImplFromOneJavaInterfaceWithDelegation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyImplFromOneJavaInterfaceWithDelegation2.kt")
|
||||
public void testManyImplFromOneJavaInterfaceWithDelegation2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/manyImplFromOneJavaInterfaceWithDelegation2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NameHighlighter.kt")
|
||||
public void testNameHighlighter() throws Exception {
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// JVM_TARGET: 1.8
|
||||
// FILE: A.java
|
||||
|
||||
public interface A {
|
||||
default String foo() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
public interface B extends A {}
|
||||
|
||||
// FILE: C.java
|
||||
|
||||
public interface C extends A {}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
class Adapter : B, C
|
||||
|
||||
class D(val adapter: Adapter) : B by adapter, C by adapter
|
||||
|
||||
fun box(): String {
|
||||
val adapter = Adapter()
|
||||
val d = D(adapter)
|
||||
return d.foo()
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// JVM_TARGET: 1.8
|
||||
// FILE: A.java
|
||||
|
||||
public interface A {
|
||||
default String foo() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
public interface B extends A {}
|
||||
|
||||
// FILE: C.java
|
||||
|
||||
public interface C extends A {}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
class Adapter : B, C
|
||||
|
||||
class D(val b: B, val c: C) : B by b, C by c
|
||||
|
||||
fun box(): String {
|
||||
val b = Adapter()
|
||||
val c = Adapter()
|
||||
val d = D(b, c)
|
||||
return d.foo()
|
||||
}
|
||||
Vendored
-19
@@ -1,19 +0,0 @@
|
||||
// FILE: A.java
|
||||
|
||||
public interface A {
|
||||
default void foo() {}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
public interface B extends A
|
||||
|
||||
// FILE: C.java
|
||||
|
||||
public interface C extends A
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
class Adapter : B, C
|
||||
|
||||
<!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class D<!>(val adapter: Adapter) : B by adapter, C by adapter
|
||||
+11
-2
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: A.java
|
||||
|
||||
public interface A {
|
||||
@@ -6,14 +7,22 @@ public interface A {
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
public interface B extends A
|
||||
public interface B extends A {}
|
||||
|
||||
// FILE: C.java
|
||||
|
||||
public interface C extends A
|
||||
public interface C extends A {}
|
||||
|
||||
// FILE: CK.kt
|
||||
|
||||
interface CK : A
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
class Adapter : B, C
|
||||
|
||||
class D(val adapter: Adapter) : B by adapter, C by adapter
|
||||
class E(val b: B, val c: C) : B by b, C by c
|
||||
|
||||
class AdapterK : B, CK
|
||||
class F(val adapter: AdapterK) : B by adapter, CK by adapter
|
||||
|
||||
Vendored
+8
@@ -5,6 +5,10 @@ interface A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
// FILE: BJ.java
|
||||
|
||||
public interface BJ extends A {}
|
||||
|
||||
// FILE: B.kt
|
||||
|
||||
interface B : A
|
||||
@@ -18,3 +22,7 @@ interface C : A
|
||||
class Adapter : B, C
|
||||
|
||||
<!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class D<!>(val adapter: Adapter) : B by adapter, C by adapter
|
||||
|
||||
class AdapterJ : BJ, C
|
||||
|
||||
<!MANY_IMPL_MEMBER_NOT_IMPLEMENTED!>class DJ<!>(val adapter: AdapterJ) : BJ by adapter, C by adapter
|
||||
|
||||
+12
@@ -18445,6 +18445,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/fir/LookupTags.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyImplFromOneJavaInterfaceWithDelegation.kt")
|
||||
public void testManyImplFromOneJavaInterfaceWithDelegation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/manyImplFromOneJavaInterfaceWithDelegation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyImplFromOneJavaInterfaceWithDelegation2.kt")
|
||||
public void testManyImplFromOneJavaInterfaceWithDelegation2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/manyImplFromOneJavaInterfaceWithDelegation2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NameHighlighter.kt")
|
||||
public void testNameHighlighter() throws Exception {
|
||||
|
||||
+6
@@ -18451,6 +18451,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
|
||||
runTest("compiler/testData/codegen/box/fir/manyImplFromOneJavaInterfaceWithDelegation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("manyImplFromOneJavaInterfaceWithDelegation2.kt")
|
||||
public void testManyImplFromOneJavaInterfaceWithDelegation2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/fir/manyImplFromOneJavaInterfaceWithDelegation2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NameHighlighter.kt")
|
||||
public void testNameHighlighter() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user