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

View File

@@ -0,0 +1,20 @@
import java.lang.*;
import java.util.*;
public class Test {
public static class IterableImpl implements Iterable<String> {
public Iterator<String> iterator() { return new IteratorImpl(); }
}
public static class IteratorImpl implements Iterator<String> {
public boolean hasNext() { return false; }
public String next() { return null; }
public void remove() { }
}
public static class MapEntryImpl implements Map.Entry<String, String> {
public String getKey() { return null; }
public String getValue() { return null; }
public String setValue(String s) { return null; }
}
}

View File

@@ -0,0 +1,19 @@
class MyIterable : Test.IterableImpl()
class MyIterator : Test.IteratorImpl()
class MyMapEntry : Test.MapEntryImpl()
fun box(): String {
MyIterable().iterator()
val a = MyIterator()
a.hasNext()
a.next()
a.remove()
val b = MyMapEntry()
b.getKey()
b.getValue()
b.setValue(null)
return "OK"
}