reigiable local classes inside static methods (IDEA-163615)

This commit is contained in:
Anna.Kozlova
2016-11-07 18:56:11 +01:00
parent 32b5e5fac0
commit 08c5a244c3
2 changed files with 14 additions and 2 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,8 +66,9 @@ public class JavaGenericsUtil {
}
if (aClass != null && !aClass.hasModifierProperty(PsiModifier.STATIC)) {
PsiModifierListOwner enclosingStaticElement = PsiUtil.getEnclosingStaticElement(aClass, aClass.getContainingClass());
PsiClass containingClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class, true);
if (containingClass != null) {
if (containingClass != null && (enclosingStaticElement == null || PsiTreeUtil.isAncestor(enclosingStaticElement, containingClass, false))) {
return isReifiableType(JavaPsiFacade.getElementFactory(aClass.getProject()).createType(containingClass, resolved.getSubstitutor()));
}
}
@@ -10,4 +10,15 @@ class B<T> {
class C {}
return obj instanceof <error descr="Illegal generic type for instanceof">C</error>;
}
static <A> B<A> localClassInStaticMethod() {
class C extends B<A> {
@Override
public boolean equals(Object obj) {
return obj instanceof C;
}
}
return new C();
}
}