mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-04 20:30:42 +07:00
[java-intentions] IDEA-313226. Suggest the correct type for switch. Generics and tests
GitOrigin-RevId: 4814c85fd7721fb7866210825a0d2286c61e2043
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ce216843a0
commit
016ba5fb84
@@ -0,0 +1,22 @@
|
||||
// "Create local variable 'i'" "true-preview"
|
||||
|
||||
class A {
|
||||
String testPattern() {
|
||||
BaseInterface<String> i;
|
||||
return switch (i)
|
||||
{
|
||||
case BaseInterface.Record1<String> record1 -> "1";
|
||||
case BaseInterface.Record2 record2 -> "2";
|
||||
default -> "3";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
sealed interface BaseInterface<T> permits BaseInterface.Record1, BaseInterface.Record2{
|
||||
|
||||
record Record1<T>() implements BaseInterface<T> {
|
||||
}
|
||||
|
||||
record Record2() implements BaseInterface<String> {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// "Create local variable 'i'" "true-preview"
|
||||
|
||||
class A {
|
||||
String testPattern() {
|
||||
return switch (i<caret>)
|
||||
{
|
||||
case BaseInterface.Record1<String> record1 -> "1";
|
||||
case BaseInterface.Record2 record2 -> "2";
|
||||
default -> "3";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
sealed interface BaseInterface<T> permits BaseInterface.Record1, BaseInterface.Record2{
|
||||
|
||||
record Record1<T>() implements BaseInterface<T> {
|
||||
}
|
||||
|
||||
record Record2() implements BaseInterface<String> {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user