Open
Description
class Foo[T <: String]
class Bar[T]
def foo[T](implicit bar: Bar[T]) = bar
implicit def mkFooBar[A, T[x] <: Foo[x]]: Bar[T[A]] = new Bar[T[A]]
foo[Foo[String]]
If you compile this code in one go, you get the following error:
error: could not find implicit value for parameter bar: Bar[Foo[String]]
foo[Foo[String]]
^
This error is actually caused by another error:
error: type arguments [x] do not conform to class Foo's type parameter bounds [T <: String]
implicit def mkFooBar[A, T[x] <: Foo[x]]: Bar[T[A]] = new Bar[T[A]]
^
This is the error you actually have to fix to get the code working, but the compiler doesn't show it and leaves you guessing what the problem is.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
scabug commentedon Mar 17, 2017
Imported From: https://issues.scala-lang.org/browse/SI-10234?orig=1
Reporter: Jasper-M
Affected Versions: 2.12.1
atiqsayyed commentedon Aug 17, 2017
Can I pick this Issue?? If somebody can provide the details it'd be great help
SethTisue commentedon Sep 11, 2017
@atiqsayyed I'd suggest starting by finding the place in the code where the error is coming from.
I'm not certain this is actually a "quick" fix — implicit search is pretty hairy stuff. if you get into it and find it's too hard, it would still be valuable even just to record your investigation here as a starting point for the next person.
som-snytt commentedon Jul 29, 2019
I don't know why scalacenter doesn't run a contest for least informative error.
som-snytt commentedon Dec 23, 2022
The ticket title reads like an Onion headline!
Jasper-M commentedon Dec 23, 2022
You won't BELIEVE these 27 errors that the scala compiler is hiding from you!