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 after StopMacroExpansion #19883

Merged
merged 2 commits into from
Mar 6, 2024

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Mar 5, 2024

When a splice throws a StopMacroExpansion, it's replaced by an EmptyTree, which has NoType. Which means you can't cast it, as you can't call .asInstanceOf on it. So handle this before calling ensureConforms.

Fixes #19851

When a splice throws a StopMacroExpansion, it's replaced by an
EmptyTree, which has NoType.  Which means you can't cast it, as you
can't call .asInstanceOf on it.  So handle this before calling
ensureConforms.
@nicolasstucki
Copy link
Contributor

I wonder if we could use another kind of tree when we stop the macro expansion. Something that has the type Nothing and would play well with ensureConforms.

@dwijnand
Copy link
Member Author

dwijnand commented Mar 5, 2024

From ccf6c2a I assumed you left it returning EmptyTree for a good reason, but you tell me.

@nicolasstucki
Copy link
Contributor

If I remeber correctly, it was the ErrorType that was cuasing problems before ccf6c2a. Maybe ref(defn.Predef_undefined) is enough.

@dwijnand
Copy link
Member Author

dwijnand commented Mar 5, 2024

I can't see how that could be true. I'll see if this works in CI.

@dwijnand dwijnand requested a review from nicolasstucki March 6, 2024 13:11
@dwijnand dwijnand marked this pull request as ready for review March 6, 2024 13:11
@dwijnand dwijnand merged commit c36c390 into scala:main Mar 6, 2024
19 checks passed
@dwijnand dwijnand deleted the avoid-crash-after-StopMacroExpansion branch March 6, 2024 18:11
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
WojciechMazur added a commit that referenced this pull request Jul 3, 2024
Backports #19883 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.

invalid prefix NoType when using report.errorAndAbort
3 participants