Files
kotlin-fork/compiler/testData/codegen/box/callableReference/bound/primitiveReceiver.kt
T
Dmitry Petrov 3dd0c9d1c7 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').
2016-11-25 14:49:24 +03:00

29 lines
717 B
Kotlin
Vendored

// 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"
}