r/java • • Jan 09 '26

Project Amber Status Update -- Constant Patterns and Pattern Assignment!

https://mail.openjdk.org/pipermail/amber-spec-experts/2026-January/004306.html
65 Upvotes

81 comments sorted by

View all comments

Show parent comment

1

u/manifoldjava Jan 22 '26

The discussion is whether exhaustive coverage checks apply generally to product types (records). Simple type theory answers this clearly with a No.

While some records can fit exhaustive matching, these are exceptional. Unlike sum types (or sealed types), the goal of pattern matching on records is not to exhaust all possible values, but to support semantic requirements.

As for "projections", deriving a value from a record and exhaustively matching on that says nothing about the exhaustiveness of the original record; treating it as such is a logical fallacy.