Make JVM backend work with Collection.size as val

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 }`
This commit is contained in:
Denis Zharkov
2015-10-06 14:10:20 +03:00
parent 252c82abe3
commit 6a1566a6dc
18 changed files with 638 additions and 26 deletions
@@ -0,0 +1,5 @@
public class Test extends java.util.ArrayList<String> {
public final int size() {
return 56;
}
}
@@ -0,0 +1,12 @@
class OurTest : Test()
fun box(): String {
val t = OurTest()
val x: MutableCollection<String> = t
if (t.size != 56) return "fail 1: ${t.size}"
if (x.size != 56) return "fail 1: ${x.size}"
return "OK"
}