FIR2IR: Fix inheritance case from built-in interface with default methods

This commit is contained in:
Denis.Zharkov
2021-03-31 17:21:51 +03:00
parent e5ea7f5b4e
commit d685e2aac7
7 changed files with 51 additions and 0 deletions
@@ -447,6 +447,12 @@ class Fir2IrDeclarationStorage(
isLambda -> IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA
function.symbol.callableId.isKFunctionInvoke() -> IrDeclarationOrigin.FAKE_OVERRIDE
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
}
classifierStorage.preCacheTypeParameters(function)
@@ -22137,6 +22137,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
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
@TestMetadata("callableReference.kt")
public void testCallableReference() throws Exception {