Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Don't GLB binders of type patterns, use the type directly#10247

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SethTisue merged 1 commit intoscala:2.13.xfromlrytz:t12702-pending
Jan 11, 2023

Conversation

@lrytz
Copy link
Member

@lrytzlrytz commentedDec 21, 2022
edited by SethTisue
Loading

In type patternsc match { case x: T }, the translation would assign the GLB ofc's type andT to the variablex.

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

caseMaybeBoundTyped(patBinder, tpe)=>
valprevTp= prevBinder.info.widen
valaccumType= glb(List(prevTp, tpe))

In the test case, the GLB collapsed toNull because its computation failed (combination of f-bounds, existentials, skolems that I don't follow), seethrow GlbFailure. This is how it's been for 14 years (b894f80). This resulted in a cast toNull$ 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.

Fixesscala/bug#12702

@scala-jenkinsscala-jenkins added this to the2.13.11 milestoneDec 21, 2022
In type patterns `c match { case x: T }`, the translation would assignthe GLB of `c`'s type and `T` to the varaible `x`.This seems to trace back to the first version of the "virtual patternmatcher". I could not find a similar use of `glb` in that revisionof the codebase. So I'm not sure if it was a new addition, or pickedup from the previous implementation.https://github.com/scala/scala/blob/8a9fd64129926eea35f7dca181242855f14e153f/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala#L438-L440In the test case, the GLB collapsed to `Null` because itscomputation failed (combination of f-bounds, existentials, skolems thatI don't follow), see `throw GlbFailure`. This is how it's been for 14years (b894f80). This resulted in a cast to `Null$` failing atruntime.I assume GLB is fixed in Scala 3, as this core of the type system hasa new implementation. But the test case as such doesn't compile inScala 3 due to the non-wildcard existential.
@lrytz
Copy link
MemberAuthor

@SethTisue could you run this one through the community build?

@lrytzlrytz requested a review fromretronymDecember 22, 2022 10:36
Copy link
Member

@retronymretronym left a comment
edited by lrytz
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Glad my hunch seems to be working! Easier than fixingglb itself in this instance!

  • Removedef glbWith, should be dead code now
  • Analyze ajardiff of a bootstrapped vs non-boostrapped compiler to get a sense of what, if anything, changes using the compiler as a test case.

@lrytz
Copy link
MemberAuthor

Thedef glbWith is already removed.

Jardiff for library+reflect+compiler here:https://gist.github.com/lrytz/35b3e7be0b6dab13ed95e771feb04429

It looks fine. The type of thiscl variable changed:https://github.com/scala/scala/blob/2.13.x/src/compiler/scala/tools/nsc/classpath/ZipAndJarFileLookupFactory.scala#L221

As it's captured below innew TimerTask { ... }, the field of the anonymous class changed (fromObject toCloseable).

@SethTisue
Copy link
Member

could you run this one through the community build?

I'll get to it... a bit backed up, post-holidays

@SethTisueSethTisue self-assigned thisJan 10, 2023
@SethTisue
Copy link
Member

https://scala-ci.typesafe.com/job/scala-2.13.x-jdk11-integrate-community-build/4226/ was green 🎉

(the metals failure is expected, it always fails on PR validation snapshots)

@SethTisueSethTisue merged commitcef9844 intoscala:2.13.xJan 11, 2023
@SethTisueSethTisue added the release-notesworth highlighting in next release notes labelJan 11, 2023
@SethTisue
Copy link
Member

I have lingering suspicion that there may be codebases out there relying on the old behavior. I think we can go ahead with it regardless, but let's release-note it.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@retronymretronymretronym approved these changes

Assignees

@SethTisueSethTisue

Labels

release-notesworth highlighting in next release notes

Projects

None yet

Milestone

2.13.11

Development

Successfully merging this pull request may close these issues.

Cast toNull$ in pattern match involving existential type

4 participants

@lrytz@SethTisue@retronym@scala-jenkins

[8]ページ先頭

©2009-2025 Movatter.jp