Ignore type parameters of inline class
when checking whether we can return unboxed inline class from suspend function
This commit is contained in:
+2
-1
@@ -475,7 +475,8 @@ fun FunctionDescriptor.originalReturnTypeOfSuspendFunctionReturningUnboxedInline
|
||||
// Force boxing if the function overrides function with different type modulo nullability
|
||||
if (originalDescriptor.overriddenDescriptors.any {
|
||||
(it.original.returnType?.isMarkedNullable == true && it.original.returnType?.isNullableUnderlyingType() == true) ||
|
||||
it.original.returnType?.makeNotNullable() != originalReturnType.makeNotNullable()
|
||||
// We do not care about type parameters, just main class type
|
||||
it.original.returnType?.constructor?.declarationDescriptor != originalReturnType.constructor.declarationDescriptor
|
||||
}) return null
|
||||
// Don't box other inline classes
|
||||
return originalReturnType
|
||||
|
||||
Generated
+5
@@ -8749,6 +8749,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/interfaceDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnInlineClass.kt")
|
||||
public void testReturnInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/returnInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/simple.kt");
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// FULL_JDK
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// CHECK_TAIL_CALL_OPTIMIZATION
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
|
||||
public inline class ValueOrClosed<out T>(val holder: Any?)
|
||||
|
||||
public interface Channel<out E> {
|
||||
public suspend fun receiveOrClosed(): ValueOrClosed<E>
|
||||
}
|
||||
|
||||
class AbstractChannel<E> : Channel<E> {
|
||||
private suspend fun <R> receiveSuspend(): R {
|
||||
TailCallOptimizationChecker.saveStackTrace()
|
||||
return ValueOrClosed<String>("OK") as R
|
||||
}
|
||||
|
||||
public final override suspend fun receiveOrClosed(): ValueOrClosed<E> {
|
||||
return receiveSuspend()
|
||||
}
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = "FAIL"
|
||||
builder {
|
||||
val channel: Channel<String> = AbstractChannel<String>()
|
||||
res = channel.receiveOrClosed().holder as String
|
||||
}
|
||||
TailCallOptimizationChecker.checkStateMachineIn("receiveOrClosed-v5DwqjU")
|
||||
return res
|
||||
}
|
||||
+5
@@ -10079,6 +10079,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/interfaceDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnInlineClass.kt")
|
||||
public void testReturnInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/returnInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/simple.kt");
|
||||
|
||||
+5
@@ -10079,6 +10079,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/interfaceDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnInlineClass.kt")
|
||||
public void testReturnInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/returnInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/simple.kt");
|
||||
|
||||
+5
@@ -8749,6 +8749,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/interfaceDelegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("returnInlineClass.kt")
|
||||
public void testReturnInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/returnInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/tailCallOptimizations/simple.kt");
|
||||
|
||||
-15
@@ -21414,11 +21414,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/ranges/unsigned/expression/emptyRange.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inexactDownToMinValue.kt")
|
||||
public void testInexactDownToMinValue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/unsigned/expression/inexactDownToMinValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inexactSteppedDownTo.kt")
|
||||
public void testInexactSteppedDownTo() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/unsigned/expression/inexactSteppedDownTo.kt");
|
||||
@@ -21464,21 +21459,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/ranges/unsigned/expression/openRange.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overflowZeroDownToMaxValue.kt")
|
||||
public void testOverflowZeroDownToMaxValue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/unsigned/expression/overflowZeroDownToMaxValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overflowZeroToMinValue.kt")
|
||||
public void testOverflowZeroToMinValue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/unsigned/expression/overflowZeroToMinValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("progressionDownToMinValue.kt")
|
||||
public void testProgressionDownToMinValue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/unsigned/expression/progressionDownToMinValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("progressionMaxValueMinusTwoToMaxValue.kt")
|
||||
public void testProgressionMaxValueMinusTwoToMaxValue() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/unsigned/expression/progressionMaxValueMinusTwoToMaxValue.kt");
|
||||
|
||||
Reference in New Issue
Block a user