# Pre-SIP: better strictEquality support in pattern matching

**URL:** <https://contributors.scala-lang.org/t/pre-sip-better-strictequality-support-in-pattern-matching/6781>\
**Category:** Scala Improvement Process\
**Created:** [October 3, 2024, 3:16pm UTC](https://contributors.scala-lang.org/t/pre-sip-better-strictequality-support-in-pattern-matching/6781 "2024-10-03T15:16:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mberndt](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/m/d9b06d/32.png) [@mberndt](https://contributors.scala-lang.org/u/mberndt)\
**Post date:** [October 3, 2024, 3:16pm UTC](https://contributors.scala-lang.org/t/pre-sip-better-strictequality-support-in-pattern-matching/6781/1 "2024-10-03T15:16:00Z")

</div>

Hey there, Happy German Unity Day (October 3rd) to everybody.

I’ve written a SIP draft on how to improve pattern matching to make it more practical in code bases compiled with the `strictEquality` feature.

> <https://github.com/mberndt123/improvement-proposals/blob/strictEquality-pattern-matching/content/strict-equality-pattern-matching.md>

I’ve worked on multiple projects where I would have liked to enable `strictEquality` for the improved type safety that it provides, but without exception, this failed due to compilation errors for basic ADT pattern matching.  
It’s time to fix it and I welcome any constructive feedback.

---

<div class="post-metadata">

**Author:** ![soronpo](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/soronpo/32/533_2.png) [@soronpo](https://contributors.scala-lang.org/u/soronpo)\
**Post date:** [October 3, 2024, 6:04pm UTC](https://contributors.scala-lang.org/t/pre-sip-better-strictequality-support-in-pattern-matching/6781/2 "2024-10-03T18:04:50Z")

</div>

I suggest you add links to previous discussions:

> [@Enumeration does not derive \`CanEqual\` for \`strictEquality\`](https://contributors.scala-lang.org/t/enumeration-does-not-derive-canequal-for-strictequality/5280):
>
> What is the reason enumeration does not derive CanEqual? It was very surprising that this is not the default case, which led me to submit the following issue: However, only after I noticed that the test cases explicitly check the interaction of enums and strictEquality, I understood that this is an intended design decision.

---

<div class="post-metadata">

**Author:** ![mberndt](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/m/d9b06d/32.png) [@mberndt](https://contributors.scala-lang.org/u/mberndt)\
**Post date:** [October 3, 2024, 8:41pm UTC](https://contributors.scala-lang.org/t/pre-sip-better-strictequality-support-in-pattern-matching/6781/3 "2024-10-03T20:41:22Z")

</div>

Thanks @soronpo, I’ve added links to related discussions (including this thread) in the Related Work section of the SIP draft.

---

<div class="post-metadata">

**Author:** ![Sporarum](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/sporarum/32/2545_2.png) [@Sporarum](https://contributors.scala-lang.org/u/Sporarum)\
**Post date:** [October 4, 2024, 9:22am UTC](https://contributors.scala-lang.org/t/pre-sip-better-strictequality-support-in-pattern-matching/6781/4 "2024-10-04T09:22:20Z")

</div>

I’d like a bit more discussion on the differences between changing the desugarring to `_ : MyObject.type` and not requiring the `Equals` instance

(I don’t have any opinions on the matter, but it should be presented in the SIP)

---

<div class="post-metadata">

**Author:** ![mberndt](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/m/d9b06d/32.png) [@mberndt](https://contributors.scala-lang.org/u/mberndt)\
**Post date:** [October 4, 2024, 10:20am UTC](https://contributors.scala-lang.org/t/pre-sip-better-strictequality-support-in-pattern-matching/6781/5 "2024-10-04T10:20:23Z")

</div>

> [@Sporarum](#):
>
> I’d like a bit more discussion on the differences between changing the desugarring to `_ : MyObject.type` and not requiring the `Equals` instance

Thanks @Sporarum, I’ve added a paragraph in the Alternatives section explaining the pros and cons of this approach. tldr: benefits of the type check behaviour are marginal, backward compat matters more. But please feel free to point out any benefits (or drawbacks) that I may have missed.

---

<div class="post-metadata">

**Author:** ![Sporarum](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/sporarum/32/2545_2.png) [@Sporarum](https://contributors.scala-lang.org/u/Sporarum)\
**Post date:** [October 5, 2024, 11:52am UTC](https://contributors.scala-lang.org/t/pre-sip-better-strictequality-support-in-pattern-matching/6781/6 "2024-10-05T11:52:34Z")

</div>

Perfect, that’s what I would have expected as well, so not I can’t think of anything else ^^

---

<div class="post-metadata">

**Author:** ![mberndt](https://contributors.scala-lang.org/letter_avatar_proxy/v4/letter/m/d9b06d/32.png) [@mberndt](https://contributors.scala-lang.org/u/mberndt)\
**Post date:** [October 21, 2024, 9:45am UTC](https://contributors.scala-lang.org/t/pre-sip-better-strictequality-support-in-pattern-matching/6781/7 "2024-10-21T09:45:11Z")

</div>

Since there have been no further comments for the past two weeks, I’ve decided to submit this to the committee.  
Thanks to everyone for participating.

> <https://github.com/scala/improvement-proposals/pull/97>
>
> Hi there,
> 
> I'd like to use the \`strictEquality\` feature for the improved type …safety it provides, but currently find it too inconvenient to use due to an unfortunate interaction with pattern matching. This SIP is my attempt to fix that.
> There have been no comments in the \[Pre-SIP thread\](https://contributors.scala-lang.org/t/pre-sip-better-strictequality-support-in-pattern-matching/6781/6) for the past two weeks, and it's a very small (though impactful) change to the language, so I felt it was time to submit it.
> 
> Best regards
> Matthias

---

<div class="post-metadata">

**Author:** ![soronpo](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/soronpo/32/533_2.png) [@soronpo](https://contributors.scala-lang.org/u/soronpo)\
**Post date:** [February 21, 2025, 4:23pm UTC](https://contributors.scala-lang.org/t/pre-sip-better-strictequality-support-in-pattern-matching/6781/8 "2025-02-21T16:23:38Z")

</div>

**Update**  
This SIP has been accepted to move into the implementation stage. Congrats @mberndt !

Is there anyone who wishes to volunteer to implement it?

---

<div class="post-metadata">

**Author:** ![soronpo](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/soronpo/32/533_2.png) [@soronpo](https://contributors.scala-lang.org/u/soronpo)\
**Post date:** [June 26, 2026, 5:45pm UTC](https://contributors.scala-lang.org/t/pre-sip-better-strictequality-support-in-pattern-matching/6781/9 "2026-06-26T17:45:19Z")

</div>

This SIP was accepted to be shipped as a stable feature. Congrats @mberndt !
