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

Avoid crash when superType does not exist after erasure #20188

Merged
merged 3 commits into from
Apr 15, 2024

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 15, 2024

Fixes #19929

Two main changes:

  • In TypeErasure, throw a TypeError instead of a FatalError if a supertype of an applied type does not exist. That way, we get a proper error with a position.
  • Move some catch-and-rethrow logic from ReTyper to TreeChecker. ReTyper already had special exceptions that disabled the logic for all uses of ReTyper except TreeChecker. Unfortunately the ReTyper override also disabled the special TypeError handling in Typer.

The root cause of #19929 got fixed by another PR, but I think it's still good to do the hardening of this commit.

Fixes scala#19929

Two main changes:

 - In TypeErasure, throw a TypeError instead of a FatalError if a supertype of an applied
   type does not exist. That way, we get a proper error with a position.
 - Move some catch-and-rethrow logic from ReTyper to TreeChecker. ReTyper alreayd had special
   exceptions that disabled the logic for all uses of ReTyper except TreeChecker. Unfortunately
   the ReTyper override also disabled the special TypeError handling in Typer.
Copy link
Contributor

@EugeneFlesselle EugeneFlesselle left a comment

Choose a reason for hiding this comment

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

LGTM

The 2nd minimisation in #19929 is unrelated so we can merge this independtly.

tests/neg/i19929.check Outdated Show resolved Hide resolved
@EugeneFlesselle EugeneFlesselle merged commit c47138c into scala:main Apr 15, 2024
17 checks passed
@EugeneFlesselle EugeneFlesselle deleted the fix-19929 branch April 15, 2024 18:58
@Kordyjan Kordyjan added this to the 3.5.0 milestone May 10, 2024
WojciechMazur added a commit that referenced this pull request Jul 5, 2024
… LTS (#21067)

Backports #20188 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when refining a private type member
3 participants