mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] switch expressions: allow null label with any non-primitive type (IDEA-282339)
GitOrigin-RevId: d6438daeba88dc37ec34509e331394a87cf1cd8d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c58089fa4d
commit
2aa9ed116e
+1
-1
@@ -452,7 +452,7 @@ public class SwitchBlockHighlightingModel {
|
||||
private HighlightInfo checkLabelAndSelectorCompatibility(@NotNull PsiCaseLabelElement label) {
|
||||
if (label instanceof PsiDefaultCaseLabelElement) return null;
|
||||
if (isNullType(label)) {
|
||||
if (!(mySelectorType instanceof PsiClassType) && !isNullType(mySelector)) {
|
||||
if (mySelectorType instanceof PsiPrimitiveType && !isNullType(mySelector)) {
|
||||
return createError(label, JavaErrorBundle.message("incompatible.switch.null.type", "null",
|
||||
JavaHighlightUtil.formatType(mySelectorType)));
|
||||
}
|
||||
|
||||
+12
@@ -183,6 +183,18 @@ class Main {
|
||||
case ((((<error descr="'java.util.List<capture<? extends java.lang.Number>>' cannot be safely cast to 'java.util.List<java.lang.Integer>'">List<Integer> l</error>)) && Math.random() > 0.5)):
|
||||
break;
|
||||
}
|
||||
|
||||
switch (list1.get(0)) {
|
||||
case null: {}
|
||||
default: {}
|
||||
}
|
||||
|
||||
switch (new int[0]) {
|
||||
case null: {}
|
||||
default: {}
|
||||
}
|
||||
|
||||
|
||||
switch (list2) {
|
||||
case List<? extends Number> l:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user