[FIR] Update return type of delegated callables in ReturnTypeCalculator
^KT-54654 Fixed
This commit is contained in:
committed by
Space Team
parent
f441151eab
commit
027b1f861c
+6
@@ -15575,6 +15575,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/delegation/kt30102_comparable.kt");
|
runTest("compiler/testData/codegen/box/delegation/kt30102_comparable.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt54654.kt")
|
||||||
|
public void testKt54654() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/delegation/kt54654.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt8154.kt")
|
@TestMetadata("kt8154.kt")
|
||||||
public void testKt8154() throws Exception {
|
public void testKt8154() throws Exception {
|
||||||
|
|||||||
+5
-1
@@ -239,7 +239,11 @@ private class ReturnTypeCalculatorWithJump(
|
|||||||
|
|
||||||
val unwrappedDelegate = declaration.delegatedWrapperData?.wrapped
|
val unwrappedDelegate = declaration.delegatedWrapperData?.wrapped
|
||||||
if (unwrappedDelegate != null) {
|
if (unwrappedDelegate != null) {
|
||||||
return tryCalculateReturnType(unwrappedDelegate)
|
return tryCalculateReturnType(unwrappedDelegate).also {
|
||||||
|
if (declaration.returnTypeRef is FirImplicitTypeRef) {
|
||||||
|
declaration.replaceReturnTypeRef(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (declaration.isSubstitutionOrIntersectionOverride) {
|
if (declaration.isSubstitutionOrIntersectionOverride) {
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// ISSUE: KT-54654
|
||||||
|
|
||||||
|
fun accessProperty(b: B) = b.property
|
||||||
|
fun accessFunction(b: B) = b.function()
|
||||||
|
|
||||||
|
fun getString_1(): String = "O"
|
||||||
|
fun getString_2(): String = "K"
|
||||||
|
|
||||||
|
interface A {
|
||||||
|
val property get() = getString_1()
|
||||||
|
fun function() = getString_2()
|
||||||
|
}
|
||||||
|
|
||||||
|
class B(val a: A) : A by a
|
||||||
|
|
||||||
|
class C : A
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val b = B(C())
|
||||||
|
return accessProperty(b) + accessFunction(b)
|
||||||
|
}
|
||||||
+6
@@ -15575,6 +15575,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/delegation/kt30102_comparable.kt");
|
runTest("compiler/testData/codegen/box/delegation/kt30102_comparable.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt54654.kt")
|
||||||
|
public void testKt54654() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/delegation/kt54654.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt8154.kt")
|
@TestMetadata("kt8154.kt")
|
||||||
public void testKt8154() throws Exception {
|
public void testKt8154() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user