You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's caused by the by-name argument to Try in combination with the PartialFunction.
def foo[A](a: =>A): Option[A] = Some(a)
// crash
val f: PartialFunction[String, Int] = x => foo(x.toInt) match { case Some(0) => 0 }
// no crash
val f: String => Int = x => foo(x.toInt) match { case Some(0) => 0 }
// no crash
val f: PartialFunction[String, Int] = x => Option(x.toInt) match { case Some(0) => 0 }
Jasper-M
changed the title
Unusual PartialFunction says "key not found: method $anonfun"
By-name argument in PartialFunction says "key not found: method $anonfun"
Nov 19, 2020
Minimized code
Output (click arrow to expand)
Expectation
This compiles in Scala 2.13, and evaluates to
List(1, 3)
.The text was updated successfully, but these errors were encountered: