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

Fix #21721: make case TypeBlock(_, _) not match non-type Block #21722

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Oct 7, 2024

  1. Fix scala#21721: make case TypeBlock(_, _) not match non-type Block

    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)
    felher committed Oct 7, 2024
    Configuration menu
    Copy the full SHA
    147f562 View commit details
    Browse the repository at this point in the history