Commit 502c7c9
committed
Fix #6199: Use a skolemized prefix in asSeenFrom when needed
Prior to
91ee02f,
unstable prefixes appearing in selection types were handled in a
two-pass approach which can be summarized as:
1. Type the selection with the unstable prefix, if this prefix appears
in a position where it cannot be widened away, mark it with a special
annotation.
2. If the result of the selection contains this annotation, retype it
after having wrapped its prefix in a skolem.
This got replaced by the use of an `ApproximatingTypeMap` which can
always construct a valid (but potentially approximated) type for the
selection.
Most of the time this is all we need but there are some cases where
skolemizing the prefix is still useful as witnessed by the tests added
in this commit. They are now handled by unconditionally skolemizing
unstable prefixes.
To avoid any potential performance impact from this, we teach
`asSeenFrom` to always widen these prefixes first and only make use of
the skolem to avoid returning an approximation. Since this almost never
occurs (it happens only once when compiling Dotty) this means we incur
almost no extra cost (the skolem itself still needs to be allocated
unconditionally in advance, this cannot be delegated to `asSeenFrom`
because it's supposed to be an idempotent operation and each skolem is
unique).1 parent 61ea245 commit 502c7c9
File tree
7 files changed
+116
-18
lines changed- compiler/src/dotty/tools/dotc
- core
- tasty
- typer
- tests/pos
7 files changed
+116
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
30 | 51 | | |
| 52 | + | |
31 | 53 | | |
32 | 54 | | |
33 | 55 | | |
| 56 | + | |
| 57 | + | |
34 | 58 | | |
35 | 59 | | |
36 | 60 | | |
| |||
44 | 68 | | |
45 | 69 | | |
46 | 70 | | |
47 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
48 | 84 | | |
49 | 85 | | |
50 | 86 | | |
| |||
74 | 110 | | |
75 | 111 | | |
76 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
77 | 118 | | |
78 | 119 | | |
79 | | - | |
| 120 | + | |
80 | 121 | | |
81 | 122 | | |
82 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
552 | | - | |
| 552 | + | |
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
| |||
3723 | 3723 | | |
3724 | 3724 | | |
3725 | 3725 | | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
| 3733 | + | |
| 3734 | + | |
| 3735 | + | |
| 3736 | + | |
| 3737 | + | |
| 3738 | + | |
| 3739 | + | |
| 3740 | + | |
3726 | 3741 | | |
3727 | 3742 | | |
3728 | 3743 | | |
| |||
4646 | 4661 | | |
4647 | 4662 | | |
4648 | 4663 | | |
| 4664 | + | |
| 4665 | + | |
| 4666 | + | |
4649 | 4667 | | |
4650 | 4668 | | |
4651 | 4669 | | |
| |||
4657 | 4675 | | |
4658 | 4676 | | |
4659 | 4677 | | |
4660 | | - | |
| 4678 | + | |
4661 | 4679 | | |
4662 | 4680 | | |
4663 | | - | |
| 4681 | + | |
4664 | 4682 | | |
4665 | 4683 | | |
4666 | 4684 | | |
| |||
4676 | 4694 | | |
4677 | 4695 | | |
4678 | 4696 | | |
4679 | | - | |
4680 | | - | |
4681 | 4697 | | |
4682 | 4698 | | |
4683 | 4699 | | |
| |||
Lines changed: 10 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1016 | 1016 | | |
1017 | 1017 | | |
1018 | 1018 | | |
1019 | | - | |
1020 | | - | |
| 1019 | + | |
| 1020 | + | |
1021 | 1021 | | |
1022 | | - | |
1023 | | - | |
| 1022 | + | |
| 1023 | + | |
1024 | 1024 | | |
1025 | | - | |
1026 | | - | |
| 1025 | + | |
| 1026 | + | |
1027 | 1027 | | |
1028 | 1028 | | |
1029 | 1029 | | |
| |||
1033 | 1033 | | |
1034 | 1034 | | |
1035 | 1035 | | |
1036 | | - | |
1037 | | - | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
1038 | 1039 | | |
1039 | | - | |
| 1040 | + | |
1040 | 1041 | | |
1041 | 1042 | | |
1042 | 1043 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
229 | 240 | | |
230 | 241 | | |
231 | 242 | | |
| |||
234 | 245 | | |
235 | 246 | | |
236 | 247 | | |
| 248 | + | |
237 | 249 | | |
238 | | - | |
| 250 | + | |
| 251 | + | |
239 | 252 | | |
240 | 253 | | |
241 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments