Fixed wrong linearization for open classes and traits.

openList changed during neighbors calculation because the same TLinkable object cannot be put into more than one TLinkedList at the same time.

#KT-3499 fixed
This commit is contained in:
Zalim Bashorov
2013-04-11 18:54:16 +04:00
parent 840a728d26
commit 7680203de2
3 changed files with 20 additions and 1 deletions
@@ -55,6 +55,10 @@ public final class ClassInheritanceTest extends SingleFileTranslationTest {
public void testAbstractVarOverride() throws Exception {
fooBoxTest();
}
public void testKt3499() throws Exception {
fooBoxTest();
}
}
@@ -129,7 +129,7 @@ public final class ClassDeclarationTranslator extends AbstractTranslator {
@NotNull
@Override
public Iterable<FinalListItem> getNeighbors(FinalListItem current) {
TLinkedList<FinalListItem> parents = new TLinkedList<FinalListItem>();
LinkedList<FinalListItem> parents = new LinkedList<FinalListItem>();
ClassDescriptor classDescriptor = getClassDescriptor(context().bindingContext(), current.declaration);
Collection<JetType> superTypes = classDescriptor.getTypeConstructor().getSupertypes();
@@ -147,6 +147,8 @@ public final class ClassDeclarationTranslator extends AbstractTranslator {
}
});
assert sortedOpenClasses.size() == openList.size();
// second pass: generate
Iterator<FinalListItem> it = sortedOpenClasses.descendingIterator();
while (it.hasNext()) {
@@ -0,0 +1,13 @@
package foo
trait A : B, E
trait B
open class C {
fun foo() = true
}
trait D
trait E
trait F : G, D
trait G
fun box() = C().foo()