forbid diamonds on non-parameterized types (javac should be fixed accordingly)

This commit is contained in:
anna
2011-02-21 18:36:16 +01:00
parent 2c27958238
commit 67c44e47df
2 changed files with 9 additions and 0 deletions
@@ -112,6 +112,9 @@ public class GenericsHighlightUtil {
if (referenceParameterList != null) {
referenceElements = referenceParameterList.getTypeParameterElements();
if (referenceElements.length == 1 && referenceElements[0].getType() instanceof PsiDiamondType) {
if (!typeParameterListOwner.hasTypeParameters()) {
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, referenceElements[0], "Diamond operator is not applicable for non-parameterized types");
}
inferenceResult = ((PsiDiamondType)referenceElements[0].getType()).resolveInferredTypes();
final String errorMessage = inferenceResult.getErrorMessage();
if (errorMessage != null) {
@@ -67,3 +67,9 @@ class MyTest {
}
}
}
class NonParameterized {
void foo() {
new NonParameterized<<error descr="Diamond operator is not applicable for non-parameterized types"></error>>();
}
}