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:
@@ -55,6 +55,10 @@ public final class ClassInheritanceTest extends SingleFileTranslationTest {
|
|||||||
public void testAbstractVarOverride() throws Exception {
|
public void testAbstractVarOverride() throws Exception {
|
||||||
fooBoxTest();
|
fooBoxTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKt3499() throws Exception {
|
||||||
|
fooBoxTest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -129,7 +129,7 @@ public final class ClassDeclarationTranslator extends AbstractTranslator {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Iterable<FinalListItem> getNeighbors(FinalListItem current) {
|
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);
|
ClassDescriptor classDescriptor = getClassDescriptor(context().bindingContext(), current.declaration);
|
||||||
Collection<JetType> superTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
Collection<JetType> superTypes = classDescriptor.getTypeConstructor().getSupertypes();
|
||||||
|
|
||||||
@@ -147,6 +147,8 @@ public final class ClassDeclarationTranslator extends AbstractTranslator {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
assert sortedOpenClasses.size() == openList.size();
|
||||||
|
|
||||||
// second pass: generate
|
// second pass: generate
|
||||||
Iterator<FinalListItem> it = sortedOpenClasses.descendingIterator();
|
Iterator<FinalListItem> it = sortedOpenClasses.descendingIterator();
|
||||||
while (it.hasNext()) {
|
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()
|
||||||
Reference in New Issue
Block a user