Commit fa6a257
committed
Refine overriding pairs in RefChecks
We now exclude a pair of overriding / overridden symbols that
have a common subclass parent of the base class only under the
additional condition that their signatures also match.
#12828 shows a case where this matters:
```scala
trait Foo[A]:
def foo(x: A): Unit
trait Bar[A] extends Foo[A]:
def foo(x: A & String): Unit = println(x.toUpperCase)
object Baz extends Bar[Int] // error overriding foo: incompatible type
@main def run() = Baz.foo(42)
```
When checking `Baz`, there is a common subclass parent (namely `Bar`),
but the signatures of the two `foo` definitions as seen from `Bar` are
different, so we cannot assume that the pair has already been checked.
Fixes #128281 parent 0722bf4 commit fa6a257
File tree
4 files changed
+70
-41
lines changed- compiler/src/dotty/tools/dotc
- transform
- typer
- tests/neg
4 files changed
+70
-41
lines changedLines changed: 30 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | | - | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
39 | | - | |
40 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
88 | | - | |
89 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
90 | 102 | | |
91 | 103 | | |
92 | | - | |
| 104 | + | |
93 | 105 | | |
94 | 106 | | |
95 | 107 | | |
| |||
134 | 146 | | |
135 | 147 | | |
136 | 148 | | |
137 | | - | |
| 149 | + | |
138 | 150 | | |
139 | | - | |
140 | | - | |
| 151 | + | |
| 152 | + | |
141 | 153 | | |
142 | | - | |
| 154 | + | |
143 | 155 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
154 | 162 | | |
155 | 163 | | |
156 | | - | |
157 | 164 | | |
158 | | - | |
159 | 165 | | |
160 | 166 | | |
161 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
374 | 377 | | |
375 | 378 | | |
376 | | - | |
| 379 | + | |
377 | 380 | | |
378 | 381 | | |
379 | 382 | | |
| |||
496 | 499 | | |
497 | 500 | | |
498 | 501 | | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
511 | 512 | | |
512 | | - | |
513 | | - | |
| 513 | + | |
| 514 | + | |
514 | 515 | | |
515 | 516 | | |
516 | 517 | | |
517 | 518 | | |
518 | | - | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
519 | 526 | | |
520 | 527 | | |
521 | 528 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments