[FIR] Update return type of delegated callables in ReturnTypeCalculator

^KT-54654 Fixed
This commit is contained in:
Dmitriy Novozhilov
2022-10-24 18:10:51 +03:00
committed by Space Team
parent f441151eab
commit 027b1f861c
4 changed files with 39 additions and 1 deletions
@@ -15575,6 +15575,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
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
@TestMetadata("kt8154.kt")
public void testKt8154() throws Exception {
@@ -239,7 +239,11 @@ private class ReturnTypeCalculatorWithJump(
val unwrappedDelegate = declaration.delegatedWrapperData?.wrapped
if (unwrappedDelegate != null) {
return tryCalculateReturnType(unwrappedDelegate)
return tryCalculateReturnType(unwrappedDelegate).also {
if (declaration.returnTypeRef is FirImplicitTypeRef) {
declaration.replaceReturnTypeRef(it)
}
}
}
if (declaration.isSubstitutionOrIntersectionOverride) {
+22
View File
@@ -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)
}
@@ -15575,6 +15575,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
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
@TestMetadata("kt8154.kt")
public void testKt8154() throws Exception {