compound assignment: allow assignment to string super types (IDEA-238812)

GitOrigin-RevId: 56d7dd94bc8e1b728aef2c59a54bee76ad43df74
This commit is contained in:
Anna Kozlova
2020-04-29 08:18:44 +02:00
committed by intellij-monorepo-bot
parent 00a0067a26
commit 09d57e4993
2 changed files with 8 additions and 2 deletions

View File

@@ -551,8 +551,10 @@ public class TypeConversionUtil {
resultTypeRank = STRING_RANK;
}
else if (rtype.equalsToText(JAVA_LANG_STRING)) {
isApplicable = !isVoidType(ltype);
resultTypeRank = STRING_RANK;
if (isVoidType(ltype)) {
return false;
}
return !strict || ltype.isAssignableFrom(rtype);
}
else if (isPrimitiveAndNotNullOrWrapper(ltype) && isPrimitiveAndNotNullOrWrapper(rtype)) {
resultTypeRank = Math.max(ltypeRank, rtypeRank);

View File

@@ -3,5 +3,9 @@ class Test {
Object o = "";
<warning descr="Operator '+' cannot be applied to 'java.lang.Object', 'java.lang.String'">o += ""</warning>;
System.out.println(o);
CharSequence c = "";
c += "";
System.out.println(c);
}
}