K2: add bytecode listing tests

#KT-57171 Fixed
This commit is contained in:
Alexander Udalov
2023-03-10 00:18:25 +01:00
parent f8deae4570
commit f0fba7be64
59 changed files with 5423 additions and 55 deletions
@@ -1,3 +1,6 @@
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57228 K2: annotations for interface member properties implemented by delegation are copied
annotation class Ann
interface IFoo {
@@ -7,4 +10,4 @@ interface IFoo {
@Ann fun String.testExtFun()
}
class DFoo(d: IFoo) : IFoo by d
class DFoo(d: IFoo) : IFoo by d
@@ -0,0 +1,18 @@
// !LANGUAGE: +RepeatableAnnotations
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// FULL_JDK
// JVM_TARGET: 1.8
// IGNORE_BACKEND_K1: JVM_IR
// ^ "c", "d" is not detected because of KT-48141.
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: ["c", "d", "a", "b"] because of KT-57219 K2: incorrect relative order of normal and use-site-targeted annotations on property getter in the resulting bytecode
@Repeatable
annotation class A(val v: String)
@get:A("a") @get:A("b")
val ab: Int
@get:A("c") @get:A("d") get() = 0
@@ -0,0 +1,25 @@
@kotlin.jvm.internal.RepeatableContainer
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class A$Container {
// source: 'propertyGetterSeveralUseSiteTargets.kt'
public abstract method value(): A[]
public inner class A$Container
}
@kotlin.annotation.Repeatable
@java.lang.annotation.Retention(value=RUNTIME)
@java.lang.annotation.Repeatable(value=A$Container::class)
@kotlin.Metadata
public annotation class A {
// source: 'propertyGetterSeveralUseSiteTargets.kt'
public abstract method v(): java.lang.String
public inner class A$Container
}
@kotlin.Metadata
public final class PropertyGetterSeveralUseSiteTargetsKt {
// source: 'propertyGetterSeveralUseSiteTargets.kt'
public final static @A$Container(value=[A(v="a"), A(v="b"), A(v="c"), A(v="d")]) method getAb(): int
public inner class A$Container
}
@@ -4,6 +4,9 @@
// FULL_JDK
// JVM_TARGET: 1.8
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57219 K2: incorrect relative order of normal and use-site-targeted annotations on property getter in the resulting bytecode
@Repeatable
annotation class A(val v: String)
@@ -19,5 +22,4 @@ val ef: Int
@get:A("g")
val ghi: Int
// "i" is not detected because of KT-48141.
@A("h") @get:A("i") get() = 0
@A("h") get() = 0
@@ -1,6 +1,9 @@
// WITH_STDLIB
// FULL_JDK
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57269 K2: collection stub for `sort` is not generated for custom List subclasses
import java.util.*
class ListSet<out E : Any> : List<E>, Set<E> {
@@ -1,3 +1,6 @@
// WITH_SIGNATURES
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
abstract class ByteShortMap : Map<Byte, Short>
@@ -1,3 +1,6 @@
// WITH_SIGNATURES
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
abstract class GenericMap<K, V> : Map<K, V>
@@ -1,3 +1,6 @@
// WITH_SIGNATURES
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
abstract class GenericStringMap<K> : Map<K, String>
@@ -1,3 +1,6 @@
// WITH_SIGNATURES
abstract class NumberStringMap : Map<Number, String>
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
abstract class NumberStringMap : Map<Number, String>
@@ -1,5 +1,8 @@
// WITH_SIGNATURES
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
abstract class GenericMap<K, V> : Map<K, V>
abstract class NumberStringMap : GenericMap<Number, String>()
abstract class NumberStringMap : GenericMap<Number, String>()
@@ -1,3 +1,6 @@
// WITH_SIGNATURES
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
abstract class StringGenericMap<V> : Map<String, V>
@@ -1,3 +1,6 @@
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
class DGenericIterator<T>(d: Iterator<T>) : Iterator<T> by d
class DGenericListIterator<T>(d: ListIterator<T>) : ListIterator<T> by d
@@ -16,4 +19,4 @@ class DGenericMapEntry<K, V>(d: Map.Entry<K, V>) : Map.Entry<K, V> by d
class DGenericCollectionBySet<T>(d: Set<T>) : Collection<T> by d
class DGenericCollectionByList<T>(d: List<T>) : Collection<T> by d
class DGenericCollectionByList<T>(d: List<T>) : Collection<T> by d
@@ -1,3 +1,6 @@
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
class DStringIterator(d: Iterator<String>) : Iterator<String> by d
class DStringListIterator(d: ListIterator<String>) : ListIterator<String> by d
@@ -16,4 +19,4 @@ class DStringMapEntry(d: Map.Entry<String, Number>) : Map.Entry<String, Number>
class DStringCollectionBySet(d: Set<String>) : Collection<String> by d
class DStringCollectionByList(d: List<String>) : Collection<String> by d
class DStringCollectionByList(d: List<String>) : Collection<String> by d
@@ -1,4 +1,8 @@
// FULL_JDK
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57269 K2: collection stub for `sort` is not generated for custom List subclasses
class DStringIterator(d: Iterator<String>) : Iterator<String> by d
class DStringListIterator(d: ListIterator<String>) : ListIterator<String> by d
@@ -17,4 +21,4 @@ class DStringMapEntry(d: Map.Entry<String, Number>) : Map.Entry<String, Number>
class DStringCollectionBySet(d: Set<String>) : Collection<String> by d
class DStringCollectionByList(d: List<String>) : Collection<String> by d
class DStringCollectionByList(d: List<String>) : Collection<String> by d
@@ -1,3 +1,6 @@
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
class DIntIterator(d: Iterator<Int>) : Iterator<Int> by d
class DIntListIterator(d: ListIterator<Int>) : ListIterator<Int> by d
@@ -16,4 +19,4 @@ class DIntMapEntry(d: Map.Entry<Int, Double>) : Map.Entry<Int, Double> by d
class DIntCollectionBySet(d: Set<Int>) : Collection<Int> by d
class DIntCollectionByList(d: List<Int>) : Collection<Int> by d
class DIntCollectionByList(d: List<Int>) : Collection<Int> by d
@@ -1,6 +1,9 @@
// FULL_JDK
// See also: https://youtrack.jetbrains.com/issue/KT-42330
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57269 K2: collection stub for `sort` is not generated for custom List subclasses
class DIntIterator(d: Iterator<Int>) : Iterator<Int> by d
class DIntListIterator(d: ListIterator<Int>) : ListIterator<Int> by d
@@ -19,4 +22,4 @@ class DIntMapEntry(d: Map.Entry<Int, Double>) : Map.Entry<Int, Double> by d
class DIntCollectionBySet(d: Set<Int>) : Collection<Int> by d
class DIntCollectionByList(d: List<Int>) : Collection<Int> by d
class DIntCollectionByList(d: List<Int>) : Collection<Int> by d
@@ -1,4 +1,8 @@
// FULL_JDK
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57269 K2: collection stub for `sort` is not generated for custom List subclasses
class DGenericIterator<T>(d: Iterator<T>) : Iterator<T> by d
class DGenericListIterator<T>(d: ListIterator<T>) : ListIterator<T> by d
@@ -17,4 +21,4 @@ class DGenericMapEntry<K, V>(d: Map.Entry<K, V>) : Map.Entry<K, V> by d
class DGenericCollectionBySet<T>(d: Set<T>) : Collection<T> by d
class DGenericCollectionByList<T>(d: List<T>) : Collection<T> by d
class DGenericCollectionByList<T>(d: List<T>) : Collection<T> by d
@@ -1,6 +1,9 @@
// FULL_JDK
// See: KT-42114, KT-42115
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57269 K2: collection stub for `sort` is not generated for custom List subclasses
abstract class AbstractIterator : Iterator<String>
abstract class AbstractIterable : Iterable<String>
@@ -1,3 +1,6 @@
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57299 K2: VerifyError due to overriding final method `size` on a subclass of Collection and Set
abstract class AC<X> : Collection<X>
abstract class ASet<T> : AC<T>(), Set<T>
abstract class ASet<T> : AC<T>(), Set<T>
@@ -1,5 +1,8 @@
// WITH_STDLIB
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57300 K2: subclass of MutableCollection with primitive element type has methods with boxed type
abstract class AIterD : AbstractIterator<Double>()
abstract class ACollD : AbstractCollection<Double>()
@@ -11,4 +14,3 @@ abstract class ASetD : AbstractSet<Double>()
abstract class AMSetD : AbstractMutableSet<Double>()
abstract class AListD : AbstractList<Double>()
@@ -1,5 +1,11 @@
// WITH_STDLIB
// IGNORE_BACKEND_K2: JVM_IR
// FIR status:
// 1) KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
// 2) KT-57300 K2: subclass of MutableCollection with primitive element type has methods with boxed type
// (`containsValue(Ljava/lang/Double;)Z` instead of `containsValue(D)Z`)
abstract class AMapSD : AbstractMap<String, Double>()
abstract class AMMapSD : AbstractMutableMap<String, Double>()
abstract class AMMapSD : AbstractMutableMap<String, Double>()
@@ -1,5 +1,8 @@
// WITH_STDLIB
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57300 K2: subclass of MutableCollection with primitive element type has methods with boxed type
abstract class AMListD : AbstractMutableList<Double>()
abstract class AMListI : AbstractMutableList<Int>()
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_K2: JVM_IR
// FULL_JDK
import java.util.concurrent.*
@@ -11,4 +10,4 @@ class Test1 : Iterable<String> {
class Test2 : Iterable<String> {
private val received = Array<String>(0) { "" }
override fun iterator() = received.iterator()
}
}
@@ -1,6 +1,9 @@
// Ensure the proper collection stubs are added, in
// particular *not* when specialized implementations are provided.
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
class MyMap<K, V> : Map<K, V> {
class MySet<E> : Set<E> {
@@ -20,4 +23,4 @@ class MyMap<K, V> : Map<K, V> {
override fun containsValue(value: V): Boolean = TODO()
override fun get(key: K): V = TODO()
override fun isEmpty(): Boolean = TODO()
}
}
@@ -1,5 +1,8 @@
// See KT-42033
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
interface ObservableMap<K, V> : Map<K, V>
abstract class ObservableMutableMap<K, V> : ObservableMap<K, V> {
@@ -9,4 +12,4 @@ abstract class ObservableMutableMap<K, V> : ObservableMap<K, V> {
fun putAll(from: Map<out K, V>) {
}
}
}
@@ -1,7 +1,5 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K2: JVM_IR
// IGNORE_BACKEND: JVM
class Outer {
val x: Int = 1
@@ -16,4 +14,4 @@ fun f(outer: Outer) {
with(outer) {
Inner(3)
}
}
}
@@ -1,7 +1,5 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K2: JVM_IR
// IGNORE_BACKEND: JVM
interface Canvas {
val suffix: String
@@ -19,4 +17,4 @@ class Circle : Shape {
object MyCanvas : Canvas {
override val suffix = ""
}
}
@@ -1,7 +1,5 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K2: JVM_IR
// IGNORE_BACKEND: JVM
data class Pair<A, B>(val first: A, val second: B)
@@ -9,4 +7,4 @@ context(Comparator<T>)
infix operator fun <T> T.compareTo(other: T) = compare(this, other)
context(Comparator<T>)
val <T> Pair<T, T>.min get() = if (first < second) first else second
val <T> Pair<T, T>.min get() = if (first < second) first else second
@@ -1,10 +1,8 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K2: JVM_IR
// IGNORE_BACKEND: JVM
class View {
val coefficient = 42
}
context(View) val Int.dp get() = coefficient * this
context(View) val Int.dp get() = coefficient * this
@@ -1,7 +1,5 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K2: JVM_IR
// IGNORE_BACKEND: JVM
class Param
class O {
@@ -12,4 +10,4 @@ class K {
}
context(O)
fun <T> K.f(g: context(O) K.(Param) -> T) = g(this@O, this@K, Param())
fun <T> K.f(g: context(O) K.(Param) -> T) = g(this@O, this@K, Param())
@@ -1,7 +1,5 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K2: JVM_IR
// IGNORE_BACKEND: JVM
// WITH_STDLIB
interface Semigroup<T> {
@@ -21,4 +19,4 @@ object StringMonoid : Monoid<String> {
}
context(Monoid<T>)
fun <T> List<T>.sum(): T = fold(unit) { acc, e -> acc.combine(e) }
fun <T> List<T>.sum(): T = fold(unit) { acc, e -> acc.combine(e) }
@@ -1,7 +1,5 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K2: JVM_IR
// IGNORE_BACKEND: JVM
class C {
val c = 42
@@ -16,4 +14,4 @@ fun bar(c: C) {
with(c) {
foo()
}
}
}
@@ -1,7 +1,5 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K2: JVM_IR
// IGNORE_BACKEND: JVM
interface A {
fun a(): Int
@@ -11,4 +9,4 @@ interface B {
}
context(A, B)
val c get() = a() + b()
val c get() = a() + b()
@@ -1,5 +1,8 @@
// !LANGUAGE: +SuspendConversion
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57244 K2: slightly different naming scheme for suspend conversion adapters
fun myApply(f: suspend () -> Unit) {}
fun test(f: () -> Unit) {
@@ -1,4 +1,6 @@
// WITH_STDLIB
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57216 K2: non-trivial enum declaration does not have ACC_FINAL in the bytecode
enum class Test {
@Deprecated("") ENTRY1,
@@ -1,3 +1,6 @@
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57228 K2: annotations for interface member properties implemented by delegation are copied
interface IFoo {
@Deprecated("")
val prop: String get() = ""
@@ -24,4 +27,4 @@ class ExplicitOverride : IFoo {
class ExplicitOverride2 : IFoo2 {
override val prop: String get() = ""
override val String.extProp: String get() = ""
}
}
+4 -1
View File
@@ -1,3 +1,6 @@
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57216 K2: non-trivial enum declaration does not have ACC_FINAL in the bytecode
enum class SimpleEnum {
A, B, C
}
@@ -18,4 +21,4 @@ annotation class Ann
enum class WithAnnotations {
@Ann A, @Ann B
}
}
@@ -3,6 +3,9 @@
// FULL_JDK
// WITH_STDLIB
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57216 K2: non-trivial enum declaration does not have ACC_FINAL in the bytecode
enum class SimpleEnum {
A, B, C
}
@@ -1,6 +1,9 @@
// !LANGUAGE: +InlineClasses
// WITH_STDLIB
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57211 K2: incorrect "error: an annotation argument must be a compile-time constant" on unsigned array in annotation argument
annotation class Ann(
val u: UInt,
val uba: UByteArray,
@@ -16,4 +19,4 @@ annotation class Ann(
[1u, 1u],
ulongArrayOf(1u, 1u)
)
fun foo() {}
fun foo() {}
@@ -1,4 +1,6 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57216 K2: non-trivial enum declaration does not have ACC_FINAL in the bytecode
inline class Z(val x: Int)
@@ -23,4 +25,4 @@ enum class TestEnum(val z: Z) {
class TestInner {
inner class Inner(val z: Z)
}
}
@@ -1,5 +1,9 @@
// IGNORE_ANNOTATIONS
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
// (in this case, it's `getOrDefault-impl` because of inline class mangling, and then `remove` is unmangled for some reason)
inline class InlineMap<K, V>(private val map: Map<K, V>) : Map<K, V> {
override val entries: Set<Map.Entry<K, V>> get() = map.entries
override val keys: Set<K> get() = map.keys
@@ -10,4 +14,3 @@ inline class InlineMap<K, V>(private val map: Map<K, V>) : Map<K, V> {
override fun get(key: K): V? = map[key]
override fun isEmpty(): Boolean = map.isEmpty()
}
@@ -1,5 +1,9 @@
// IGNORE_ANNOTATIONS
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
// (in this case, it's `remove-impl`/`getOrDefault-impl` because of inline class mangling)
inline class InlineMutableMap<K, V>(private val mmap: MutableMap<K, V>) : MutableMap<K, V> {
override val size: Int get() = mmap.size
override fun containsKey(key: K): Boolean = mmap.containsKey(key)
@@ -14,4 +18,3 @@ inline class InlineMutableMap<K, V>(private val mmap: MutableMap<K, V>) : Mutabl
override fun putAll(from: Map<out K, V>) { mmap.putAll(from) }
override fun remove(key: K): V? = mmap.remove(key)
}
@@ -1,5 +1,9 @@
// IGNORE_ANNOTATIONS
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
// (in this case, it's `getOrDefault-h8vw2VU` because of inline class mangling, and then `remove` is unmangled for some reason)
inline class IK(val x: Int)
inline class IV(val x: Double)
@@ -13,4 +17,3 @@ inline class InlineMap(private val map: Map<IK, IV>) : Map<IK, IV> {
override fun get(key: IK): IV? = map[key]
override fun isEmpty(): Boolean = map.isEmpty()
}
@@ -1,5 +1,9 @@
// IGNORE_ANNOTATIONS
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
// (in this case, it's `remove-YEowaJk`/`getOrDefault-h8vw2VU` because of inline class mangling)
inline class IK(val x: Int)
inline class IV(val x: Double)
@@ -17,4 +21,3 @@ inline class InlineMutableMap(private val mmap: MutableMap<IK, IV>) : MutableMap
override fun putAll(from: Map<out IK, IV>) { mmap.putAll(from) }
override fun remove(key: IK): IV? = mmap.remove(key)
}
+5
View File
@@ -1,3 +1,8 @@
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: delegated implementation for `foo` is generated in `C`, which makes this code execute fine at runtime.
// For K1, invoking `C.foo` leads to AbstractMethodError, see KT-46120.
// Probably there should be a frontend error. (But if not, then K2 is correct.)
// FILE: kt45934.kt
class C(client: J) : I by client
@@ -3,6 +3,9 @@
// TARGET_BACKEND: JVM
// WITH_STDLIB
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: K2 incorrectly generates Anno.class, need to investigate after KT-57243 is fixed.
@file:Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE") // TODO: support common sources in the test infrastructure
@OptionalExpectation
@@ -0,0 +1,51 @@
@kotlin.Metadata
public interface A {
// source: 'nonApproxToValidSupertype.kt'
}
@kotlin.Metadata
public interface B {
// source: 'nonApproxToValidSupertype.kt'
}
@kotlin.Metadata
public final class G {
// source: 'nonApproxToValidSupertype.kt'
public method <init>(): void
public final method check(@org.jetbrains.annotations.NotNull p0: IFoo): void
}
@kotlin.Metadata
public interface IFoo {
// source: 'nonApproxToValidSupertype.kt'
public abstract method accept(@org.jetbrains.annotations.NotNull p0: X): void
}
@kotlin.Metadata
final class NonApproxToValidSupertypeKt$test$1 {
// source: 'nonApproxToValidSupertype.kt'
enclosing method NonApproxToValidSupertypeKt.test()V
public final static field INSTANCE: NonApproxToValidSupertypeKt$test$1
inner (anonymous) class NonApproxToValidSupertypeKt$test$1
static method <clinit>(): void
method <init>(): void
public final method accept(@org.jetbrains.annotations.NotNull p0: X): void
}
@kotlin.Metadata
public final class NonApproxToValidSupertypeKt {
// source: 'nonApproxToValidSupertype.kt'
inner (anonymous) class NonApproxToValidSupertypeKt$test$1
public final static method sel(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
public final static method test(): void
}
@kotlin.Metadata
public interface X {
// source: 'nonApproxToValidSupertype.kt'
}
@kotlin.Metadata
public interface Z {
// source: 'nonApproxToValidSupertype.kt'
}
@@ -1,3 +1,6 @@
// K1 generates `accept(Object)` and bridge `accept(X)` in the SAM adapter.
// K2 generates `accept(X)` only. It is fine though, because if `check`'s parameter is passed where Z is expected, checkcast is added.
interface X
interface Z
@@ -17,4 +20,4 @@ class G<T> where T: X, T: Z {
fun test() {
val g = sel(G<A>(), G<B>()) // g: G<out { X & Z }>
g.check {} // (*) target SAM type: IFoo<{ X & Z }> (TODO: report a compile time error for this case)
}
}
@@ -0,0 +1,62 @@
@kotlin.Metadata
public interface A {
// source: 'nonApproxToValidSupertype2.kt'
}
@kotlin.Metadata
public interface B {
// source: 'nonApproxToValidSupertype2.kt'
}
@kotlin.Metadata
public final class G {
// source: 'nonApproxToValidSupertype2.kt'
public method <init>(): void
public final method check(@org.jetbrains.annotations.NotNull p0: IFoo): void
}
@kotlin.Metadata
public interface IFoo {
// source: 'nonApproxToValidSupertype2.kt'
public abstract method accept(@org.jetbrains.annotations.NotNull p0: U): void
}
@kotlin.Metadata
final class NonApproxToValidSupertype2Kt$test$1 {
// source: 'nonApproxToValidSupertype2.kt'
enclosing method NonApproxToValidSupertype2Kt.test()V
public final static field INSTANCE: NonApproxToValidSupertype2Kt$test$1
inner (anonymous) class NonApproxToValidSupertype2Kt$test$1
static method <clinit>(): void
method <init>(): void
public final method accept(@org.jetbrains.annotations.NotNull p0: X): void
public synthetic bridge method accept(p0: U): void
}
@kotlin.Metadata
public final class NonApproxToValidSupertype2Kt {
// source: 'nonApproxToValidSupertype2.kt'
inner (anonymous) class NonApproxToValidSupertype2Kt$test$1
public final static method sel(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
public final static method test(): void
}
@kotlin.Metadata
public interface U {
// source: 'nonApproxToValidSupertype2.kt'
}
@kotlin.Metadata
public interface W {
// source: 'nonApproxToValidSupertype2.kt'
}
@kotlin.Metadata
public interface X {
// source: 'nonApproxToValidSupertype2.kt'
}
@kotlin.Metadata
public interface Z {
// source: 'nonApproxToValidSupertype2.kt'
}
@@ -1,3 +1,6 @@
// K1 generates `accept(Object)` and bridge `accept(U)` in the SAM adapter.
// K2 generates `accept(X)` and bridge `accept(U)`. It is fine though, because if `check`'s parameter is passed where Z or W is expected, checkcast is added.
interface X: U, W
interface Z: U, W
@@ -20,4 +23,4 @@ class G<T> where T: U, T: W {
fun test() {
val g = sel(G<A>(), G<B>())
g.check {} // TODO: report a compile time error for this case
}
}
@@ -1,5 +1,8 @@
// !LANGUAGE: -AllowSealedInheritorsInDifferentFilesOfSamePackage
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: don't support legacy feature
sealed class TestNoSubclasses(val x: Int)
sealed class TestSubclassAfter(val x: Int)
@@ -11,4 +14,4 @@ sealed class TestSubclassAfterAllDefaults(val x: Int = 0)
class X3 : TestSubclassAfterAllDefaults()
class X4: TestSubclassBefore(1)
sealed class TestSubclassBefore(val x: Int)
sealed class TestSubclassBefore(val x: Int)
@@ -1,5 +1,8 @@
// WITH_STDLIB
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
open class A : HashMap<String, String>()
class B : A()
class B : A()
@@ -1,6 +1,9 @@
// TARGET_BACKEND: JVM
// FULL_JDK
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57301 K2: `getOrDefault` and bridges are not generated for certain Map subclasses
// FILE: kt48945.kt
interface MSS : Map<String, String>
interface GM<K, V> : Map<K, V>
@@ -1,5 +1,8 @@
// WITH_SIGNATURES
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57268 K2: extra methods `remove` and/or `getOrDefault` are generated for Map subclasses with JDK 1.6 in dependencies
interface MapN<K : Number, V> : Map<K, V>
abstract class MapImpl<A, B> : Map<A, B> {
@@ -12,4 +15,4 @@ abstract class MapSImpl<B> : Map<String, B> {
abstract class MapNImpl<A : Number, B> : MapN<A, B> {
override fun containsKey(key: A): Boolean = false
}
}
@@ -2,6 +2,9 @@
// WITH_STDLIB
// FULL_JDK
// IGNORE_BACKEND_K2: JVM_IR
// FIR status: KT-57301 K2: `getOrDefault` and bridges are not generated for certain Map subclasses
abstract class AMap1<K1, V1>(private val m: Map<K1, V1>) : Map<K1, V1> by m
interface Value2