Commit 3800c91
authored
Fix upper bound constraints, that are higher-kinded (#16744)
When recording an upper bound, when it's a some higher-kinded type
variable applied to some type arguments, TypeComparer was re-applying
the type arguments to the type parameter (the type variable's origin).
Meaning that the instantiation of the type variable won't reflect in the
upper bound.
See the error message: `F$1[Int]` correctly appears as the lower bound,
but `F$1[Int]` isn't the upper bound, `F[Int]` is, which is the original
type parameter, in `Foo.Bar.apply[F](..)`.
-- [E007] Type Mismatch Error: i12478.scala:8:13
-------------------------------
8 | Foo.Bar(fu1)
| ^^^^^^^^^^^^
|Found: Foo.Bar[F$1]
|Required: Foo[T1]
|
|where: F$1 is a type in method id1 with bounds <: [_] =>> Any
| T1 is a type in method id1 with bounds >: F$1[Int] and <: F[Int]
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: i12478.scala:18:13
------------------------------
18 | Foo.Bar(fu3)
| ^^^^^^^^^^^^
|Found: Foo.Bar[F$2]
|Required: Foo[T3]
|
|where: F$2 is a type in method id3 with bounds <: [_] =>> Any
| T3 is a type in method id3 with bounds >: F$2[Int] and <: F[Int]
|
| longer explanation available when compiling with `-explain`File tree
2 files changed
+24
-2
lines changed- compiler/src/dotty/tools/dotc/core
- tests/pos
2 files changed
+24
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1338 | 1338 | | |
1339 | 1339 | | |
1340 | 1340 | | |
1341 | | - | |
1342 | | - | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
1343 | 1346 | | |
1344 | 1347 | | |
1345 | 1348 | | |
| |||
| 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 | + | |
0 commit comments