mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
java error tooltips: highlight type arguments according to TypeConversionUtil#isAssigned (IDEA-94965)
GitOrigin-RevId: db456a719c885e055a5a1bd379a63120aeba1aee
This commit is contained in:
committed by
intellij-monorepo-bot
parent
97e799fdaa
commit
9f6014adfc
@@ -2832,7 +2832,10 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
PsiTypeParameter rTypeParameter = i >= rTypeParams.length ? null : rTypeParams[i];
|
||||
PsiType lSubstitutedType = lTypeParameter == null ? null : lTypeData.third.substitute(lTypeParameter);
|
||||
PsiType rSubstitutedType = rTypeParameter == null ? null : rTypeData.third.substitute(rTypeParameter);
|
||||
boolean matches = Comparing.equal(lSubstitutedType, rSubstitutedType);
|
||||
boolean matches = lSubstitutedType == rSubstitutedType ||
|
||||
lSubstitutedType != null &&
|
||||
rSubstitutedType != null &&
|
||||
TypeConversionUtil.typesAgree(lSubstitutedType, rSubstitutedType, true);
|
||||
String openBrace = i == 0 ? "<" : "";
|
||||
String closeBrace = i == typeParamColumns - 1 ? ">" : ",";
|
||||
requiredRow.append("<td>").append(lTypeParams.length == 0 ? "" : openBrace).append(redIfNotMatch(lSubstitutedType, matches))
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class MyTest {
|
||||
void subject(Generic<? extends Number, Number, Integer> pSuper,
|
||||
Generic<Integer, Integer, Integer> pSub) {
|
||||
<error descr="Incompatible types. Found: 'Generic<java.lang.Integer,java.lang.Integer,java.lang.Integer>', required: 'Generic<? extends java.lang.Number,java.lang.Number,java.lang.Integer>'">pSuper = pSub</error>;
|
||||
}
|
||||
}
|
||||
class Generic<U, V, W> {}
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.java.codeInsight.daemon.lambda;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
|
||||
@@ -26,6 +27,7 @@ import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Assert;
|
||||
|
||||
//javac option to dump bounds: -XDdumpInferenceGraphsTo=
|
||||
public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
@@ -1039,6 +1041,20 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTooltipTypesAgree() {
|
||||
doTest();
|
||||
doHighlighting()
|
||||
.stream()
|
||||
.filter(info -> info.type == HighlightInfoType.ERROR)
|
||||
.forEach(info -> Assert.assertEquals("<html><body>Incompatible types." +
|
||||
"<table><tr><td>Required:</td>" +
|
||||
"<td>Generic</td><td><? extends Number,</td><td><font color='red'><b>java.lang.Number</b></font>,</td><td>Integer></td></tr>" +
|
||||
"<tr><td>Found:</td>" +
|
||||
"<td>Generic</td><td><Integer,</td><td><font color='red'><b>java.lang.Integer</b></font>,</td><td>Integer></td></tr>" +
|
||||
"</table></body></html>",
|
||||
info.getToolTip()));
|
||||
}
|
||||
|
||||
public void testBridgeMethodOverriding() { doTest(); }
|
||||
public void testNestedWildcardsWithImplicitBounds() { doTest(); }
|
||||
public void testCallOnRawWithExplicitTypeArguments() { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user