JVM_IR more precise check for special bridges in super class
KT-41123
This commit is contained in:
Generated
+5
@@ -5013,6 +5013,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/collections/irrelevantSizeOverrideInJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt41123.kt")
|
||||
public void testKt41123() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/kt41123.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutableList.kt")
|
||||
public void testMutableList() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/mutableList.kt");
|
||||
|
||||
+3
@@ -353,6 +353,9 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
|
||||
return null
|
||||
}
|
||||
|
||||
internal fun mapCalleeToAsmMethod(function: IrSimpleFunction, isSuperCall: Boolean = false): Method =
|
||||
mapAsmMethod(findSuperDeclaration(function, isSuperCall))
|
||||
|
||||
// Copied from KotlinTypeMapper.findSuperDeclaration.
|
||||
private fun findSuperDeclaration(function: IrSimpleFunction, isSuperCall: Boolean): IrSimpleFunction {
|
||||
var current = function
|
||||
|
||||
+7
-5
@@ -357,11 +357,13 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass
|
||||
}
|
||||
|
||||
// List of special bridge methods which were not implemented in Kotlin superclasses.
|
||||
private fun IrSimpleFunction.overriddenSpecialBridges(): List<SpecialBridge> = allOverridden().mapNotNull {
|
||||
if (it.parentAsClass.isInterface || it.comesFromJava())
|
||||
it.specialBridgeOrNull?.takeIf { bridge -> bridge.signature != jvmMethod }
|
||||
?.copy(isFinal = false, isSynthetic = true, methodInfo = null)
|
||||
else null
|
||||
private fun IrSimpleFunction.overriddenSpecialBridges(): List<SpecialBridge> {
|
||||
val targetJvmMethod = context.methodSignatureMapper.mapCalleeToAsmMethod(this)
|
||||
return allOverridden()
|
||||
.filter { it.parentAsClass.isInterface || it.comesFromJava() }
|
||||
.mapNotNull { it.specialBridgeOrNull }
|
||||
.filter { it.signature != targetJvmMethod }
|
||||
.map { it.copy(isFinal = false, isSynthetic = true, methodInfo = null) }
|
||||
}
|
||||
|
||||
private fun IrClass.addAbstractMethodStub(irFunction: IrSimpleFunction, needsArgumentBoxing: Boolean) =
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
open class A : HashMap<String, String>()
|
||||
|
||||
fun box(): String {
|
||||
val a = object : A() {}
|
||||
a["OK"] = "OK"
|
||||
return a["OK"]!!
|
||||
}
|
||||
-105
@@ -1,105 +0,0 @@
|
||||
@kotlin.Metadata
|
||||
public abstract class AJALA {
|
||||
// source: 'abstractListsWithJavaBase.kt'
|
||||
public method <init>(): void
|
||||
public abstract method getSize(): int
|
||||
public bridge final method remove(p0: int): java.lang.Object
|
||||
public bridge method removeAt(p0: int): java.lang.Object
|
||||
public bridge final method size(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public abstract class AJALAN {
|
||||
// source: 'abstractListsWithJavaBase.kt'
|
||||
public method <init>(): void
|
||||
public abstract method getSize(): int
|
||||
public bridge final method remove(p0: int): java.lang.Object
|
||||
public bridge method removeAt(p0: int): java.lang.Object
|
||||
public bridge final method size(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public abstract class AJALI {
|
||||
// source: 'abstractListsWithJavaBase.kt'
|
||||
public method <init>(): void
|
||||
public bridge method contains(p0: java.lang.Integer): boolean
|
||||
public bridge final method contains(p0: java.lang.Object): boolean
|
||||
public abstract method getSize(): int
|
||||
public bridge method indexOf(p0: java.lang.Integer): int
|
||||
public bridge final method indexOf(p0: java.lang.Object): int
|
||||
public bridge method lastIndexOf(p0: java.lang.Integer): int
|
||||
public bridge final method lastIndexOf(p0: java.lang.Object): int
|
||||
public bridge final method remove(p0: int): java.lang.Integer
|
||||
public synthetic bridge method remove(p0: int): java.lang.Object
|
||||
public bridge method remove(p0: java.lang.Integer): boolean
|
||||
public bridge final method remove(p0: java.lang.Object): boolean
|
||||
public bridge method removeAt(p0: int): java.lang.Integer
|
||||
public bridge final method size(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public abstract class AJALIN {
|
||||
// source: 'abstractListsWithJavaBase.kt'
|
||||
public method <init>(): void
|
||||
public bridge method contains(p0: java.lang.Integer): boolean
|
||||
public bridge final method contains(p0: java.lang.Object): boolean
|
||||
public abstract method getSize(): int
|
||||
public bridge method indexOf(p0: java.lang.Integer): int
|
||||
public bridge final method indexOf(p0: java.lang.Object): int
|
||||
public bridge method lastIndexOf(p0: java.lang.Integer): int
|
||||
public bridge final method lastIndexOf(p0: java.lang.Object): int
|
||||
public bridge final method remove(p0: int): java.lang.Integer
|
||||
public synthetic bridge method remove(p0: int): java.lang.Object
|
||||
public bridge method remove(p0: java.lang.Integer): boolean
|
||||
public bridge final method remove(p0: java.lang.Object): boolean
|
||||
public bridge method removeAt(p0: int): java.lang.Integer
|
||||
public bridge final method size(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public abstract class AJALS {
|
||||
// source: 'abstractListsWithJavaBase.kt'
|
||||
public method <init>(): void
|
||||
public bridge final method contains(p0: java.lang.Object): boolean
|
||||
public bridge method contains(p0: java.lang.String): boolean
|
||||
public abstract method getSize(): int
|
||||
public bridge final method indexOf(p0: java.lang.Object): int
|
||||
public bridge method indexOf(p0: java.lang.String): int
|
||||
public bridge final method lastIndexOf(p0: java.lang.Object): int
|
||||
public bridge method lastIndexOf(p0: java.lang.String): int
|
||||
public synthetic bridge method remove(p0: int): java.lang.Object
|
||||
public bridge final method remove(p0: int): java.lang.String
|
||||
public bridge final method remove(p0: java.lang.Object): boolean
|
||||
public bridge method remove(p0: java.lang.String): boolean
|
||||
public bridge method removeAt(p0: int): java.lang.String
|
||||
public bridge final method size(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public abstract class AJALSN {
|
||||
// source: 'abstractListsWithJavaBase.kt'
|
||||
public method <init>(): void
|
||||
public bridge final method contains(p0: java.lang.Object): boolean
|
||||
public bridge method contains(p0: java.lang.String): boolean
|
||||
public abstract method getSize(): int
|
||||
public bridge final method indexOf(p0: java.lang.Object): int
|
||||
public bridge method indexOf(p0: java.lang.String): int
|
||||
public bridge final method lastIndexOf(p0: java.lang.Object): int
|
||||
public bridge method lastIndexOf(p0: java.lang.String): int
|
||||
public synthetic bridge method remove(p0: int): java.lang.Object
|
||||
public bridge final method remove(p0: int): java.lang.String
|
||||
public bridge final method remove(p0: java.lang.Object): boolean
|
||||
public bridge method remove(p0: java.lang.String): boolean
|
||||
public bridge method removeAt(p0: int): java.lang.String
|
||||
public bridge final method size(): int
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public abstract class AJALT {
|
||||
// source: 'abstractListsWithJavaBase.kt'
|
||||
public method <init>(): void
|
||||
public abstract method getSize(): int
|
||||
public bridge final method remove(p0: int): java.lang.Object
|
||||
public bridge method removeAt(p0: int): java.lang.Object
|
||||
public bridge final method size(): int
|
||||
}
|
||||
@@ -58,7 +58,6 @@ public abstract class A5 {
|
||||
public bridge method indexOf(p0: java.lang.String): int
|
||||
public bridge final method lastIndexOf(p0: java.lang.Object): int
|
||||
public bridge method lastIndexOf(p0: java.lang.String): int
|
||||
public synthetic bridge method remove(p0: int): java.lang.Object
|
||||
public bridge final method remove(p0: int): java.lang.String
|
||||
public bridge final method remove(p0: java.lang.Object): boolean
|
||||
public bridge method remove(p0: java.lang.String): boolean
|
||||
@@ -78,7 +77,6 @@ public abstract class A6 {
|
||||
public bridge method indexOf(p0: java.lang.String): int
|
||||
public bridge final method lastIndexOf(p0: java.lang.Object): int
|
||||
public bridge method lastIndexOf(p0: java.lang.String): int
|
||||
public synthetic bridge method remove(p0: int): java.lang.Object
|
||||
public bridge final method remove(p0: int): java.lang.String
|
||||
public bridge final method remove(p0: java.lang.Object): boolean
|
||||
public bridge method remove(p0: java.lang.String): boolean
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
// TODO KT-42391
|
||||
// JVM:
|
||||
// public bridge final method get(p0: java.lang.Object): java.lang.Object
|
||||
// public bridge final method remove(p0: java.lang.Object): java.lang.Object
|
||||
// JVM_IR:
|
||||
// public bridge final method get(p0: java.lang.Object): java.lang.String
|
||||
// public bridge final method remove(p0: java.lang.Object): java.lang.String
|
||||
|
||||
open class A : HashMap<String, String>()
|
||||
|
||||
class B : A()
|
||||
@@ -0,0 +1,27 @@
|
||||
@kotlin.Metadata
|
||||
public class A {
|
||||
// source: 'kt41123.kt'
|
||||
public method <init>(): void
|
||||
public bridge final method containsKey(p0: java.lang.Object): boolean
|
||||
public bridge method containsKey(p0: java.lang.String): boolean
|
||||
public bridge final method containsValue(p0: java.lang.Object): boolean
|
||||
public bridge method containsValue(p0: java.lang.String): boolean
|
||||
public bridge final method entrySet(): java.util.Set
|
||||
public bridge final method get(p0: java.lang.Object): java.lang.Object
|
||||
public bridge method get(p0: java.lang.String): java.lang.String
|
||||
public bridge method getEntries(): java.util.Set
|
||||
public bridge method getKeys(): java.util.Set
|
||||
public bridge method getSize(): int
|
||||
public bridge method getValues(): java.util.Collection
|
||||
public bridge final method keySet(): java.util.Set
|
||||
public bridge final method remove(p0: java.lang.Object): java.lang.Object
|
||||
public bridge method remove(p0: java.lang.String): java.lang.String
|
||||
public bridge final method size(): int
|
||||
public bridge final method values(): java.util.Collection
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class B {
|
||||
// source: 'kt41123.kt'
|
||||
public method <init>(): void
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
@kotlin.Metadata
|
||||
public class A {
|
||||
// source: 'kt41123.kt'
|
||||
public method <init>(): void
|
||||
public bridge final method containsKey(p0: java.lang.Object): boolean
|
||||
public bridge method containsKey(p0: java.lang.String): boolean
|
||||
public bridge final method containsValue(p0: java.lang.Object): boolean
|
||||
public bridge method containsValue(p0: java.lang.String): boolean
|
||||
public bridge final method entrySet(): java.util.Set
|
||||
public bridge final method get(p0: java.lang.Object): java.lang.String
|
||||
public bridge method get(p0: java.lang.String): java.lang.String
|
||||
public bridge method getEntries(): java.util.Set
|
||||
public bridge method getKeys(): java.util.Set
|
||||
public bridge method getSize(): int
|
||||
public bridge method getValues(): java.util.Collection
|
||||
public bridge final method keySet(): java.util.Set
|
||||
public bridge final method remove(p0: java.lang.Object): java.lang.String
|
||||
public bridge method remove(p0: java.lang.String): java.lang.String
|
||||
public bridge final method size(): int
|
||||
public bridge final method values(): java.util.Collection
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class B {
|
||||
// source: 'kt41123.kt'
|
||||
public method <init>(): void
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
abstract class A1<T> : MutableList<T> {
|
||||
override fun remove(x: T): Boolean = true
|
||||
override fun removeAt(index: Int): T = null!!
|
||||
@@ -99,8 +101,8 @@ On the JVM backend we have:
|
||||
1 INVOKEVIRTUAL A10\.remove \(I\) -> one call in 'box' function
|
||||
|
||||
On the JVM IR backend we have:
|
||||
9 INVOKEVIRTUAL A[0-9]+.removeAt \(I\) -> calls in non-synthetic bridges with signature `public final bridge remove(I)`
|
||||
17 INVOKEVIRTUAL A[0-9]+\.remove \(I\) -> calls to A1-A9.removeAt + calls in synthetic bridges with signature `public synthetic bridge remove(I)Ljava/lang/Object;`
|
||||
10 INVOKEVIRTUAL A[0-9]+.removeAt \(I\) -> calls in bridges with signature `public final bridge remove(I)`
|
||||
15 INVOKEVIRTUAL A[0-9]+\.remove \(I\) -> calls to A1-A9.removeAt + calls in synthetic bridges with signature `public synthetic bridge remove(I)Ljava/lang/Object;`
|
||||
2 INVOKEVIRTUAL A10\.remove \(I\) -> one call in 'box' function + call from synthetic `remove(I)` bridge
|
||||
|
||||
This currently differs because of KT-40277, and the test expectations should be revised once KT-40277 is resolved.
|
||||
@@ -117,6 +119,21 @@ This currently differs because of KT-40277, and the test expectations should be
|
||||
// 1 INVOKEVIRTUAL A10\.remove \(I\)
|
||||
|
||||
// JVM_IR_TEMPLATES:
|
||||
// 9 INVOKEVIRTUAL A[0-9]+.removeAt \(I\)
|
||||
// 17 INVOKEVIRTUAL A[0-9]+\.remove \(I\)
|
||||
// 1 INVOKEVIRTUAL A1\.removeAt \(I\)
|
||||
// 1 INVOKEVIRTUAL A2\.removeAt \(I\)
|
||||
// 1 INVOKEVIRTUAL A3\.removeAt \(I\)
|
||||
// 1 INVOKEVIRTUAL A4\.removeAt \(I\)
|
||||
// 1 INVOKEVIRTUAL A5\.removeAt \(I\)
|
||||
// 1 INVOKEVIRTUAL A6\.removeAt \(I\)
|
||||
// 1 INVOKEVIRTUAL A8\.removeAt \(I\)
|
||||
// 1 INVOKEVIRTUAL A10\.removeAt \(I\)
|
||||
|
||||
// 2 INVOKEVIRTUAL A7\.removeAt \(I\)
|
||||
// ^ in:
|
||||
// public final bridge remove(I)Ljava/lang/String;
|
||||
// public synthetic bridge remove(I)Ljava/lang/Object;
|
||||
|
||||
// 10 INVOKEVIRTUAL A[0-9]+\.removeAt \(I\)
|
||||
|
||||
// 15 INVOKEVIRTUAL A[0-9]+\.remove \(I\)
|
||||
// 2 INVOKEVIRTUAL A10\.remove \(I\)
|
||||
|
||||
@@ -37,5 +37,5 @@ class MyMap: TestMap<String, String>()
|
||||
// 1 public final bridge getOrDefault\(Ljava/lang/Object;Ljava/lang/Object;\)Ljava/lang/Object;
|
||||
|
||||
// JVM_IR_TEMPLATES:
|
||||
// 1 public final bridge getOrDefault\(Ljava/lang/Object;Ljava/lang/String;\)Ljava/lang/String;
|
||||
// 1 public synthetic bridge getOrDefault\(Ljava/lang/Object;Ljava/lang/Object;\)Ljava/lang/Object;
|
||||
// 1 public bridge getOrDefault\(Ljava/lang/String;Ljava/lang/String;\)Ljava/lang/String;
|
||||
// 1 public final bridge getOrDefault\(Ljava/lang/Object;Ljava/lang/String;\)Ljava/lang/String;
|
||||
+5
@@ -5043,6 +5043,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/collections/irrelevantSizeOverrideInJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt41123.kt")
|
||||
public void testKt41123() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/kt41123.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutableList.kt")
|
||||
public void testMutableList() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/mutableList.kt");
|
||||
|
||||
+5
@@ -948,6 +948,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/specialBridges/contains.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt41123.kt")
|
||||
public void testKt41123() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/specialBridges/kt41123.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noDefaultImplsOnEmptySubInterface.kt")
|
||||
public void testNoDefaultImplsOnEmptySubInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/specialBridges/noDefaultImplsOnEmptySubInterface.kt");
|
||||
|
||||
+5
@@ -5043,6 +5043,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/collections/irrelevantSizeOverrideInJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt41123.kt")
|
||||
public void testKt41123() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/kt41123.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutableList.kt")
|
||||
public void testMutableList() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/mutableList.kt");
|
||||
|
||||
+5
@@ -5013,6 +5013,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/collections/irrelevantSizeOverrideInJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt41123.kt")
|
||||
public void testKt41123() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/kt41123.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mutableList.kt")
|
||||
public void testMutableList() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/mutableList.kt");
|
||||
|
||||
+5
@@ -918,6 +918,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
|
||||
runTest("compiler/testData/codegen/bytecodeListing/specialBridges/contains.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt41123.kt")
|
||||
public void testKt41123() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/specialBridges/kt41123.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noDefaultImplsOnEmptySubInterface.kt")
|
||||
public void testNoDefaultImplsOnEmptySubInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/specialBridges/noDefaultImplsOnEmptySubInterface.kt");
|
||||
|
||||
Generated
+5
@@ -4088,6 +4088,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/collections/inSetWithSmartCast.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt41123.kt")
|
||||
public void testKt41123() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/kt41123.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("removeClash.kt")
|
||||
public void testRemoveClash() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/removeClash.kt");
|
||||
|
||||
Generated
+5
@@ -4088,6 +4088,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/collections/inSetWithSmartCast.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt41123.kt")
|
||||
public void testKt41123() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/kt41123.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("removeClash.kt")
|
||||
public void testRemoveClash() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/removeClash.kt");
|
||||
|
||||
+5
@@ -4088,6 +4088,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/collections/inSetWithSmartCast.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt41123.kt")
|
||||
public void testKt41123() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/kt41123.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("removeClash.kt")
|
||||
public void testRemoveClash() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/collections/removeClash.kt");
|
||||
|
||||
Reference in New Issue
Block a user