Last active
June 15, 2018 17:15
-
-
Save pshirshov/60bf552a095403010a841d56e14eab29 to your computer and use it in GitHub Desktop.
Failing scala inference, works in dotty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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