[JS IR] Fix case with bridge with nested classes
^KT-54686 fixed
This commit is contained in:
committed by
Space Team
parent
2e48557a0d
commit
fd5fba6f09
+6
@@ -2363,6 +2363,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameters.kt")
|
||||||
|
public void testNestedClassTypeParameters() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/bridges/nestedClassTypeParameters.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
||||||
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
||||||
|
|||||||
@@ -415,10 +415,4 @@ class JsIrBackendContext(
|
|||||||
outlinedJsCodeFunctions[symbol] = parsedJsFunction
|
outlinedJsCodeFunctions[symbol] = parsedJsFunction
|
||||||
return parsedJsFunction
|
return parsedJsFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
private var irFunctionSignatureCache = hashMapOf<IrFunction, String>()
|
|
||||||
|
|
||||||
fun getFunctionSignatureFromCache(f: IrFunction): String {
|
|
||||||
return irFunctionSignatureCache.getOrPut(f) { calculateJsFunctionSignature(f, this) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -34,7 +34,10 @@ class JsBridgesConstruction(context: JsIrBackendContext) : BridgesConstruction<J
|
|||||||
private val primitiveToLiteralConstructor = context.intrinsics.primitiveToLiteralConstructor
|
private val primitiveToLiteralConstructor = context.intrinsics.primitiveToLiteralConstructor
|
||||||
|
|
||||||
override fun getFunctionSignature(function: IrSimpleFunction) =
|
override fun getFunctionSignature(function: IrSimpleFunction) =
|
||||||
jsFunctionSignature(function, context)
|
jsFunctionSignature(
|
||||||
|
function,
|
||||||
|
context
|
||||||
|
)
|
||||||
|
|
||||||
override fun getBridgeOrigin(bridge: IrSimpleFunction): IrDeclarationOrigin =
|
override fun getBridgeOrigin(bridge: IrSimpleFunction): IrDeclarationOrigin =
|
||||||
when {
|
when {
|
||||||
|
|||||||
@@ -158,7 +158,10 @@ fun calculateJsFunctionSignature(declaration: IrFunction, context: JsIrBackendCo
|
|||||||
) + "_" + abs(signature.hashCode()).toString(Character.MAX_RADIX) + RESERVED_MEMBER_NAME_SUFFIX
|
) + "_" + abs(signature.hashCode()).toString(Character.MAX_RADIX) + RESERVED_MEMBER_NAME_SUFFIX
|
||||||
}
|
}
|
||||||
|
|
||||||
fun jsFunctionSignature(declaration: IrFunction, context: JsIrBackendContext): String {
|
fun jsFunctionSignature(
|
||||||
|
declaration: IrFunction,
|
||||||
|
context: JsIrBackendContext
|
||||||
|
): String {
|
||||||
require(!declaration.isStaticMethodOfClass)
|
require(!declaration.isStaticMethodOfClass)
|
||||||
require(declaration.dispatchReceiverParameter != null)
|
require(declaration.dispatchReceiverParameter != null)
|
||||||
|
|
||||||
@@ -172,7 +175,7 @@ fun jsFunctionSignature(declaration: IrFunction, context: JsIrBackendContext): S
|
|||||||
}
|
}
|
||||||
|
|
||||||
val declarationSignature = (declaration as? IrSimpleFunction)?.resolveFakeOverride() ?: declaration
|
val declarationSignature = (declaration as? IrSimpleFunction)?.resolveFakeOverride() ?: declaration
|
||||||
return context.getFunctionSignatureFromCache(declarationSignature)
|
return calculateJsFunctionSignature(declarationSignature, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
class NameTables(
|
class NameTables(
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
class Outer {
|
||||||
|
class Inner {
|
||||||
|
fun foo() = "K"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface I<T> {
|
||||||
|
fun foo(t: T, inner: Outer.Inner): String
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Child : I<String> {
|
||||||
|
override fun foo(t: String, inner: Outer.Inner): String {
|
||||||
|
return t + inner.foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val child: I<String> = Child()
|
||||||
|
return child.foo("O", Outer.Inner())
|
||||||
|
}
|
||||||
+6
@@ -2267,6 +2267,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameters.kt")
|
||||||
|
public void testNestedClassTypeParameters() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/bridges/nestedClassTypeParameters.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
||||||
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
||||||
|
|||||||
+6
@@ -2363,6 +2363,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameters.kt")
|
||||||
|
public void testNestedClassTypeParameters() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/bridges/nestedClassTypeParameters.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
||||||
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
||||||
|
|||||||
+5
@@ -1987,6 +1987,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nestedClassTypeParameters.kt")
|
||||||
|
public void testNestedClassTypeParameters() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/bridges/nestedClassTypeParameters.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
||||||
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/bridges/noBridgeOnMutableCollectionInheritance.kt");
|
runTest("compiler/testData/codegen/box/bridges/noBridgeOnMutableCollectionInheritance.kt");
|
||||||
|
|||||||
+6
@@ -1541,6 +1541,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameters.kt")
|
||||||
|
public void testNestedClassTypeParameters() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/bridges/nestedClassTypeParameters.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
||||||
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
||||||
|
|||||||
+6
@@ -1595,6 +1595,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameters.kt")
|
||||||
|
public void testNestedClassTypeParameters() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/bridges/nestedClassTypeParameters.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
||||||
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
||||||
|
|||||||
+5
@@ -1417,6 +1417,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nestedClassTypeParameters.kt")
|
||||||
|
public void testNestedClassTypeParameters() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/bridges/nestedClassTypeParameters.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
||||||
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/bridges/noBridgeOnMutableCollectionInheritance.kt");
|
runTest("compiler/testData/codegen/box/bridges/noBridgeOnMutableCollectionInheritance.kt");
|
||||||
|
|||||||
+6
@@ -1633,6 +1633,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
|||||||
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
runTest("compiler/testData/codegen/box/bridges/methodFromTrait.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassTypeParameters.kt")
|
||||||
|
public void testNestedClassTypeParameters() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/bridges/nestedClassTypeParameters.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
@TestMetadata("noBridgeOnMutableCollectionInheritance.kt")
|
||||||
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
public void testNoBridgeOnMutableCollectionInheritance() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user