[JS IR] Consider erasing type parameters in return type in js signatures

This commit is contained in:
Ilya Goncharov
2021-12-09 17:46:08 +03:00
committed by Space
parent 4f1a10d72e
commit 6adcbe081e
11 changed files with 67 additions and 2 deletions
@@ -2285,6 +2285,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/bridges/overrideReturnType.kt");
}
@Test
@TestMetadata("overrideWithValueClassReturn.kt")
public void testOverrideWithValueClassReturn() throws Exception {
runTest("compiler/testData/codegen/box/bridges/overrideWithValueClassReturn.kt");
}
@Test
@TestMetadata("propertyAccessorsWithoutBody.kt")
public void testPropertyAccessorsWithoutBody() throws Exception {
@@ -31,7 +31,7 @@ class JsBridgesConstruction(context: JsIrBackendContext) : BridgesConstruction<J
function.valueParameters.map { it.type.eraseGenerics(context.irBuiltIns) },
function.returnType.takeIf {
it.getJsInlinedClass() != null || it.isUnit()
}
}?.eraseGenerics(context.irBuiltIns)
)
}
@@ -132,7 +132,7 @@ fun jsFunctionSignature(declaration: IrFunction, context: JsIrBackendContext): S
// Return type is only used in signature for inline class and Unit types because
// they are binary incompatible with supertypes.
if (context.inlineClassesUtils.isTypeInlined(it) || it.isUnit()) {
nameBuilder.append("_ret$${it.asString()}")
nameBuilder.append("_ret$${it.eraseGenerics(context.irBuiltIns).asString()}")
}
}
@@ -0,0 +1,19 @@
// WITH_STDLIB
interface I<E> {
public fun foo(): VC<E>
}
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
@kotlin.jvm.JvmInline
public value class VC<out T>(val holder: String)
abstract class AC<E>(val vc: VC<E>) : I<E> {
override fun foo(): VC<E> {
return vc
}
}
fun box(): String {
return object : AC<String>(VC("OK")) {}.foo().holder
}
@@ -2207,6 +2207,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/bridges/overrideReturnType.kt");
}
@Test
@TestMetadata("overrideWithValueClassReturn.kt")
public void testOverrideWithValueClassReturn() throws Exception {
runTest("compiler/testData/codegen/box/bridges/overrideWithValueClassReturn.kt");
}
@Test
@TestMetadata("propertyAccessorsWithoutBody.kt")
public void testPropertyAccessorsWithoutBody() throws Exception {
@@ -2285,6 +2285,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/bridges/overrideReturnType.kt");
}
@Test
@TestMetadata("overrideWithValueClassReturn.kt")
public void testOverrideWithValueClassReturn() throws Exception {
runTest("compiler/testData/codegen/box/bridges/overrideWithValueClassReturn.kt");
}
@Test
@TestMetadata("propertyAccessorsWithoutBody.kt")
public void testPropertyAccessorsWithoutBody() throws Exception {
@@ -1937,6 +1937,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/bridges/overrideReturnType.kt");
}
@TestMetadata("overrideWithValueClassReturn.kt")
public void testOverrideWithValueClassReturn() throws Exception {
runTest("compiler/testData/codegen/box/bridges/overrideWithValueClassReturn.kt");
}
@TestMetadata("propertyAccessorsWithoutBody.kt")
public void testPropertyAccessorsWithoutBody() throws Exception {
runTest("compiler/testData/codegen/box/bridges/propertyAccessorsWithoutBody.kt");
@@ -1517,6 +1517,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/bridges/overrideReturnType.kt");
}
@Test
@TestMetadata("overrideWithValueClassReturn.kt")
public void testOverrideWithValueClassReturn() throws Exception {
runTest("compiler/testData/codegen/box/bridges/overrideWithValueClassReturn.kt");
}
@Test
@TestMetadata("propertyAccessorsWithoutBody.kt")
public void testPropertyAccessorsWithoutBody() throws Exception {
@@ -1559,6 +1559,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/bridges/overrideReturnType.kt");
}
@Test
@TestMetadata("overrideWithValueClassReturn.kt")
public void testOverrideWithValueClassReturn() throws Exception {
runTest("compiler/testData/codegen/box/bridges/overrideWithValueClassReturn.kt");
}
@Test
@TestMetadata("propertyAccessorsWithoutBody.kt")
public void testPropertyAccessorsWithoutBody() throws Exception {
@@ -1387,6 +1387,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/bridges/overrideReturnType.kt");
}
@TestMetadata("overrideWithValueClassReturn.kt")
public void testOverrideWithValueClassReturn() throws Exception {
runTest("compiler/testData/codegen/box/bridges/overrideWithValueClassReturn.kt");
}
@TestMetadata("propertyAccessorsWithoutBody.kt")
public void testPropertyAccessorsWithoutBody() throws Exception {
runTest("compiler/testData/codegen/box/bridges/propertyAccessorsWithoutBody.kt");
@@ -1577,6 +1577,12 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest {
runTest("compiler/testData/codegen/box/bridges/overrideReturnType.kt");
}
@Test
@TestMetadata("overrideWithValueClassReturn.kt")
public void testOverrideWithValueClassReturn() throws Exception {
runTest("compiler/testData/codegen/box/bridges/overrideWithValueClassReturn.kt");
}
@Test
@TestMetadata("propertyAccessorsWithoutBody.kt")
public void testPropertyAccessorsWithoutBody() throws Exception {