Rewrite mutable collection stub method generation

The main problem of the previous approach was that we were only generating
erased method signatures, which was incorrect in case a class also had a member
from another supertype with the same signature as the substituted one from the
collection. Javac issues compilation errors when compiling Java code against
such classes.

Also all the needed method stub signatures were hardcoded in
generateBuiltInMethodStubs() and the case of MutableListIterator was missing
This commit is contained in:
Alexander Udalov
2014-10-22 16:48:30 +04:00
parent 1fc9c58b24
commit 35e956609a
25 changed files with 795 additions and 112 deletions
@@ -0,0 +1,21 @@
open class SetStringImpl {
fun add(s: String): Boolean = false
fun remove(o: Any?): Boolean = false
fun clear(): Unit {}
}
class S : Set<String>, SetStringImpl() {
override fun size(): Int = 0
override fun isEmpty(): Boolean = true
override fun contains(o: Any?): Boolean = false
override fun iterator(): Iterator<String> = null!!
override fun containsAll(c: Collection<Any?>) = false
}
fun box(): String {
val s = S() as MutableSet<String>
s.add("")
s.remove("")
s.clear()
return "OK"
}