Implementation of SIP-67: better pattern matching with `strictEquality`
Closed this issue · 4 comments
Hi there,
Since my SIP about pattern matching with strictEquality was recently accepted, the time has come to implement it.
I'd love to help out with that, but I don't know anything about the dotty internals, so I'm going to need some guidance. @soronpo has suggested that I open an issue about this, so here we are. What would be a good place to start?
I'd love to help out with that, but I don't know anything about the dotty internals, so I'm going to need some guidance. @soronpo has suggested that I open an issue about this, so here we are. What would be a good place to start?
@noti0na1 @KacperFKorban can you help @mberndt123 get started?
Also, as for getting familiar with compiler internals, @mberndt123 maybe you could join the next Scala Issue Spree?
I believe we'll have one next week (17.03.2025).
cc @mbovel
Hi @mberndt123, feel free to ask any question related to the implementation!
For pattern matching, there are two important files:
PatternMatcher.scala: it transforms Match nodes into simple switchs;Space.scala: it checks exhaustivity and unreachability.
You can also ask @dwijnand who is an expert in this field.
I think taking this on during an issue spree is best to get started at least.
I think the implementation might be to add the conditions from the sip:
- the pattern is a `case object` that extends the scrutinee's type, or
- the pattern is an `enum case` without a parameter list (e. g. `Nat.Zero`) and the scrutinee has that `enum` type (or a supertype thereof)
(along with the implied strictEquality check) around the typedExpr call in checkEqualityEvidence, which is only called when checking equality calls in patterns. We do keep the warnOnImplausiblePattern check though.