mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
switch expressions: report bad result expression types
if they are not convertible to poly expression target type
This commit is contained in:
+7
-1
@@ -26,9 +26,15 @@ no instance(s) of type variable(s) exist so that Object conforms to String">foo(
|
||||
String s4 = foo(() -> switch (i) {default -> { break bar();}});
|
||||
String s5 = foo(<error descr="Incompatible types. Required String but 'foo' was inferred to T:
|
||||
no instance(s) of type variable(s) exist so that Integer conforms to String">() -> switch (i) {default -> { break 1;}}</error>);
|
||||
String s6 = switch (i) {
|
||||
case 1 -> <error descr="Bad type in switch expression: int cannot be converted to java.lang.String">2</error>;
|
||||
default -> {
|
||||
break <error descr="Bad type in switch expression: int cannot be converted to java.lang.String">1</error>;
|
||||
}
|
||||
};
|
||||
Supplier<String> stringSupplier = switch (i) {
|
||||
default -> {
|
||||
break () -> <error descr="Bad return type in lambda expression: int cannot be converted to String">1</error>;
|
||||
break () -> <error descr="Bad return type in lambda expression: int cannot be converted to String">1</error>;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user