Skip to content

Instantly share code, notes, and snippets.

@pshirshov
Last active June 15, 2018 17:15
Show Gist options
  • Save pshirshov/60bf552a095403010a841d56e14eab29 to your computer and use it in GitHub Desktop.
Save pshirshov/60bf552a095403010a841d56e14eab29 to your computer and use it in GitHub Desktop.
Failing scala inference, works in dotty
// works in dotty, not in scala
trait Provider[P] {
def provide: P
}
implicit object IntProvider extends Provider[Int] {
override def provide = 1
}
implicit object StringProvider extends Provider[String] {
override def provide = "s"
}
def make[P: Provider]: P = implicitly[Provider[P]].provide
case class Something(a: Int, b: String)
val v = Something(make[Int], make[String])
// but this works:
def make[P]: P = ???
case class Something(a: Int, b: String)
val v = Something(make, make)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment