JVM_IR KT-47939 equality for fun interface constructor references
This commit is contained in:
committed by
TeamCityServer
parent
50b0dae786
commit
e179598457
+43
@@ -0,0 +1,43 @@
|
||||
// !LANGUAGE: +AllowKotlinFunInterfaceConstructorReference
|
||||
|
||||
// IGNORE_BACKEND: JVM
|
||||
// ^ unsupported in old JVM BE
|
||||
|
||||
// IGNORE_BACKEND: WASM
|
||||
// ^ wasm-function[1893]:0x1cf8a: RuntimeError: dereferencing a null pointer
|
||||
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// ^ TypeError: tmp is not a function
|
||||
|
||||
// FILE: funInterfaceConstructorEquality.kt
|
||||
|
||||
val ks1: (() -> String) -> KSupplier<String> =
|
||||
::KSupplier
|
||||
|
||||
val ks11Foo = ks1(::foo)
|
||||
val ks21Foo = ks2(::foo)
|
||||
|
||||
fun box(): String {
|
||||
if (ks11Foo != ks12Foo)
|
||||
return "failed: ks11Foo != ks12Foo (same ctor, different source files)"
|
||||
if (ks11Foo != ks21Foo)
|
||||
return "failed: ks11Foo != ks21Foo (different ctors, same source file)"
|
||||
if (ks11Foo != ks22Foo)
|
||||
return "failed: ks11Foo != ks22Foo (different ctors, different source files)"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: KSupplier.kt
|
||||
|
||||
fun interface KSupplier<T> {
|
||||
fun get(): T
|
||||
}
|
||||
|
||||
fun foo() = "abc"
|
||||
|
||||
val ks2: (() -> String) -> KSupplier<String> =
|
||||
::KSupplier
|
||||
|
||||
val ks12Foo = ks1(::foo)
|
||||
val ks22Foo = ks2(::foo)
|
||||
Vendored
+2
-1
@@ -1,6 +1,7 @@
|
||||
// !LANGUAGE: +AllowKotlinFunInterfaceConstructorReference
|
||||
|
||||
// IGNORE_BACKEND: JVM
|
||||
// ^ feature supported in IR-based backends only
|
||||
// ^ unsupported in old JVM BE
|
||||
|
||||
fun interface KSupplier<T> {
|
||||
fun get(): T
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
// !LANGUAGE: +AllowKotlinFunInterfaceConstructorReference
|
||||
|
||||
// DONT_TARGET_EXACT_BACKEND: JVM
|
||||
// ^ old JVM BE generates bogus code that fails in 'invoke', but works almost as expected in terms of equality
|
||||
|
||||
// IGNORE_BACKEND: WASM
|
||||
// ^ Failed: ks1 != ks2 (same file, same SAM type)
|
||||
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// ^ Failed: ks1 != ks2 (same file, same SAM type)
|
||||
|
||||
// FILE: funInterfaceConstructorEquality.kt
|
||||
|
||||
val ks1: (() -> String) -> KSupplier<String> =
|
||||
::KSupplier
|
||||
|
||||
val ks2: (() -> String) -> KSupplier<String> =
|
||||
::KSupplier
|
||||
|
||||
val kn1: (() -> Number) -> KSupplier<Number> =
|
||||
::KSupplier
|
||||
|
||||
fun box(): String {
|
||||
if (ks1 != ks2)
|
||||
return "Failed: ks1 != ks2 (same file, same SAM type)"
|
||||
if (ks1 != ks3)
|
||||
return "Failed: ks1 != ks3 (different file, same SAM type)"
|
||||
if (ks1 != kn1)
|
||||
return "Failed: ks1 != kn1 (same file, same SAM interface, different type arguments)"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: KSupplier.kt
|
||||
|
||||
fun interface KSupplier<T> {
|
||||
fun get(): T
|
||||
}
|
||||
|
||||
val ks3: (() -> String) -> KSupplier<String> =
|
||||
::KSupplier
|
||||
Reference in New Issue
Block a user