Commit 48c7964
committed
Fix higher-order unification incorrectly substituting tparams
When creating a fresh type lambda for the purpose of higher-order type
inference, we incorrectly substituted references to type parameters
before this commit. We want to construct:
bodyArgs := otherArgs.take(d), T_0, ..., T_k-1
[T_0, ..., T_k-1] =>> otherTycon[bodyArgs]
For this type to be valid, we need the bounds of `T_i` to be the bounds of
the (d+i) type parameter of `otherTycon` after substituting references to
each type parameter of `otherTycon` by the corresponding argument in `bodyArgs`.
The previous implementation incorrectly substituted only the last `k` type
parameters, this was not enough for correctness. It could also lead to a crash
because it called `integrate` which implicitly assumes it is passed a full list
of type parameters (this is now documented).
Fixes #15983.1 parent 62684d0 commit 48c7964
File tree
5 files changed
+51
-8
lines changed- compiler/src/dotty/tools/dotc/core
- tests/pos
5 files changed
+51
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
207 | 213 | | |
208 | 214 | | |
209 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1066 | 1066 | | |
1067 | 1067 | | |
1068 | 1068 | | |
| 1069 | + | |
| 1070 | + | |
1069 | 1071 | | |
1070 | | - | |
| 1072 | + | |
1071 | 1073 | | |
1072 | | - | |
| 1074 | + | |
1073 | 1075 | | |
1074 | | - | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
1075 | 1079 | | |
1076 | 1080 | | |
1077 | 1081 | | |
| |||
1096 | 1100 | | |
1097 | 1101 | | |
1098 | 1102 | | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
1099 | 1112 | | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
1103 | | - | |
| 1113 | + | |
| 1114 | + | |
1104 | 1115 | | |
1105 | 1116 | | |
1106 | 1117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3600 | 3600 | | |
3601 | 3601 | | |
3602 | 3602 | | |
| 3603 | + | |
| 3604 | + | |
| 3605 | + | |
| 3606 | + | |
3603 | 3607 | | |
3604 | 3608 | | |
3605 | 3609 | | |
3606 | | - | |
| 3610 | + | |
3607 | 3611 | | |
3608 | 3612 | | |
3609 | 3613 | | |
| |||
| 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 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments