-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[21][pattern switch] ParameterizedType in Exhaustive check not done. #587
Milestone
Comments
@mpalat, @jarthana: I just re-tested this on JDK 20 and the current batch compiler after the Java 20 merge to the main branch. This issue is still unresolved. Javcac 20 compiles it fine, ECJ does not. Again, the code I just compiled with both compilers: /**
* Inspired by examples in https://openjdk.org/jeps/427
*/
public class SwitchPatternPreview4OK {
/**
* According to an example from JEP 420, this should work with preview 2 (Java 18), and it does with Javac,
* but not with ECJ for Java 18, 19 and 20.
*
* See:
* https://openjdk.java.net/jeps/420#2--Exhaustiveness-of-switch-expressions-and-statements
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=579360
* https://github.com/eclipse-jdt/eclipse.jdt.core/issues/587
*
* TODO: reactivate when implemented or move to preview 5 with Java 21.
*/
sealed interface I<T> permits D, E {}
final static class D<X> implements I<String> {}
final static class E<Y> implements I<Y> {}
static int testGenericSealedExhaustive(I<Integer> i) {
return switch (i) {
// Exhaustive as no D case possible!
case E<Integer> bi -> 42;
};
}
} |
7 tasks
mpalat
changed the title
[pattern switch] recursive exhaustiveness not determined
[pattern switch] ParameterizedType in Exhaustive check not done.
Aug 16, 2023
mpalat
added a commit
to mpalat/eclipse.jdt.core
that referenced
this issue
Aug 16, 2023
3 tasks
mpalat
changed the title
[pattern switch] ParameterizedType in Exhaustive check not done.
[21][pattern switch] ParameterizedType in Exhaustive check not done.
Aug 16, 2023
mpalat
added a commit
that referenced
this issue
Aug 16, 2023
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reproduced from https://bugs.eclipse.org/bugs/show_bug.cgi?id=579360
from Alexander Kriegisch - reproduced verbatim:
From bug 576746 comment 5
public class SwitchPatternPreview2OK {
sealed interface I permits A, B {}
final static class A implements I {}
final static class B implements I {}
static int testGenericSealedExhaustive(I i) {
return switch (i) {
// Exhaustive as no A case possible!
case B bi -> 42;
};
}
}
$ java -jar org.eclipse.jdt.core/target/org.eclipse.jdt.core-3.29.50-SNAPSHOT-batch-compiler.jar -18 --enable-preview ../AspectJ/tests/features199/java18/SwitchPatternPreview2OK.java
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
sealed interface I permits A, B {}
^
SwitchPatternPreview2OK.A is a raw type. References to generic type SwitchPatternPreview2OK.A should be parameterized
sealed interface I permits A, B {}
^
SwitchPatternPreview2OK.B is a raw type. References to generic type SwitchPatternPreview2OK.B should be parameterized
return switch (i) {
^
A switch expression should have a default case
// Exhaustive as no A case possible!
case B bi -> 42;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You are using a preview language feature that may or may not be supported in a future release
4 problems (1 error, 3 warnings)
So it seems as if the improved exhaustiveness logic has not been implemented yet either.
The text was updated successfully, but these errors were encountered: