FIR2IR: correct IR origin for substitution overrides

#KT-44054 Fixed
This commit is contained in:
Jinseong Jeon
2020-12-23 00:47:54 -08:00
committed by Mikhail Glukhikh
parent 34dbbdce07
commit aaa3f2e2c1
10 changed files with 69 additions and 1 deletions
@@ -1155,7 +1155,7 @@ class Fir2IrDeclarationStorage(
parentOrigin: IrDeclarationOrigin,
irParent: IrDeclarationParent?
): IrDeclarationOrigin {
return if (irParent.isSourceClass() && symbol.fir.isIntersectionOverride)
return if (irParent.isSourceClass() && (symbol.fir.isIntersectionOverride || symbol.fir.isSubstitutionOverride))
IrDeclarationOrigin.FAKE_OVERRIDE
else
parentOrigin
@@ -19869,6 +19869,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/objects/simpleObject.kt");
}
@TestMetadata("substitutionFunctionFromSuper.kt")
public void testSubstitutionFunctionFromSuper() throws Exception {
runTest("compiler/testData/codegen/box/objects/substitutionFunctionFromSuper.kt");
}
@TestMetadata("thisInConstructor.kt")
public void testThisInConstructor() throws Exception {
runTest("compiler/testData/codegen/box/objects/thisInConstructor.kt");
@@ -0,0 +1,28 @@
// KT-44054
enum class Enum {
Entry1,
Entry2
}
class Outer {
fun fooCaller(): Enum = obj.foo()
private abstract inner class Inner<T>(val default: T) {
fun foo(): T {
return default
}
}
private val obj = object : Inner<Enum>(Enum.Entry1) {
fun bar(): Enum {
return default
}
}
}
fun box(): String {
val o = Outer()
if (o.fooCaller() != Enum.Entry1) return "Fail"
return "OK"
}
@@ -19869,6 +19869,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/objects/simpleObject.kt");
}
@TestMetadata("substitutionFunctionFromSuper.kt")
public void testSubstitutionFunctionFromSuper() throws Exception {
runTest("compiler/testData/codegen/box/objects/substitutionFunctionFromSuper.kt");
}
@TestMetadata("thisInConstructor.kt")
public void testThisInConstructor() throws Exception {
runTest("compiler/testData/codegen/box/objects/thisInConstructor.kt");
@@ -19869,6 +19869,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/objects/simpleObject.kt");
}
@TestMetadata("substitutionFunctionFromSuper.kt")
public void testSubstitutionFunctionFromSuper() throws Exception {
runTest("compiler/testData/codegen/box/objects/substitutionFunctionFromSuper.kt");
}
@TestMetadata("thisInConstructor.kt")
public void testThisInConstructor() throws Exception {
runTest("compiler/testData/codegen/box/objects/thisInConstructor.kt");
@@ -19869,6 +19869,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/objects/simpleObject.kt");
}
@TestMetadata("substitutionFunctionFromSuper.kt")
public void testSubstitutionFunctionFromSuper() throws Exception {
runTest("compiler/testData/codegen/box/objects/substitutionFunctionFromSuper.kt");
}
@TestMetadata("thisInConstructor.kt")
public void testThisInConstructor() throws Exception {
runTest("compiler/testData/codegen/box/objects/thisInConstructor.kt");
@@ -15924,6 +15924,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/objects/simpleObject.kt");
}
@TestMetadata("substitutionFunctionFromSuper.kt")
public void testSubstitutionFunctionFromSuper() throws Exception {
runTest("compiler/testData/codegen/box/objects/substitutionFunctionFromSuper.kt");
}
@TestMetadata("thisInConstructor.kt")
public void testThisInConstructor() throws Exception {
runTest("compiler/testData/codegen/box/objects/thisInConstructor.kt");
@@ -15924,6 +15924,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/objects/simpleObject.kt");
}
@TestMetadata("substitutionFunctionFromSuper.kt")
public void testSubstitutionFunctionFromSuper() throws Exception {
runTest("compiler/testData/codegen/box/objects/substitutionFunctionFromSuper.kt");
}
@TestMetadata("thisInConstructor.kt")
public void testThisInConstructor() throws Exception {
runTest("compiler/testData/codegen/box/objects/thisInConstructor.kt");
@@ -15989,6 +15989,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/objects/simpleObject.kt");
}
@TestMetadata("substitutionFunctionFromSuper.kt")
public void testSubstitutionFunctionFromSuper() throws Exception {
runTest("compiler/testData/codegen/box/objects/substitutionFunctionFromSuper.kt");
}
@TestMetadata("thisInConstructor.kt")
public void testThisInConstructor() throws Exception {
runTest("compiler/testData/codegen/box/objects/thisInConstructor.kt");
@@ -9965,6 +9965,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/objects/simpleObject.kt");
}
@TestMetadata("substitutionFunctionFromSuper.kt")
public void testSubstitutionFunctionFromSuper() throws Exception {
runTest("compiler/testData/codegen/box/objects/substitutionFunctionFromSuper.kt");
}
@TestMetadata("thisInConstructor.kt")
public void testThisInConstructor() throws Exception {
runTest("compiler/testData/codegen/box/objects/thisInConstructor.kt");