Commit a97974c
authored
`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
File tree
3 files changed
+18
-1
lines changed- compiler/src/scala/quoted/runtime/impl
- tests/pos/i21721
3 files changed
+18
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1413 | 1413 | | |
1414 | 1414 | | |
1415 | 1415 | | |
1416 | | - | |
| 1416 | + | |
1417 | 1417 | | |
1418 | 1418 | | |
1419 | 1419 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments