Skip to content

Commit 716630e

Browse files
Merge pull request #12289 from dotty-staging/fix-12284
Don't use raw type ASTs in error message
2 parents f3811be + cff889b commit 716630e

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4436,7 +4436,7 @@ object Types {
44364436
typr.println(msg)
44374437
val bound = TypeComparer.fullUpperBound(origin)
44384438
if !(atp <:< bound) then
4439-
throw new TypeError(s"$msg,\nbut the latter type does not conform to the upper bound $bound")
4439+
throw new TypeError(i"$msg,\nbut the latter type does not conform to the upper bound $bound")
44404440
atp
44414441
// AVOIDANCE TODO: This really works well only if variables are instantiated from below
44424442
// If we hit a problematic symbol while instantiating from above, then avoidance

tests/neg/i12284.check

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
-- Error: tests/neg/i12284.scala:5:36 ----------------------------------------------------------------------------------
2+
5 | val xx: Vector[F[_]] = deps.map(i => magic(i)) // error // error // error
3+
| ^^^^^^^^^^^^^
4+
| return type B of lambda cannot be made hygienic;
5+
| it is not a supertype of the hygienic type Any
6+
-- Error: tests/neg/i12284.scala:5:33 ----------------------------------------------------------------------------------
7+
5 | val xx: Vector[F[_]] = deps.map(i => magic(i)) // error // error // error
8+
| ^
9+
| Inaccessible variables captured in instantation of type variable B.
10+
| F[i.A] was fixed to Any,
11+
| but the latter type does not conform to the upper bound F[?]
12+
-- Error: tests/neg/i12284.scala:5:6 -----------------------------------------------------------------------------------
13+
5 | val xx: Vector[F[_]] = deps.map(i => magic(i)) // error // error // error
14+
| ^
15+
| Inaccessible variables captured in instantation of type variable B.
16+
| F[i.A] was fixed to Any,
17+
| but the latter type does not conform to the upper bound F[?]
18+
-- Error: tests/neg/i12284.scala:4:2 -----------------------------------------------------------------------------------
19+
4 | val deps: Vector[I[F, _]] = ??? // error
20+
| ^
21+
| Inaccessible variables captured in instantation of type variable B.
22+
| F[i.A] was fixed to Any,
23+
| but the latter type does not conform to the upper bound F[?]
24+
-- Error: tests/neg/i12284.scala:3:4 -----------------------------------------------------------------------------------
25+
3 |def magic[F[_], A](in: I[F, A]): F[A] = // error // error
26+
| ^
27+
| Inaccessible variables captured in instantation of type variable B.
28+
| F[i.A] was fixed to Any,
29+
| but the latter type does not conform to the upper bound F[?]
30+
-- Error: tests/neg/i12284.scala:3:0 -----------------------------------------------------------------------------------
31+
3 |def magic[F[_], A](in: I[F, A]): F[A] = // error // error
32+
|^
33+
|Inaccessible variables captured in instantation of type variable B.
34+
|F[i.A] was fixed to Any,
35+
|but the latter type does not conform to the upper bound F[?]
36+
-- Error: tests/neg/i12284.scala:1:0 -----------------------------------------------------------------------------------
37+
1 |trait I[F[_], A] // error
38+
|^
39+
|Inaccessible variables captured in instantation of type variable B.
40+
|F[i.A] was fixed to Any,
41+
|but the latter type does not conform to the upper bound F[?]

tests/neg/i12284.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
trait I[F[_], A] // error
2+
3+
def magic[F[_], A](in: I[F, A]): F[A] = // error // error
4+
val deps: Vector[I[F, _]] = ??? // error
5+
val xx: Vector[F[_]] = deps.map(i => magic(i)) // error // error // error
6+
???

0 commit comments

Comments
 (0)