The discussion in the sister thread Synthesize constructor for opaque types has prompted me to look again at the problem how to make our top type more parametric. There was a previous thread 3 years ago after which we concluded that things are complicated.
I have now discovered a different solution which keeps the most important parametricity guarantees without running into a lot of complexity and migration headaches. It is described in this PR. See also the associated issue that contains a more complete discussion (if you are interested, you should read the whole comments thread since there was quite a bit of development between the starting thoughts and where we ended up). In short, we need to add a trait
Matchable that is inherited by
AnyRef and that encapsulates the behavior of
isInstanceOf and pattern matching.
The associated warnings that ensure parametricity can be rolled out over the next minor releases of Scala 3. But here’s the catch: This works only if we lay the groundwork now by adding the
Matchable trait. If we do not do that we will likely have to wait several years for the next major version of the language. The problem is that we are now very close to finalizing Scala 3. So for this to go forward we’d need quick and thorough feedback from the community whether this is perceived as an important step forward or whether you think it is irrelevant or a dead end.
Discussions should take place here instead of the PR.