Predict boolean type for 'when' expression of switch pattern

IDEA-274106

GitOrigin-RevId: 3f41806bc5eceea7efa2c10bc149f231b4d42262
This commit is contained in:
Andrey Cherkasov
2022-11-07 05:17:27 +04:00
committed by intellij-monorepo-bot
parent 2f7a5590b8
commit 4bbd7cf012
13 changed files with 137 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
// "Create method 'isEmpty' in 'Main'" "true-preview"
class Main {
void foo(Object obj) {
switch (obj) {
case String s && isEmpty(s) -> {}
default -> {}
}
}
private boolean isEmpty(String s) {
return false;
}
}

View File

@@ -0,0 +1,13 @@
// "Create method 'isEmpty' in 'Main'" "true-preview"
class Main {
void foo(Object obj) {
switch (obj) {
case String s when isEmpty(s) -> {}
default -> {}
}
}
private boolean isEmpty(String s) {
return false;
}
}

View File

@@ -0,0 +1,9 @@
// "Create method 'isEmpty' in 'Main'" "true-preview"
class Main {
void foo(Object obj) {
switch (obj) {
case String s && isEmpt<caret>y(s) -> {}
default -> {}
}
}
}

View File

@@ -0,0 +1,9 @@
// "Create method 'isEmpty' in 'Main'" "true-preview"
class Main {
void foo(Object obj) {
switch (obj) {
case String s when isEmpt<caret>y(s) -> {}
default -> {}
}
}
}