Equality comparison for bound callable references takes into account bound receiver.
Fixed KT-14939: use expected receiver type when generating receiver code in get/set methods for bound property references.
Otherwise we have VerifyError for bound receiver 'null' of type 'Nothing?', which is mapped to 'java.lang.Void'.
TODO: proper equality comparison for property accessors ('x::prop.getter', 'x::prop.setter').
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// TODO: investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun Boolean.foo() = 1
|
||||
fun Byte.foo() = 2
|
||||
fun Short.foo() = 3
|
||||
fun Int.foo() = 4
|
||||
fun Long.foo() = 5
|
||||
fun Char.foo() = 6
|
||||
fun Float.foo() = 7
|
||||
fun Double.foo() = 8
|
||||
|
||||
fun testRef(name: String, f: () -> Int, expected: Int) {
|
||||
val actual = f()
|
||||
if (actual != expected) throw AssertionError("$name: $actual != $expected")
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
testRef("Boolean", true::foo, 1)
|
||||
testRef("Byte", 1.toByte()::foo, 2)
|
||||
testRef("Short", 1.toShort()::foo, 3)
|
||||
testRef("Int", 1::foo, 4)
|
||||
testRef("Long", 1L::foo, 5)
|
||||
testRef("Char", '1'::foo, 6)
|
||||
testRef("Float", 1.0F::foo, 7)
|
||||
testRef("Double", 1.0::foo, 8)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user