do not open wildcards accessing elements of array (IDEA-57285)

This commit is contained in:
anna
2013-05-02 17:08:34 +02:00
parent 4d84932b11
commit e3c5d8ec32
3 changed files with 17 additions and 0 deletions

View File

@@ -491,6 +491,10 @@ public class PsiImplUtil {
toplevel = (PsiExpression)toplevel.getParent();
}
if (toplevel instanceof PsiArrayAccessExpression) {
return type;
}
final PsiType normalized = doNormalizeWildcardByPosition(type, expression, toplevel);
LOG.assertTrue(normalized.isValid(), type);
if (normalized instanceof PsiClassType && !PsiUtil.isAccessedForWriting(toplevel)) {

View File

@@ -0,0 +1,12 @@
package pck;
abstract class A<S> {
S y;
void bar(A<? extends int[]> x){
Object obj = <error descr="Array type expected; found: 'capture<? extends int[]>'">x.y</error>[0];
}
void baz(A<? super int[]> x){
Object obj = <error descr="Array type expected; found: 'capture<? super int[]>'">x.y</error>[0];
}
}

View File

@@ -218,6 +218,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA57265(){ doTest5(false); }
public void testIDEA57271(){ doTest5(false); }
public void testIDEA57272(){ doTest5(false); }
public void testIDEA57285(){ doTest5(false); }
public void testIDEA67571(){ doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
public void testWildcardsOnRawTypes() { doTest5(false); }