Commit 1451788
committed
Try to be more subtle when inferring type parameters of class parents
The previous scheme was basically like this:
1. If the parent type is an application, infer type parameters from the
term parameters during completion of the class.
2. If the parent type is an Ident or Select and it appears in an anonymous
class, infer it from the expected type.
It could happen in the second case that we infer Nothing since an expected type
was missing, but if the parent type had been an application, we would have inferred
something else from implicit arguments to the parent constructor. This is a case
handled by Scala 2, but not yet by Dotty.
To deal with this we have to perform a complicated dance:
- Try step (2) above, but back out if the inferred parent type has Nothing
as a type argument.
- During completion, if the inferred parent has missing type arguments, convert
the parent type to an application with () arguments and try that instead.
I normally would have thought this is too much sophistry but there are valid
use cases that Scala 2 supports and it would be good if we get to parity for these.1 parent 3d251d6 commit 1451788
File tree
10 files changed
+66
-34
lines changed- compiler/src/dotty/tools/dotc/typer
- tests
- neg
- pos
10 files changed
+66
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
310 | | - | |
| 310 | + | |
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
315 | | - | |
316 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
317 | 319 | | |
318 | 320 | | |
319 | | - | |
320 | 321 | | |
321 | 322 | | |
322 | 323 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1453 | 1453 | | |
1454 | 1454 | | |
1455 | 1455 | | |
1456 | | - | |
1457 | | - | |
1458 | | - | |
1459 | | - | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
1460 | 1459 | | |
1461 | 1460 | | |
1462 | | - | |
1463 | | - | |
| 1461 | + | |
1464 | 1462 | | |
1465 | 1463 | | |
1466 | 1464 | | |
1467 | 1465 | | |
1468 | | - | |
| 1466 | + | |
1469 | 1467 | | |
1470 | 1468 | | |
1471 | 1469 | | |
1472 | | - | |
1473 | 1470 | | |
1474 | 1471 | | |
1475 | | - | |
1476 | | - | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
1477 | 1491 | | |
1478 | 1492 | | |
1479 | 1493 | | |
| |||
1607 | 1621 | | |
1608 | 1622 | | |
1609 | 1623 | | |
1610 | | - | |
| 1624 | + | |
1611 | 1625 | | |
1612 | 1626 | | |
1613 | 1627 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
843 | 843 | | |
844 | 844 | | |
845 | 845 | | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
854 | 851 | | |
855 | 852 | | |
856 | 853 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
This file was deleted.
This file was deleted.
This file was deleted.
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments