Files
kotlin-fork/compiler/testData/diagnostics/tests/callableReference/property/extensionFromTopLevel.kt
T
Alexander Udalov 30794060a9 Simplify property hierarchy in reflection
Leave only 3*2 = 6 classes: KProperty0, KProperty1, KProperty2 and their
mutable analogs, depending on the number of receivers a property takes
2015-07-10 20:10:09 +03:00

26 lines
535 B
Kotlin
Vendored

// !CHECK_TYPE
import kotlin.reflect.*
val String.countCharacters: Int
get() = length()
var Int.meaning: Long
get() = 42L
set(value) {}
fun test() {
val f = String::countCharacters
checkSubtype<KProperty1<String, Int>>(f)
checkSubtype<KMutableProperty1<String, Int>>(<!TYPE_MISMATCH!>f<!>)
checkSubtype<Int>(f.get("abc"))
f.<!UNRESOLVED_REFERENCE!>set<!>("abc", 0)
val g = Int::meaning
checkSubtype<KMutableProperty1<Int, Long>>(g)
checkSubtype<Long>(g.get(0))
g.set(1, 0L)
}