Skip to content

Don't use raw type ASTs in error message #12289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4432,7 +4432,7 @@ object Types {
typr.println(msg)
val bound = TypeComparer.fullUpperBound(origin)
if !(atp <:< bound) then
throw new TypeError(s"$msg,\nbut the latter type does not conform to the upper bound $bound")
throw new TypeError(i"$msg,\nbut the latter type does not conform to the upper bound $bound")
atp
// AVOIDANCE TODO: This really works well only if variables are instantiated from below
// If we hit a problematic symbol while instantiating from above, then avoidance
Expand Down
41 changes: 41 additions & 0 deletions tests/neg/i12284.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-- Error: tests/neg/i12284.scala:5:36 ----------------------------------------------------------------------------------
5 | val xx: Vector[F[_]] = deps.map(i => magic(i)) // error // error // error
| ^^^^^^^^^^^^^
| return type B of lambda cannot be made hygienic;
| it is not a supertype of the hygienic type Any
-- Error: tests/neg/i12284.scala:5:33 ----------------------------------------------------------------------------------
5 | val xx: Vector[F[_]] = deps.map(i => magic(i)) // error // error // error
| ^
| Inaccessible variables captured in instantation of type variable B.
| F[i.A] was fixed to Any,
| but the latter type does not conform to the upper bound F[?]
-- Error: tests/neg/i12284.scala:5:6 -----------------------------------------------------------------------------------
5 | val xx: Vector[F[_]] = deps.map(i => magic(i)) // error // error // error
| ^
| Inaccessible variables captured in instantation of type variable B.
| F[i.A] was fixed to Any,
| but the latter type does not conform to the upper bound F[?]
-- Error: tests/neg/i12284.scala:4:2 -----------------------------------------------------------------------------------
4 | val deps: Vector[I[F, _]] = ??? // error
| ^
| Inaccessible variables captured in instantation of type variable B.
| F[i.A] was fixed to Any,
| but the latter type does not conform to the upper bound F[?]
-- Error: tests/neg/i12284.scala:3:4 -----------------------------------------------------------------------------------
3 |def magic[F[_], A](in: I[F, A]): F[A] = // error // error
| ^
| Inaccessible variables captured in instantation of type variable B.
| F[i.A] was fixed to Any,
| but the latter type does not conform to the upper bound F[?]
-- Error: tests/neg/i12284.scala:3:0 -----------------------------------------------------------------------------------
3 |def magic[F[_], A](in: I[F, A]): F[A] = // error // error
|^
|Inaccessible variables captured in instantation of type variable B.
|F[i.A] was fixed to Any,
|but the latter type does not conform to the upper bound F[?]
-- Error: tests/neg/i12284.scala:1:0 -----------------------------------------------------------------------------------
1 |trait I[F[_], A] // error
|^
|Inaccessible variables captured in instantation of type variable B.
|F[i.A] was fixed to Any,
|but the latter type does not conform to the upper bound F[?]
6 changes: 6 additions & 0 deletions tests/neg/i12284.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
trait I[F[_], A] // error

def magic[F[_], A](in: I[F, A]): F[A] = // error // error
val deps: Vector[I[F, _]] = ??? // error
val xx: Vector[F[_]] = deps.map(i => magic(i)) // error // error // error
???