Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport] Under -Xsource:2.13, don't GLB binders of type patterns, use the type directly #10298

Merged
merged 1 commit into from Feb 13, 2023

Conversation

lrytz
Copy link
Member

@lrytz lrytz commented Feb 6, 2023

Backport of #10247 under -Xsource:2.13.

In type patterns `c match { case x: T }`, the translation would assign
the GLB of `c`'s type and `T` to the varaible `x`.

This seems to trace back to the first version of the "virtual pattern
matcher". I could not find a similar use of `glb` in that revision
of the codebase. So I'm not sure if it was a new addition, or picked
up from the previous implementation.

https://github.com/scala/scala/blob/8a9fd64129926eea35f7dca181242855f14e153f/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala#L438-L440

In the test case, the GLB collapsed to `Null` because its
computation failed (combination of f-bounds, existentials, skolems that
I don't follow), see `throw GlbFailure`. This is how it's been for 14
years (b894f80). This resulted in a cast to `Null$` failing at
runtime.

I assume GLB is fixed in Scala 3, as this core of the type system has
a new implementation. But the test case as such doesn't compile in
Scala 3 due to the non-wildcard existential.
@scala-jenkins scala-jenkins added this to the 2.12.18 milestone Feb 6, 2023
@lrytz lrytz requested a review from dwijnand February 6, 2023 14:48
@SethTisue SethTisue changed the title [backport] Don't GLB binders of type patterns, use the type directly [backport] Under -Xsource:2.13, don't GLB binders of type patterns, use the type directly Feb 9, 2023
@dwijnand dwijnand merged commit de8fa1e into scala:2.12.x Feb 13, 2023
@SethTisue SethTisue added the release-notes worth highlighting in next release notes label Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes worth highlighting in next release notes
Projects
None yet
4 participants