Add patterns module: pattern matching from JDK 21 to 27
Type, record and primitive patterns, guards, sealed exhaustiveness, MatchException via separate compilation, and eight captured transcripts. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TF9JWFvJSNm6HVzswzZU5a
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
$ javac src/SealedExhaustive.java && java SealedExhaustive (21.0.10+7-Ubuntu-124.04)
|
||||
Circle[r=1.0] -> 3.14
|
||||
Square[side=2.0] -> 4.00
|
||||
Rect[w=2.0, h=3.0] -> 6.00
|
||||
|
||||
$ javac src/SealedExhaustive.java && java SealedExhaustive (25.0.4.1+1-LTS)
|
||||
Circle[r=1.0] -> 3.14
|
||||
Square[side=2.0] -> 4.00
|
||||
Rect[w=2.0, h=3.0] -> 6.00
|
||||
|
||||
$ javac src/SealedExhaustive.java && java SealedExhaustive (27+35)
|
||||
Circle[r=1.0] -> 3.14
|
||||
Square[side=2.0] -> 4.00
|
||||
Rect[w=2.0, h=3.0] -> 6.00
|
||||
|
||||
$ javac broken/NotExhaustive.java (21.0.10+7-Ubuntu-124.04)
|
||||
broken/NotExhaustive.java:8: error: the switch expression does not cover all possible input values
|
||||
return switch (s) {
|
||||
^
|
||||
1 error
|
||||
|
||||
$ javac broken/NotExhaustive.java (25.0.4.1+1-LTS)
|
||||
broken/NotExhaustive.java:8: error: the switch expression does not cover all possible input values
|
||||
return switch (s) {
|
||||
^
|
||||
1 error
|
||||
|
||||
$ javac broken/NotExhaustive.java (27+35)
|
||||
broken/NotExhaustive.java:8: error: the switch expression does not cover all possible input values
|
||||
return switch (s) {
|
||||
^
|
||||
missing patterns:
|
||||
Rect _
|
||||
1 error
|
||||
|
||||
$ javac broken/NotExhaustiveObject.java (21.0.10+7-Ubuntu-124.04)
|
||||
broken/NotExhaustiveObject.java:3: error: the switch expression does not cover all possible input values
|
||||
return switch (o) {
|
||||
^
|
||||
1 error
|
||||
|
||||
$ javac broken/NotExhaustiveObject.java (25.0.4.1+1-LTS)
|
||||
broken/NotExhaustiveObject.java:3: error: the switch expression does not cover all possible input values
|
||||
return switch (o) {
|
||||
^
|
||||
1 error
|
||||
|
||||
$ javac broken/NotExhaustiveObject.java (27+35)
|
||||
broken/NotExhaustiveObject.java:3: error: the switch expression does not cover all possible input values
|
||||
return switch (o) {
|
||||
^
|
||||
missing patterns:
|
||||
Object _
|
||||
1 error
|
||||
Reference in New Issue
Block a user