-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Incorrect given resolution with abstract type parameter and same type constructor #12051
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
Comments
Generally, matching on intersection is a bad idea since they are not rigid enough. |
it this simplification apply to invariant type parameters as well? trait Has0[T]
trait Test[T]
given [K]: Test[Has0[String] & K] with {}
summon[Test[Has0[String] & Has0[Int]]] |
A good way to find out more about these things is to pass the given that you think should match to the -- [E007] Type Mismatch Error: ../new/test.scala:6:57 --------------------------
6 | val x = summon[Test[Has0[String] & Has0[Int]]](using g[)
| ^
| Found: g[Nothing]
| Required: Test[Has0[String] & Has0[Int]]
longer explanation available when compiling with `-explain` The compiler inferred summon[Test[Has0[String] & Has0[Int]]](using g[Hash0[Int]]) // ok So yes, in the presence of intersection types you will not get very good type inference. |
is it possible to fix it in the compiler? I see a lot of ways how this kind of type inference can be used in ZIO for type-level programming. ZIO has its "HAS pattern" and it would be useful to have implicit resolution works this way for replacing one |
Compiler version
3.0.0-RC2
Minimized code
Output
Expectation
Not sure how it works with HKT, but I expected all of them to compile.
The text was updated successfully, but these errors were encountered: