JVM_IR fix special bridge generation for inline classes
This commit is contained in:
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int)
|
||||
|
||||
inline class ZArray(val storage: IntArray) : Collection<Z> {
|
||||
override val size: Int
|
||||
get() = storage.size
|
||||
|
||||
override fun contains(element: Z): Boolean {
|
||||
return storage.contains(element.x)
|
||||
}
|
||||
|
||||
override fun containsAll(elements: Collection<Z>): Boolean {
|
||||
return elements.all { contains(it) }
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean {
|
||||
return storage.isEmpty()
|
||||
}
|
||||
|
||||
private class ZArrayIterator(val storage: IntArray): Iterator<Z> {
|
||||
var index = 0
|
||||
|
||||
override fun hasNext(): Boolean = index < storage.size
|
||||
|
||||
override fun next(): Z = Z(storage[index++])
|
||||
}
|
||||
|
||||
override fun iterator(): Iterator<Z> = ZArrayIterator(storage)
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val zs = ZArray(IntArray(5))
|
||||
|
||||
val testSize = zs.size
|
||||
if (testSize != 5) return "Failed: testSize=$testSize"
|
||||
|
||||
val testContains = zs.contains(object {} as Any)
|
||||
if (testContains) return "Failed: testContains=$testContains"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+56
@@ -0,0 +1,56 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int)
|
||||
|
||||
inline class ZArray(val storage: IntArray) : List<Z> {
|
||||
override val size: Int
|
||||
get() = storage.size
|
||||
|
||||
override fun contains(element: Z): Boolean {
|
||||
return storage.contains(element.x)
|
||||
}
|
||||
|
||||
override fun containsAll(elements: Collection<Z>): Boolean {
|
||||
return elements.all { contains(it) }
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean {
|
||||
return storage.isEmpty()
|
||||
}
|
||||
|
||||
override fun get(index: Int): Z = Z(storage[index])
|
||||
|
||||
override fun indexOf(element: Z): Int = storage.indexOf(element.x)
|
||||
|
||||
override fun lastIndexOf(element: Z): Int = storage.lastIndexOf(element.x)
|
||||
|
||||
override fun listIterator(): ListIterator<Z> = ZArrayIterator(storage)
|
||||
|
||||
override fun listIterator(index: Int): ListIterator<Z> = ZArrayIterator(storage, index)
|
||||
|
||||
override fun subList(fromIndex: Int, toIndex: Int): List<Z> = TODO()
|
||||
|
||||
private class ZArrayIterator(val storage: IntArray, var index: Int = 0): ListIterator<Z> {
|
||||
override fun hasNext(): Boolean = index < storage.size
|
||||
override fun next(): Z = Z(storage[index++])
|
||||
override fun nextIndex(): Int = index + 1
|
||||
|
||||
override fun hasPrevious(): Boolean = index > 0
|
||||
override fun previous(): Z = Z(storage[index--])
|
||||
override fun previousIndex(): Int = index - 1
|
||||
}
|
||||
|
||||
override fun iterator(): Iterator<Z> = ZArrayIterator(storage)
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val zs = ZArray(IntArray(5))
|
||||
|
||||
val testElement = object {} as Any
|
||||
zs.contains(testElement)
|
||||
zs.indexOf(testElement)
|
||||
zs.lastIndexOf(testElement)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+57
@@ -0,0 +1,57 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int)
|
||||
|
||||
inline class ZArrayMap(val storage: IntArray) : Map<Z, Z> {
|
||||
override val size: Int
|
||||
get() = storage.size
|
||||
|
||||
private class MapEntry(val i: Int, val si: Int): Map.Entry<Z, Z> {
|
||||
override val key: Z get() = Z(i)
|
||||
override val value: Z get() = Z(si)
|
||||
}
|
||||
|
||||
private class MapEntrySet(val storage: IntArray) : AbstractSet<Map.Entry<Z, Z>>() {
|
||||
private inner class MyIterator : Iterator<Map.Entry<Z, Z>> {
|
||||
var index = 0
|
||||
override fun hasNext(): Boolean = index < size
|
||||
override fun next(): Map.Entry<Z, Z> = MapEntry(index, storage[index++])
|
||||
}
|
||||
|
||||
override val size: Int
|
||||
get() = storage.size
|
||||
|
||||
override fun iterator(): Iterator<Map.Entry<Z, Z>> = MyIterator()
|
||||
}
|
||||
|
||||
override val entries: Set<Map.Entry<Z, Z>>
|
||||
get() = MapEntrySet(storage)
|
||||
|
||||
override val keys: Set<Z>
|
||||
get() = (0 until size).mapTo(HashSet()) { Z(it) }
|
||||
|
||||
override val values: Collection<Z>
|
||||
get() = storage.mapTo(ArrayList()) { Z(it) }
|
||||
|
||||
override fun containsKey(key: Z): Boolean = key.x in (0 until size)
|
||||
|
||||
override fun containsValue(value: Z): Boolean = storage.contains(value.x)
|
||||
|
||||
override fun get(key: Z) = storage.getOrNull(key.x)?.let { Z(it) }
|
||||
|
||||
override fun isEmpty(): Boolean = size > 0
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val zm = ZArrayMap(IntArray(5))
|
||||
|
||||
zm.containsKey(Z(0))
|
||||
zm.containsValue(Z(0))
|
||||
zm[Z(0)]
|
||||
|
||||
zm.containsKey(object {} as Any)
|
||||
zm.containsValue(object {} as Any)
|
||||
zm.get(object {} as Any)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/UIntArrayWithFullJdk_ir.txt
Vendored
+1
-1
@@ -29,7 +29,7 @@ public final class UIntArray {
|
||||
public synthetic final static method box-impl(p0: int[]): UIntArray
|
||||
public method clear(): void
|
||||
public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: int[]): int[]
|
||||
public synthetic bridge method contains(p0: java.lang.Object): boolean
|
||||
public bridge final method contains(p0: java.lang.Object): boolean
|
||||
public method contains-fLmw4x8(p0: int): boolean
|
||||
public static method contains-fLmw4x8(p0: int[], p1: int): boolean
|
||||
public method containsAll(@org.jetbrains.annotations.NotNull p0: java.util.Collection): boolean
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public final class InlineCollection {
|
||||
public synthetic final static method box-impl(p0: java.util.Collection): InlineCollection
|
||||
public method clear(): void
|
||||
public static method constructor-impl(p0: java.util.Collection): java.util.Collection
|
||||
public synthetic bridge method contains(p0: java.lang.Object): boolean
|
||||
public bridge final method contains(p0: java.lang.Object): boolean
|
||||
public method contains-jHY5zpA(p0: int): boolean
|
||||
public static method contains-jHY5zpA(p0: java.util.Collection, p1: int): boolean
|
||||
public method containsAll(p0: java.util.Collection): boolean
|
||||
|
||||
Vendored
+3
-3
@@ -28,7 +28,7 @@ public final class InlineList {
|
||||
public synthetic final static method box-impl(p0: java.util.List): InlineList
|
||||
public method clear(): void
|
||||
public static method constructor-impl(p0: java.util.List): java.util.List
|
||||
public synthetic bridge method contains(p0: java.lang.Object): boolean
|
||||
public bridge final method contains(p0: java.lang.Object): boolean
|
||||
public method contains-jHY5zpA(p0: int): boolean
|
||||
public static method contains-jHY5zpA(p0: java.util.List, p1: int): boolean
|
||||
public method containsAll(p0: java.util.Collection): boolean
|
||||
@@ -43,14 +43,14 @@ public final class InlineList {
|
||||
public static method getSize-impl(p0: java.util.List): int
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: java.util.List): int
|
||||
public synthetic bridge method indexOf(p0: java.lang.Object): int
|
||||
public bridge final method indexOf(p0: java.lang.Object): int
|
||||
public method indexOf-jHY5zpA(p0: int): int
|
||||
public static method indexOf-jHY5zpA(p0: java.util.List, p1: int): int
|
||||
public method isEmpty(): boolean
|
||||
public static method isEmpty-impl(p0: java.util.List): boolean
|
||||
public method iterator(): java.util.Iterator
|
||||
public static method iterator-impl(p0: java.util.List): java.util.Iterator
|
||||
public synthetic bridge method lastIndexOf(p0: java.lang.Object): int
|
||||
public bridge final method lastIndexOf(p0: java.lang.Object): int
|
||||
public method lastIndexOf-jHY5zpA(p0: int): int
|
||||
public static method lastIndexOf-jHY5zpA(p0: java.util.List, p1: int): int
|
||||
public method listIterator(): java.util.ListIterator
|
||||
|
||||
Vendored
+3
-2
@@ -39,16 +39,17 @@ public final class InlineMap {
|
||||
public synthetic final static method box-impl(p0: java.util.Map): InlineMap
|
||||
public method clear(): void
|
||||
public static method constructor-impl(p0: java.util.Map): java.util.Map
|
||||
public synthetic bridge method containsKey(p0: java.lang.Object): boolean
|
||||
public bridge final method containsKey(p0: java.lang.Object): boolean
|
||||
public method containsKey-FSIWiWE(p0: int): boolean
|
||||
public static method containsKey-FSIWiWE(p0: java.util.Map, p1: int): boolean
|
||||
public synthetic bridge method containsValue(p0: java.lang.Object): boolean
|
||||
public bridge final method containsValue(p0: java.lang.Object): boolean
|
||||
public method containsValue-jbX5DO8(p0: double): boolean
|
||||
public static method containsValue-jbX5DO8(p0: java.util.Map, p1: double): boolean
|
||||
public synthetic bridge method entrySet(): java.util.Set
|
||||
public method equals(p0: java.lang.Object): boolean
|
||||
public static method equals-impl(p0: java.util.Map, p1: java.lang.Object): boolean
|
||||
public final static method equals-impl0(p0: java.util.Map, p1: java.util.Map): boolean
|
||||
public bridge final method get(p0: java.lang.Object): IV
|
||||
public synthetic bridge method get(p0: java.lang.Object): java.lang.Object
|
||||
public method get-qgyy0Jc(p0: int): IV
|
||||
public static method get-qgyy0Jc(p0: java.util.Map, p1: int): IV
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public final class InlineMutableCollection {
|
||||
public method clear(): void
|
||||
public static method clear-impl(p0: java.util.Collection): void
|
||||
public static method constructor-impl(p0: java.util.Collection): java.util.Collection
|
||||
public synthetic bridge method contains(p0: java.lang.Object): boolean
|
||||
public bridge final method contains(p0: java.lang.Object): boolean
|
||||
public method contains-jHY5zpA(p0: int): boolean
|
||||
public static method contains-jHY5zpA(p0: java.util.Collection, p1: int): boolean
|
||||
public method containsAll(p0: java.util.Collection): boolean
|
||||
|
||||
+3
-3
@@ -33,7 +33,7 @@ public final class InlineMutableList {
|
||||
public method clear(): void
|
||||
public static method clear-impl(p0: java.util.List): void
|
||||
public static method constructor-impl(p0: java.util.List): java.util.List
|
||||
public synthetic bridge method contains(p0: java.lang.Object): boolean
|
||||
public bridge final method contains(p0: java.lang.Object): boolean
|
||||
public static method contains-jHY5zpA(p0: java.util.List, p1: long): boolean
|
||||
public method contains-jHY5zpA(p0: long): boolean
|
||||
public method containsAll(p0: java.util.Collection): boolean
|
||||
@@ -48,14 +48,14 @@ public final class InlineMutableList {
|
||||
public static method getSize-impl(p0: java.util.List): int
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: java.util.List): int
|
||||
public synthetic bridge method indexOf(p0: java.lang.Object): int
|
||||
public bridge final method indexOf(p0: java.lang.Object): int
|
||||
public static method indexOf-jHY5zpA(p0: java.util.List, p1: long): int
|
||||
public method indexOf-jHY5zpA(p0: long): int
|
||||
public method isEmpty(): boolean
|
||||
public static method isEmpty-impl(p0: java.util.List): boolean
|
||||
public method iterator(): java.util.Iterator
|
||||
public static method iterator-impl(p0: java.util.List): java.util.Iterator
|
||||
public synthetic bridge method lastIndexOf(p0: java.lang.Object): int
|
||||
public bridge final method lastIndexOf(p0: java.lang.Object): int
|
||||
public static method lastIndexOf-jHY5zpA(p0: java.util.List, p1: long): int
|
||||
public method lastIndexOf-jHY5zpA(p0: long): int
|
||||
public method listIterator(): java.util.ListIterator
|
||||
|
||||
+3
-2
@@ -40,16 +40,17 @@ public final class InlineMutableMap {
|
||||
public method clear(): void
|
||||
public static method clear-impl(p0: java.util.Map): void
|
||||
public static method constructor-impl(p0: java.util.Map): java.util.Map
|
||||
public synthetic bridge method containsKey(p0: java.lang.Object): boolean
|
||||
public bridge final method containsKey(p0: java.lang.Object): boolean
|
||||
public method containsKey-FSIWiWE(p0: int): boolean
|
||||
public static method containsKey-FSIWiWE(p0: java.util.Map, p1: int): boolean
|
||||
public synthetic bridge method containsValue(p0: java.lang.Object): boolean
|
||||
public bridge final method containsValue(p0: java.lang.Object): boolean
|
||||
public method containsValue-jbX5DO8(p0: double): boolean
|
||||
public static method containsValue-jbX5DO8(p0: java.util.Map, p1: double): boolean
|
||||
public synthetic bridge method entrySet(): java.util.Set
|
||||
public method equals(p0: java.lang.Object): boolean
|
||||
public static method equals-impl(p0: java.util.Map, p1: java.lang.Object): boolean
|
||||
public final static method equals-impl0(p0: java.util.Map, p1: java.util.Map): boolean
|
||||
public bridge final method get(p0: java.lang.Object): IV
|
||||
public synthetic bridge method get(p0: java.lang.Object): java.lang.Object
|
||||
public method get-qgyy0Jc(p0: int): IV
|
||||
public static method get-qgyy0Jc(p0: java.util.Map, p1: int): IV
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public final class InlineMutableSet2 {
|
||||
public method clear(): void
|
||||
public static method clear-impl(p0: java.util.Set): void
|
||||
public static method constructor-impl(p0: java.util.Set): java.util.Set
|
||||
public synthetic bridge method contains(p0: java.lang.Object): boolean
|
||||
public bridge final method contains(p0: java.lang.Object): boolean
|
||||
public method contains-C2ZI6mw(p0: int): boolean
|
||||
public static method contains-C2ZI6mw(p0: java.util.Set, p1: int): boolean
|
||||
public method containsAll(p0: java.util.Collection): boolean
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public final class InlineMutableSet {
|
||||
public method clear(): void
|
||||
public static method clear-impl(p0: java.util.Set): void
|
||||
public static method constructor-impl(p0: java.util.Set): java.util.Set
|
||||
public synthetic bridge method contains(p0: java.lang.Object): boolean
|
||||
public bridge final method contains(p0: java.lang.Object): boolean
|
||||
public method contains-jHY5zpA(p0: int): boolean
|
||||
public static method contains-jHY5zpA(p0: java.util.Set, p1: int): boolean
|
||||
public method containsAll(p0: java.util.Collection): boolean
|
||||
|
||||
Vendored
+1
-1
@@ -25,7 +25,7 @@ public final class InlineSet {
|
||||
public synthetic final static method box-impl(p0: java.util.Set): InlineSet
|
||||
public method clear(): void
|
||||
public static method constructor-impl(p0: java.util.Set): java.util.Set
|
||||
public synthetic bridge method contains(p0: java.lang.Object): boolean
|
||||
public bridge final method contains(p0: java.lang.Object): boolean
|
||||
public method contains-jHY5zpA(p0: int): boolean
|
||||
public static method contains-jHY5zpA(p0: java.util.Set, p1: int): boolean
|
||||
public method containsAll(p0: java.util.Collection): boolean
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ public final class UIntArray {
|
||||
public synthetic final static method box-impl(p0: int[]): UIntArray
|
||||
public method clear(): void
|
||||
public static method constructor-impl(p0: int[]): int[]
|
||||
public synthetic bridge method contains(p0: java.lang.Object): boolean
|
||||
public bridge final method contains(p0: java.lang.Object): boolean
|
||||
public method contains-WZ4Q5Ns(p0: int): boolean
|
||||
public static method contains-WZ4Q5Ns(p0: int[], p1: int): boolean
|
||||
public method containsAll(p0: java.util.Collection): boolean
|
||||
|
||||
Reference in New Issue
Block a user