eclipse-jdt / eclipse-jdt/eclipse.jdt.core

[content assist] Ordering in the completion list is not as expected

Open
#347 2 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

@SuppressWarnings("preview")public class X {
public static void print(Object p) {
if (p instanceof Pair(Student(Object n1, int i), Teacher(Object n)) p1) {
System.out.println(n); // Remove n and try to get proposals println is listed in top list
}
}
public static void main(String[] args) {
print(new Pair( new Student("abc", 15), new Teacher("123")));
print(new Pair( new Teacher("123"), new Student("abc", 1)));
}
}
sealed interface Person permits Student, Teacher {
String name();
}
record Student(String name, int id) implements Person {}
record Teacher(String name) implements Person {}
record Pair(Person s, Person s1) {}

Remove n and try to get proposals for , println is listed in top list
Where as in similar case gives expected order:
public static void printLowerRight(Rectangle r) {
int res = switch(r) {
case Rectangle(ColoredPoint(Point(int x, int y), Color c),
ColoredPoint lr) r1 when x > 1 -> {
System.out.println("one" + ); // try to get proposals
yield x;
}
case Rectangle(ColoredPoint(Point(int x, int y), Color c),
ColoredPoint lr) r1 when x <= 0 -> {
System.out.println("two");
yield x;
}
default -> 0;
};
System.out.println("Returns: " + res);
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.