JVM_IR KT-47939 fixes after review
This commit is contained in:
committed by
TeamCityServer
parent
e179598457
commit
9eeb8f54fb
+35
-7
@@ -17,13 +17,39 @@ val ks1: (() -> String) -> KSupplier<String> =
|
||||
val ks11Foo = ks1(::foo)
|
||||
val ks21Foo = ks2(::foo)
|
||||
|
||||
fun interface KStringSupplier {
|
||||
fun get(): String
|
||||
}
|
||||
|
||||
val kss: (() -> String) -> KStringSupplier =
|
||||
::KStringSupplier
|
||||
|
||||
val ks11Bar = ks1(::bar)
|
||||
|
||||
val kssFoo = kss(::foo)
|
||||
|
||||
fun checkEqual(message: String, a1: Any, a2: Any) {
|
||||
if (a1 != a2) {
|
||||
throw Exception("$message: equals: $a1 != $a2")
|
||||
}
|
||||
if (a1.hashCode() != a2.hashCode()) {
|
||||
throw Exception("$message: hashCode: ${a1.hashCode()} != ${a2.hashCode()}")
|
||||
}
|
||||
}
|
||||
|
||||
fun checkNotEqual(message: String, a1: Any, a2: Any) {
|
||||
if (a1 == a2) {
|
||||
throw Exception("$message: equals: $a1 == $a2")
|
||||
}
|
||||
}
|
||||
|
||||
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)"
|
||||
checkEqual("ks11Foo == ks12Foo (same ctor, different source files)", ks11Foo, ks12Foo)
|
||||
checkEqual("ks11Foo == ks21Foo (different ctors, same source file)", ks11Foo, ks21Foo)
|
||||
checkEqual("ks11Foo == ks22Foo (different ctors, different source files)", ks11Foo, ks22Foo)
|
||||
|
||||
checkNotEqual("ks11Foo != ks11Bar (different funs)", ks11Foo, ks11Bar)
|
||||
checkNotEqual("ks11Foo != kssFoo (different fun interfaces)", ks11Foo, kssFoo)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -36,8 +62,10 @@ fun interface KSupplier<T> {
|
||||
|
||||
fun foo() = "abc"
|
||||
|
||||
fun bar() = "def"
|
||||
|
||||
val ks2: (() -> String) -> KSupplier<String> =
|
||||
::KSupplier
|
||||
|
||||
val ks12Foo = ks1(::foo)
|
||||
val ks22Foo = ks2(::foo)
|
||||
val ks22Foo = ks2(::foo)
|
||||
+27
-6
@@ -20,13 +20,34 @@ val ks2: (() -> String) -> KSupplier<String> =
|
||||
val kn1: (() -> Number) -> KSupplier<Number> =
|
||||
::KSupplier
|
||||
|
||||
|
||||
fun interface KRunnable {
|
||||
fun run()
|
||||
}
|
||||
|
||||
|
||||
fun checkEqual(message: String, a1: Any, a2: Any) {
|
||||
if (a1 != a2) {
|
||||
throw Exception("$message: equals: $a1 != $a2")
|
||||
}
|
||||
if (a1.hashCode() != a2.hashCode()) {
|
||||
throw Exception("$message: hashCode: ${a1.hashCode()} != ${a2.hashCode()}")
|
||||
}
|
||||
}
|
||||
|
||||
fun checkNotEqual(message: String, a1: Any, a2: Any) {
|
||||
if (a1 == a2) {
|
||||
throw Exception("$message: equals: $a1 == $a2")
|
||||
}
|
||||
}
|
||||
|
||||
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)"
|
||||
checkEqual("ks1 == ks2 (same file, same SAM type)", ks1, ks2)
|
||||
checkEqual("ks1 == ks3 (different file, same SAM type)", ks1, ks3)
|
||||
checkEqual("ks1 == kn1 (same file, same SAM interface, different type arguments)", ks1, kn1)
|
||||
|
||||
val kr: (() -> Unit) -> KRunnable = ::KRunnable
|
||||
checkNotEqual("ks1 != kr (different fun interfaces)", ks1, kr)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user