Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
`TypeBlock`s are represented as normal `Blocks` in the Quotes API's implementation. 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 of the block, trying to turn it into a `TypeDef` by using a match with the pattern ```scala case alias: TypeDef => alias ``` This seems fine since `TypeBlock`s are supposed to be just a list of `TypeDefs` followed by a type as the last expression. Since the `TypeTest` matches any `Block` and not only `Blocks` that are `TypeBlocks`, the statements can be anything, not just `TypeDef`s, which lets the whole `case TypeBlock(_, _)` pattern die 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 `Block`s expression is a type) Closes #21721
- Loading branch information