JVM_IR indy-SAM conversions: inline classes
KT-44278 KT-26060 KT-42621
This commit is contained in:
+11
-1
@@ -6,11 +6,21 @@ fun interface IFoo<T> {
|
||||
fun foo(x: T): T
|
||||
}
|
||||
|
||||
fun foo1(fs: IFoo<Int>) = fs.foo(1)
|
||||
fun interface IBar<T : Any> {
|
||||
fun bar(x: T): T
|
||||
}
|
||||
|
||||
|
||||
fun foo1(foo: IFoo<Int>) = foo.foo(1)
|
||||
|
||||
fun bar1(bar: IBar<Int>) = bar.bar(1)
|
||||
|
||||
fun box(): String {
|
||||
val t = foo1 { it + 41 }
|
||||
if (t != 42) return "Failed: t=$t"
|
||||
|
||||
val tt = bar1 { it + 41 }
|
||||
if (tt != 42) return "Failed: tt=$tt"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
inline class Z(val value: Any)
|
||||
|
||||
fun interface IFooZ {
|
||||
fun foo(x: Z): Z
|
||||
}
|
||||
|
||||
fun foo1(fs: IFooZ) = fs.foo(Z(1))
|
||||
|
||||
fun box(): String {
|
||||
val t = foo1 { Z((it.value as Int) + 41) }
|
||||
if (t.value != 42) return "Failed: t=$t"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
inline class Z(val value: Int)
|
||||
|
||||
fun interface IFooZ {
|
||||
fun foo(x: Z): Z
|
||||
}
|
||||
|
||||
fun foo1(fs: IFooZ) = fs.foo(Z(1))
|
||||
|
||||
fun box(): String {
|
||||
val t = foo1 { Z(it.value + 41) }
|
||||
if (t.value != 42) return "Failed: t=$t"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineNAny.kt
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
inline class Z(val value: Any?)
|
||||
|
||||
fun interface IFooZ {
|
||||
fun foo(x: Z): Z
|
||||
}
|
||||
|
||||
fun foo1(fs: IFooZ) = fs.foo(Z(1))
|
||||
|
||||
fun box(): String {
|
||||
val t = foo1 { Z((it.value as Int) + 41) }
|
||||
if (t.value != 42) return "Failed: t=$t"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineNInt.kt
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
inline class Z(val value: Int?)
|
||||
|
||||
fun interface IFooZ {
|
||||
fun foo(x: Z): Z
|
||||
}
|
||||
|
||||
fun foo1(fs: IFooZ) = fs.foo(Z(1))
|
||||
|
||||
fun box(): String {
|
||||
val t = foo1 { Z(it.value!! + 41) }
|
||||
if (t.value != 42) return "Failed: t=$t"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
inline class Z(val value: String?)
|
||||
|
||||
fun interface IFooZ {
|
||||
fun foo(x: Z): Z
|
||||
}
|
||||
|
||||
fun foo1(fs: IFooZ) = fs.foo(Z("O"))
|
||||
|
||||
fun box(): String {
|
||||
val t = foo1 { Z(it.value!! + "K") }
|
||||
if (t.value != "OK") return "Failed: t=$t"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
inline class Z(val value: String)
|
||||
|
||||
fun interface IFooZ {
|
||||
fun foo(x: Z): Z
|
||||
}
|
||||
|
||||
fun foo1(fs: IFooZ) = fs.foo(Z("O"))
|
||||
|
||||
fun box(): String {
|
||||
val t = foo1 { Z(it.value + "K") }
|
||||
if (t.value != "OK") return "Failed: t=$t"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
inline class Z(val value: Any)
|
||||
|
||||
fun interface IFoo<T> {
|
||||
fun foo(x: T): T
|
||||
}
|
||||
|
||||
fun foo1(fs: IFoo<Z>) = fs.foo(Z(1))
|
||||
|
||||
fun box(): String {
|
||||
val t = foo1 { Z((it.value as Int) + 41) }
|
||||
if (t.value != 42) return "Failed: t=$t"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
inline class Z(val value: Int)
|
||||
|
||||
fun interface IFoo<T> {
|
||||
fun foo(x: T): T
|
||||
}
|
||||
|
||||
fun foo1(fs: IFoo<Z>) = fs.foo(Z(1))
|
||||
|
||||
fun box(): String {
|
||||
val t = foo1 { Z(it.value + 41) }
|
||||
if (t.value != 42) return "Failed: t=$t"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
inline class Z(val value: Any?)
|
||||
|
||||
fun interface IFoo<T> {
|
||||
fun foo(x: T): T
|
||||
}
|
||||
|
||||
fun foo1(fs: IFoo<Z>) = fs.foo(Z(1))
|
||||
|
||||
fun box(): String {
|
||||
val t = foo1 { Z((it.value as Int) + 41) }
|
||||
if (t.value != 42) return "Failed: t=$t"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
inline class Z(val value: Int?)
|
||||
|
||||
fun interface IFoo<T> {
|
||||
fun foo(x: T): T
|
||||
}
|
||||
|
||||
fun foo1(fs: IFoo<Z>) = fs.foo(Z(1))
|
||||
|
||||
fun box(): String {
|
||||
val t = foo1 { Z(it.value!! + 41) }
|
||||
if (t.value != 42) return "Failed: t=$t"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
inline class Z(val value: String?)
|
||||
|
||||
fun interface IFoo<T> {
|
||||
fun foo(x: T): T
|
||||
}
|
||||
|
||||
fun foo1(fs: IFoo<Z>) = fs.foo(Z("O"))
|
||||
|
||||
fun box(): String {
|
||||
val t = foo1 { Z(it.value!! + "K") }
|
||||
if (t.value != "OK") return "Failed: t=$t"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
inline class Z(val value: String)
|
||||
|
||||
fun interface IFoo<T> {
|
||||
fun foo(x: T): T
|
||||
}
|
||||
|
||||
fun foo1(fs: IFoo<Z>) = fs.foo(Z("O"))
|
||||
|
||||
fun box(): String {
|
||||
val t = foo1 { Z(it.value + "K") }
|
||||
if (t.value != "OK") return "Failed: t=$t"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user