Commit 731522a
authored
Be still more careful when computing denotations of class parameters (#16112)
Be still more careful when intersecting info and arguments of a class
type parameter. This is the latest installment of a never-ending story.
The problem is this: Given
```scala
class C[T >: L1 <: H1] { val x: T }
def f(): C[? >: L2 <: H2]
```
what is the type of `f().x`?
With capture conversion (an extremely tricky aspect of the type system
forced on us since Java does it), the type is something like `?1.T`
where `?1` is a skolem variable of type `C[? >: L2 <: H2]`. OK, but what
is the underlying (widened) type of `?1.T`?
We used to say it's `C[T >: L1 <: H1]`. I.e. we forgot about the actual
arguments. But then we had to change untupling desugarings from defs to
vals in #14816 to fix #14783 and it turned out that was not good enough,
we needed the information of the actual arguments, i.e. the type should
be `C[T >: L2 <: H2]`. Then something else started failing which relied
on the formal arguiment bounds being preserved. So the new resolution
was that the type would be the intersection of the formal parameter
bounds and the actual bounds, i.e. `C[T >: L1 | L2 <: H1 & H2]`. Then
there was a series of problems where _that_ failed, either because the
parameter bound was F-bounded or because the intersection was an empty
type. The latest installment is that the parameter bounds refer to
another parameter in the same class, which requires a simultaneous
substitution of all skolemized bounds for all dependent parameter
references in the parameter bounds. But that's impossible or at least
very hard to achieve since we are looking at the type of a single
parameter after capture conversion here. So the current solution is to
also back out of the intersection if there are cross-parameter
references and to use just the argument bounds instead.File tree
3 files changed
+35
-18
lines changed- compiler/src/dotty/tools/dotc/core
- tests/pos
3 files changed
+35
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1076 | 1076 | | |
1077 | 1077 | | |
1078 | 1078 | | |
| 1079 | + | |
1079 | 1080 | | |
1080 | 1081 | | |
1081 | 1082 | | |
| |||
1120 | 1121 | | |
1121 | 1122 | | |
1122 | 1123 | | |
1123 | | - | |
1124 | | - | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
1128 | | - | |
1129 | | - | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
| 1124 | + | |
| 1125 | + | |
1133 | 1126 | | |
1134 | 1127 | | |
1135 | 1128 | | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
1136 | 1149 | | |
1137 | 1150 | | |
1138 | 1151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | 445 | | |
454 | 446 | | |
455 | 447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
0 commit comments