mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not erasure methods from non generics super types of raw types (IDEA-129646)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
+30
@@ -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;
|
||||
}
|
||||
}
|
||||
+4
@@ -239,6 +239,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCallToGenericMethodsOfNonGenericClassInsideRawInheritor() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user