6a1566a6dc
0. Such properties are called special because their accessor JVM name differs from usual one
1. When making call to such property, always choose special name
2. When generating Kotlin class inheriting such property generate `final bridge int size() { return this.getSize(); }`
3. If there is no `size` declaration in current class generate `bridge int getSize() { // super-call }`
41 lines
970 B
Kotlin
Vendored
41 lines
970 B
Kotlin
Vendored
class A : Map<String, String> {
|
|
override val size: Int get() = 56
|
|
|
|
override fun isEmpty(): Boolean {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun containsKey(key: Any?): Boolean {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun containsValue(value: Any?): Boolean {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun get(key: Any?): String? {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun keySet(): Set<String> {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun values(): Collection<String> {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun entrySet(): Set<Map.Entry<String, String>> {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
val a = A()
|
|
if (a.size != 56) return "fail 1: ${a.size}"
|
|
|
|
val x: Map<String, String> = a
|
|
if (x.size != 56) return "fail 2: ${x.size}"
|
|
|
|
return "OK"
|
|
} |