mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
diamonds: should check raw types when error occurs before inference is even started (IDEA-74053)
This commit is contained in:
+5
-5
@@ -121,11 +121,11 @@ public class GenericsHighlightUtil {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, referenceElements[0], "Diamond operator is not applicable for non-parameterized types");
|
||||
}
|
||||
inferenceResult = ((PsiDiamondType)referenceElements[0].getType()).resolveInferredTypes();
|
||||
final PsiType expectedType = detectExpectedType(referenceParameterList);
|
||||
if (!(expectedType instanceof PsiClassType && ((PsiClassType)expectedType).isRaw())) {
|
||||
final String errorMessage = inferenceResult.getErrorMessage();
|
||||
if (errorMessage != null) {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, referenceElements[0], errorMessage);
|
||||
final String errorMessage = inferenceResult.getErrorMessage();
|
||||
if (errorMessage != null) {
|
||||
final PsiType expectedType = detectExpectedType(referenceParameterList);
|
||||
if (!(inferenceResult.failedToInfer() && expectedType instanceof PsiClassType && ((PsiClassType)expectedType).isRaw())) {
|
||||
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, referenceElements[0], errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-1
@@ -171,4 +171,13 @@ class TestWildcardInference {
|
||||
A<? extends Number> y = new B<>(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PredefinedErrorsOverRaw<T> {
|
||||
<U> PredefinedErrorsOverRaw(T t) {
|
||||
}
|
||||
|
||||
void test() {
|
||||
PredefinedErrorsOverRaw mc = new <Boolean>PredefinedErrorsOverRaw<<error descr="Cannot use diamonds with explicit type parameters for constructor"></error>>("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,6 +313,10 @@ public class PsiDiamondType extends PsiType {
|
||||
public String getErrorMessage() {
|
||||
return myErrorMessage;
|
||||
}
|
||||
|
||||
public boolean failedToInfer() {
|
||||
return myErrorMessage != null;
|
||||
}
|
||||
|
||||
public void addInferredType(PsiType psiType) {
|
||||
if (myErrorMessage != null) return;
|
||||
|
||||
Reference in New Issue
Block a user