Commit 521ce95
committed
Always use baseType when constraining patternTp with scrutineeTp
In the following example:
```
type Cond[B <: Boolean] <: Tuple2[String, String] = B match ...
type Decoded[B <: Boolean] = Cond[B] match
case (h1, _) => Int
```
When constraining the `(h1, _)` pattern with `Cond[B]`,
we incorrectly assumed we could constrain h1 with B,
because `Cond[B]` is an applied type of which the baseType is Tuple2.
The issue can be fixed in constrainSimplePatternType
by obtaining the baseType for both the patternTp and scrutineeTp,
with the most general base of the two.
So in the above example, we wound constrain `B` with String
by obtaining `(String, String)` from `Cond[B]`.1 parent 960858d commit 521ce95
File tree
2 files changed
+34
-7
lines changed- compiler/src/dotty/tools/dotc/core
- tests/pos
2 files changed
+34
-7
lines changedLines changed: 5 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
204 | | - | |
| 203 | + | |
| 204 | + | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
260 | 258 | | |
261 | 259 | | |
262 | 260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
0 commit comments