-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implicit view not found involving an uninstantiated type variable #3343
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
I think you may have minimized this too much, this only succeeds in scalac because |
class Arbitrary[T]
object Arbitrary {
def arbitrary[T](implicit a: Arbitrary[T]): T = ???
implicit def arbContainer[C[_],T](implicit t: C[T] => Traversable[T]): Arbitrary[C[T]] = ???
val arbString = arbitrary[List[Char]]
} scalac resolves: val arbString: List[Char] =
arbitrary[List[Char]](arbContainer[List, Char](scala.Predef.$conforms[List[Char]])); |
Thanks! We can reduce it further, this doesn't compile with dotty: object Test {
def foo[C[_],T](implicit t: C[T] => Traversable[T]): C[T] = ???
val a: List[Char] = foo
} But this does: object Test {
def foo[C[_],T](implicit t: C[T] => Traversable[T]): C[T] = ???
val a: List[Char] = foo[List, Char]
} The error we get in the first case is: 4 | val a: List[Char] = foo
| ^
| No implicit view available from scala.collection.immutable.List[T]
|
| where: T is a type variable with constraint <: Char
| => scala.collection.Traversable[T]
|
| where: T is a type variable with constraint <: Char
| . |
We can minimize even more actually: object Test {
def foo[C[_]](implicit t: C[Char] => Traversable[Char]): C[Char] = ???
val a: List[Char] = foo
} 4 | val a: List[Char] = foo
| ^
|No implicit view available from scala.collection.immutable.List[Char] => scala.collection.Traversable[Char]. Here the error message is misleading: there is an implicit view from |
Previously, `C[Char]`.baseType(`Traversable[Char]`) where C := `[X] => List|X]` returned `Traversable[ParamRef(A)]` instead of `Traversable[Char]`, because the substitution was done on the type parameters of the class symbol instead of the type parameters of the type, these are different when type lambdas are involved.
Previously, `C[Char]`.baseType(`Traversable[Char]`) where C := `[X] => List|X]` returned `Traversable[ParamRef(A)]` instead of `Traversable[Char]`, because the substitution was done on the type parameters of the class symbol instead of the type parameters of the type, these are different when type lambdas are involved.
Previously, `C[Char]`.baseTypeOf(`Traversable[Char]`) where C := `[X] => List|X]` returned `Traversable[ParamRef(A)]` instead of `Traversable[Char]`, because the substitution was done on the type parameters of the class symbol instead of the type parameters of the type, these are different when type lambdas are involved.
Previously, `C[Char]`.baseTypeOf(`Traversable[Char]`) where C := `[X] => List[X]` returned `Traversable[ParamRef(A)]` instead of `Traversable[Char]`, because the substitution was done on the type parameters of the class symbol instead of the type parameters of the type, these are different when type lambdas are involved.
Previously, `C[Char]`.baseTypeOf(`Traversable[Char]`) where C := `[X] => List[X]` returned `Traversable[ParamRef(A)]` instead of `Traversable[Char]`, because the substitution was done on the type parameters of the class symbol instead of the type parameters of the type, these are different when type lambdas are involved. This is fixed by always going through `AppliedType#superType` when the tycon is not a class.
Fix #3343: Make baseType work properly with type lambdas
This fails to compile with Dotty
Note that this compiles:
The text was updated successfully, but these errors were encountered: