mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-05 08:06:56 +07:00
[java-completion] IDEA-355252 Don't suggest deconstruction with incorrect name
GitOrigin-RevId: 9bdb1273f507054c479eaa86597eadaf4568a9dd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fc86f137ca
commit
73bbc5d00d
@@ -0,0 +1,23 @@
|
||||
// "Create missing branches: 'Pair(A sc2, B sc3)', and 'Pair(B sc2, A sc3)'" "true-preview"
|
||||
record Pair(SC sc1, SC sc2) {
|
||||
|
||||
}
|
||||
|
||||
sealed interface SC{}
|
||||
final class A implements SC{}
|
||||
final class B implements SC{}
|
||||
|
||||
class Test {
|
||||
|
||||
void foo1(Pair o) {
|
||||
int sc1 = 1;
|
||||
switch (o) {
|
||||
case Pair(A sc3, A sc2) -> System.out.println("1");
|
||||
case Pair(B sc3, B sc2) -> System.out.println("1");
|
||||
case Pair(A sc2, B sc3) -> {
|
||||
}
|
||||
case Pair(B sc2, A sc3) -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Create missing branches: 'Pair(A sc2, B sc3)', and 'Pair(B sc2, A sc3)'" "true-preview"
|
||||
record Pair(SC sc1, SC sc2) {
|
||||
|
||||
}
|
||||
|
||||
sealed interface SC{}
|
||||
final class A implements SC{}
|
||||
final class B implements SC{}
|
||||
|
||||
class Test {
|
||||
|
||||
void foo1(Pair o) {
|
||||
int sc1 = 1;
|
||||
switch (o<caret>) {
|
||||
case Pair(A sc3, A sc2) -> System.out.println("1");
|
||||
case Pair(B sc3, B sc2) -> System.out.println("1");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,6 +317,29 @@ public class NormalPatternsCompletionTest extends NormalCompletionTestCase {
|
||||
}""");
|
||||
}
|
||||
|
||||
@NeedsIndex.Full
|
||||
public void testHasTheSameName() {
|
||||
myFixture.configureByText("a.java", """
|
||||
record Point(int x1, int x2);
|
||||
class X {
|
||||
void test(Object o) {
|
||||
int x1 = 0;
|
||||
if(o instanceof Point(<caret>)
|
||||
}
|
||||
}""");
|
||||
myFixture.completeBasic();
|
||||
selectItem(0);
|
||||
myFixture.checkResult(
|
||||
"""
|
||||
record Point(int x1, int x2);
|
||||
class X {
|
||||
void test(Object o) {
|
||||
int x1 = 0;
|
||||
if(o instanceof Point(int x2, int x3)
|
||||
}
|
||||
}""");
|
||||
}
|
||||
|
||||
private void selectItem(int index) {
|
||||
LookupElement[] elements = myFixture.getLookupElements();
|
||||
assertNotNull(elements);
|
||||
|
||||
Reference in New Issue
Block a user