mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-63698 (Inconvertible type (assign double to Integer) not highlighted as error)
This commit is contained in:
+14
-4
@@ -361,7 +361,6 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo checkAssignmentCompatibleTypes(@NotNull PsiAssignmentExpression assignment) {
|
||||
if (!"=".equals(assignment.getOperationSign().getText())) return null;
|
||||
PsiExpression lExpr = assignment.getLExpression();
|
||||
PsiExpression rExpr = assignment.getRExpression();
|
||||
if (rExpr == null) return null;
|
||||
@@ -369,16 +368,27 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
PsiType rType = rExpr.getType();
|
||||
if (rType == null) return null;
|
||||
|
||||
HighlightInfo highlightInfo = checkAssignability(lType, rType, rExpr, assignment);
|
||||
final IElementType sign = assignment.getOperationTokenType();
|
||||
HighlightInfo highlightInfo;
|
||||
if (JavaTokenType.EQ.equals(sign)) {
|
||||
highlightInfo = checkAssignability(lType, rType, rExpr, assignment);
|
||||
}
|
||||
else {
|
||||
// 15.26.2. Compound Assignment Operators
|
||||
final IElementType opSign = TypeConversionUtil.convertEQtoOperation(sign);
|
||||
final PsiType type = TypeConversionUtil.calcTypeForBinaryExpression(lType, rType, opSign, true);
|
||||
if (type == null || lType == null || TypeConversionUtil.areTypesConvertible(type, lType)) {
|
||||
return null;
|
||||
}
|
||||
highlightInfo = createIncompatibleTypeHighlightInfo(lType, type, assignment.getTextRange(), 0);
|
||||
}
|
||||
if (highlightInfo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
registerChangeVariableTypeFixes(lExpr, rType, highlightInfo);
|
||||
if (lType != null) {
|
||||
registerChangeVariableTypeFixes(rExpr, lType, highlightInfo);
|
||||
}
|
||||
|
||||
return highlightInfo;
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -42,5 +42,9 @@ public class a {
|
||||
int i1='d';
|
||||
<error descr="Incompatible types. Found: 'long', required: 'int'">int i2 = 1L;</error>
|
||||
|
||||
Integer destination = 25;
|
||||
<error descr="Incompatible types. Found: 'double', required: 'java.lang.Integer'">destination += 2.0</error>;
|
||||
Byte b = 1;
|
||||
<error descr="Incompatible types. Found: 'int', required: 'java.lang.Byte'">b -= 1</error>;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -119,7 +119,7 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testAssignToFinal() { doTest(false, false); }
|
||||
public void testUnhandledExceptionsInSuperclass() { doTest(false, false); }
|
||||
public void testNoUnhandledExceptionsMultipleInheritance() { doTest(false, false); }
|
||||
public void testAssignmentCompatible () { doTest(false, false); }
|
||||
public void testAssignmentCompatible () { setLanguageLevel(LanguageLevel.JDK_1_5); doTest(false, false); }
|
||||
public void testMustBeBoolean() { doTest(false, false); }
|
||||
|
||||
public void testNumericLiterals() { doTest(false, false); }
|
||||
|
||||
Reference in New Issue
Block a user