JVM_IR more precise check for special bridges in super class

KT-41123
This commit is contained in:
Dmitry Petrov
2020-10-01 17:54:07 +03:00
parent cf5bd38bec
commit e018f2bd3e
19 changed files with 156 additions and 118 deletions
+11
View File
@@ -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"]!!
}
@@ -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\)
+2 -2
View File
@@ -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;