-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Type alias results in confusing type mismatch #8067
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
Labels
Comments
Using different type parameter names to make the error clearer: trait Tc[F[_]]
type OfString[G[_]] = G[String]
def foo[A[_]](fs: A[String])(implicit f: Tc[A]): A[String] = ???
def bar[B[_]](fs: OfString[B]): B[String] = foo(fs)(new Tc[B] {}) ary-bootstrapped/scala-0.22/dotty-library_0.22-0.22.0-bin-SNAPSHOT.jar -Xprint-types -Xprint:typer try/i8067.scala
-- [E007] Type Mismatch Error: try/i8067.scala:5:64 ----------------------------
5 |def bar[B[_]](fs: OfString[B]): B[String] = foo(fs)(new Tc[B] {})
| ^
|Found: Object with Tc[B] {...}
|Required: Tc[A]
|
|where: A is a type variable with constraint >: [X0] => B[X0] | X0[String] and <: [_$3] => Any
| B is a type in method bar with bounds <: [_$4] => Any Something is seriously wrong here. In trait Tc[+F[_]]
// ... same as before 5 |def bar[B[_]](fs: OfString[B]): B[String] = foo(fs)(new Tc[B] {})
| ^^^^^^^^^^^^^^^^^^^^^
| Found: B[String] | String[String]
| Required: B[String]
|
| where: B is a type in method bar with bounds <: [_$4] => Any Unassigning myself because I've got enough things in my todo list for now 😵 |
odersky
added a commit
that referenced
this issue
Jan 31, 2020
Fix #8067: Don't constrain with types of wrong kinds
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
minimized code
Compilation output
expectation
This compiles on Scala 2, and I ran into it while trying to cross-build cats-effect. I don't think it's the same variance issue as #7993, but I could be wrong about that?
The text was updated successfully, but these errors were encountered: