Commit 8b8d813
committed
Another tweak to overloading resolution
After thinking even more about it, I now believe we should revise the rule. The idea of using implicits as a priority mechanism is so that we can write something like this:
```
class LowPrio
class MidPrio extends LowPrio
class HighPrio extends MidPrio
implied for LowPrio
implied for MidPrio
implied for HighPrio
implied fallback given LowPrio for A
implied standard given MidPrio for A
implied specialized given HighPrio for A
```
(usually in different modules, of course). This is a good alternative to the previous priorization by owner subclassing since it places no demands on where implied instances are put and is stable under aliasing/forwarding.
But to do this reliably it should also work if some of the alternatives take additional implicit parameters. E.g.
```
implied standard given MidPrio given B for A
```
The "more implicit parameters is better" rule would make standard of higher priority than specialized, which defeats the purpose.1 parent b47d2f2 commit 8b8d813
File tree
4 files changed
+9
-24
lines changed- compiler/src/dotty/tools/dotc/typer
- docs/docs/reference/changed-features
- tests/run
4 files changed
+9
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1344 | 1344 | | |
1345 | 1345 | | |
1346 | 1346 | | |
1347 | | - | |
1348 | | - | |
1349 | | - | |
1350 | 1347 | | |
1351 | 1348 | | |
1352 | 1349 | | |
| |||
1383 | 1380 | | |
1384 | 1381 | | |
1385 | 1382 | | |
1386 | | - | |
1387 | 1383 | | |
1388 | 1384 | | |
1389 | 1385 | | |
| |||
1416 | 1412 | | |
1417 | 1413 | | |
1418 | 1414 | | |
1419 | | - | |
1420 | | - | |
1421 | | - | |
1422 | | - | |
1423 | | - | |
1424 | | - | |
1425 | | - | |
1426 | | - | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
1427 | 1421 | | |
1428 | 1422 | | |
1429 | 1423 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | | - | |
119 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | 38 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | 15 | | |
20 | 16 | | |
21 | 17 | | |
22 | 18 | | |
23 | 19 | | |
24 | | - | |
25 | 20 | | |
26 | 21 | | |
27 | 22 | | |
| |||
0 commit comments