correct resolving supers of a class directly inside anonymous, when AST is not loaded (EA-84982 - assert: TypeConversionUtil.reportHierarchyInconsistency)

This commit is contained in:
peter
2016-06-30 11:16:53 +02:00
parent 964a06d8a9
commit f98e80544d
2 changed files with 6 additions and 9 deletions
@@ -183,15 +183,7 @@ public class PsiAnonymousClassImpl extends PsiClassImpl implements PsiAnonymousC
@NotNull PsiElement place) {
if (lastParent instanceof PsiExpressionList) return true;
final PsiClassStub stub = getStub();
if (stub != null) {
// no tree is loaded
// that means we could not have come from resolving something inside anonymous class, we just resolving the base class reference
// so skip the (very expensive) getBaseClassReference() call which would load tree
return true;
}
if (lastParent != null/* IMPORTANT: do not call getBaseClassReference() for lastParent == null and lastParent which is not under our node - loads tree!*/
if (lastParent instanceof PsiJavaCodeReferenceElement/* IMPORTANT: do not call getBaseClassReference() for lastParent == null and lastParent which is not under our node - loads tree!*/
&& lastParent.getParent() == this && lastParent == getBaseClassReference()) {
return true;
}
@@ -116,11 +116,14 @@ class A {
Object field = new B() {
void foo(Object o) {
}
class MyInner extends Inner {}
};
}
class B {
void foo(Object o) {}
static class Inner {}
}
""")
assert !file.contentsLoaded
@@ -138,6 +141,8 @@ class B {
assert !file.contentsLoaded
assert bClass == override.containingClass.superClass
assert bClass.innerClasses[0] == override.containingClass.innerClasses[0].superClass
assert !file.contentsLoaded
}
public void "test AST can be gc-ed and recreated"() {