FIR2IR: Fix inheritance case from built-in interface with default methods
This commit is contained in:
@@ -447,6 +447,12 @@ class Fir2IrDeclarationStorage(
|
|||||||
isLambda -> IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA
|
isLambda -> IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA
|
||||||
function.symbol.callableId.isKFunctionInvoke() -> IrDeclarationOrigin.FAKE_OVERRIDE
|
function.symbol.callableId.isKFunctionInvoke() -> IrDeclarationOrigin.FAKE_OVERRIDE
|
||||||
simpleFunction?.isStatic == true && simpleFunction.name in ENUM_SYNTHETIC_NAMES -> IrDeclarationOrigin.ENUM_CLASS_SPECIAL_MEMBER
|
simpleFunction?.isStatic == true && simpleFunction.name in ENUM_SYNTHETIC_NAMES -> IrDeclarationOrigin.ENUM_CLASS_SPECIAL_MEMBER
|
||||||
|
|
||||||
|
// Kotlin built-in class and Java originated method (Collection.forEach, etc.)
|
||||||
|
// It's necessary to understand that such methods do not belong to DefaultImpls but actually generated as default
|
||||||
|
// See org.jetbrains.kotlin.backend.jvm.lower.InheritedDefaultMethodsOnClassesLoweringKt.isDefinitelyNotDefaultImplsMethod
|
||||||
|
(irParent as? IrClass)?.origin == IrDeclarationOrigin.IR_EXTERNAL_DECLARATION_STUB &&
|
||||||
|
function.origin == FirDeclarationOrigin.Enhancement -> IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB
|
||||||
else -> origin
|
else -> origin
|
||||||
}
|
}
|
||||||
classifierStorage.preCacheTypeParameters(function)
|
classifierStorage.preCacheTypeParameters(function)
|
||||||
|
|||||||
+6
@@ -22137,6 +22137,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/jvm8/defaults/bridgeWithJava.kt");
|
runTest("compiler/testData/codegen/box/jvm8/defaults/bridgeWithJava.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("builtInsInherited.kt")
|
||||||
|
public void testBuiltInsInherited() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvm8/defaults/builtInsInherited.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("callableReference.kt")
|
@TestMetadata("callableReference.kt")
|
||||||
public void testCallableReference() throws Exception {
|
public void testCallableReference() throws Exception {
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// JVM_TARGET: 1.8
|
||||||
|
// FULL_JDK
|
||||||
|
// WITH_RUNTIME
|
||||||
|
import java.util.function.Consumer
|
||||||
|
|
||||||
|
class A : Iterable<String> {
|
||||||
|
override fun iterator(): Iterator<String> = listOf("OK").iterator()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var res = ""
|
||||||
|
A().forEach(Consumer { res += it })
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
+6
@@ -22119,6 +22119,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/jvm8/defaults/bridgeWithJava.kt");
|
runTest("compiler/testData/codegen/box/jvm8/defaults/bridgeWithJava.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("builtInsInherited.kt")
|
||||||
|
public void testBuiltInsInherited() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvm8/defaults/builtInsInherited.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("callableReference.kt")
|
@TestMetadata("callableReference.kt")
|
||||||
public void testCallableReference() throws Exception {
|
public void testCallableReference() throws Exception {
|
||||||
|
|||||||
+6
@@ -22137,6 +22137,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/jvm8/defaults/bridgeWithJava.kt");
|
runTest("compiler/testData/codegen/box/jvm8/defaults/bridgeWithJava.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("builtInsInherited.kt")
|
||||||
|
public void testBuiltInsInherited() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvm8/defaults/builtInsInherited.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("callableReference.kt")
|
@TestMetadata("callableReference.kt")
|
||||||
public void testCallableReference() throws Exception {
|
public void testCallableReference() throws Exception {
|
||||||
|
|||||||
+5
@@ -18577,6 +18577,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/jvm8/defaults/bridgeWithJava.kt");
|
runTest("compiler/testData/codegen/box/jvm8/defaults/bridgeWithJava.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("builtInsInherited.kt")
|
||||||
|
public void testBuiltInsInherited() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvm8/defaults/builtInsInherited.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("callableReference.kt")
|
@TestMetadata("callableReference.kt")
|
||||||
public void testCallableReference() throws Exception {
|
public void testCallableReference() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/jvm8/defaults/callableReference.kt");
|
runTest("compiler/testData/codegen/box/jvm8/defaults/callableReference.kt");
|
||||||
|
|||||||
Generated
+6
@@ -22148,6 +22148,12 @@ public class VisualizerBlackBoxTestGenerated extends AbstractVisualizerBlackBoxT
|
|||||||
runTest("compiler/testData/codegen/box/jvm8/defaults/bridgeWithJava.kt");
|
runTest("compiler/testData/codegen/box/jvm8/defaults/bridgeWithJava.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("builtInsInherited.kt")
|
||||||
|
public void testBuiltInsInherited() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvm8/defaults/builtInsInherited.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("callableReference.kt")
|
@TestMetadata("callableReference.kt")
|
||||||
public void testCallableReference() throws Exception {
|
public void testCallableReference() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user