do not erasure methods from non generics super types of raw types (IDEA-129646)

This commit is contained in:
Anna Kozlova
2014-09-18 15:02:23 +04:00
parent a6b194f5e6
commit 38087e7f3b
3 changed files with 43 additions and 3 deletions
@@ -604,9 +604,15 @@ public class PsiClassImplUtil {
@NotNull PsiElementFactory factory,
@NotNull PsiMethod candidateMethod,
@NotNull PsiSubstitutor substitutor) {
if (isRaw && !candidateMethod.hasModifierProperty(PsiModifier.STATIC)) { //static methods are not erased due to raw overriding
PsiTypeParameter[] methodTypeParameters = candidateMethod.getTypeParameters();
substitutor = factory.createRawSubstitutor(substitutor, methodTypeParameters);
//4.8-2. Raw Types and Inheritance
//certain members of a raw type are not erased,
//namely static members whose types are parameterized, and members inherited from a non-generic supertype.
if (isRaw && !candidateMethod.hasModifierProperty(PsiModifier.STATIC)) {
final PsiClass containingClass = candidateMethod.getContainingClass();
if (containingClass != null && containingClass.hasTypeParameters()) {
PsiTypeParameter[] methodTypeParameters = candidateMethod.getTypeParameters();
substitutor = factory.createRawSubstitutor(substitutor, methodTypeParameters);
}
}
return substitutor;
}
@@ -0,0 +1,30 @@
interface IRequestablePage {}
abstract class Page implements IRequestablePage {}
abstract class BTest {
public final <C extends IRequestablePage> void setResponsePage(final Class<C> cls) {}
public final <C extends IRequestablePage> void setResponsePage(final Class<C> cls, int i) {}
public abstract Class<? extends Page> getHomePage();
{
setResponsePage(getHomePage());
}
public BTest(Class<? extends Page> homePage) {
ALink link = new ALink() {
{
setResponsePage(homePage);
}
};
}
}
class ALink<T> extends BTest {
public ALink() {
super(null);
}
@Override
public Class<? extends Page> getHomePage() {
return null;
}
}
@@ -239,6 +239,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
doTest();
}
public void testCallToGenericMethodsOfNonGenericClassInsideRawInheritor() throws Exception {
doTest();
}
private void doTest() throws Exception {
doTest(false);
}