Skip to content

Backport "Fix #21721: make case TypeBlock(_, _) not match non-type Block" to 3.3 LTS #278

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

Merged
merged 1 commit into from
Apr 24, 2025

Conversation

tgodzik
Copy link

@tgodzik tgodzik commented Apr 23, 2025

Backports scala#21722 to the 3.3.7.

PR submitted by the release tooling.
[skip ci]

TypeBlocks are represented as normal Blocks in the Quotes API. The
current TypeTest for TypeBlock is exactly the same as the TypeTest for
Block, which means that case TypeBlock(_, _) matches every block.

The implementation of unapply on TypeBlockModule, however, gives back
(List[TypeDef], TypeTree). It constructs the List[TypeDef] by mapping
over every statement, turning it into a TypeDef by using a match
with the pattern

  case alias: TypeDef => alias

Since the TypeTest matches any Block and not only Blocks that are
TypeBlocks, the statemnts can be anything, not just TypeDefs, which lets
the whole case TypeBlock(_, _) pattern fail with a MatchError.

This commit fixes the problem by making the TypeTest check whether the
Block is a type (which in turns checks whether the blocks expression is
a type)

[Cherry-picked 147f562]
Base automatically changed from backport-lts-3.3-22655 to lts-3.3 April 24, 2025 10:40
@tgodzik
Copy link
Author

tgodzik commented Apr 24, 2025

No regressions detected in the community build up to backport-lts-3.3-22712.

Reference

@tgodzik tgodzik merged commit bc573a8 into lts-3.3 Apr 24, 2025
22 checks passed
@tgodzik tgodzik deleted the backport-lts-3.3-21722 branch April 24, 2025 10:40
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.

2 participants