mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
switch expression: inference for result expression fixed; more testdata on overload resolution
This commit is contained in:
+16
@@ -1,11 +1,27 @@
|
||||
import java.util.function.*;
|
||||
class MyTest {
|
||||
<T> T foo(T t) {
|
||||
return t;
|
||||
}
|
||||
<T> T foo(Supplier<T> t) {
|
||||
return t.get();
|
||||
}
|
||||
|
||||
<T> T foo(IntSupplier t) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static <K> K bar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
void m(int i) {
|
||||
String s = foo(switch (i) {default -> "str";});
|
||||
String s1 = <error descr="Incompatible types. Required String but 'foo' was inferred to T:
|
||||
no instance(s) of type variable(s) exist so that Object conforms to String">foo(switch (i) {case 1 -> new Object(); default -> "str";});</error>
|
||||
String s2 = foo(() -> switch (i) {
|
||||
default -> "str";
|
||||
});
|
||||
String s3 = foo(() -> switch (i) {default -> bar();});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user