-
Notifications
You must be signed in to change notification settings - Fork 21
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
regression in type inference of match-defined partial function #6925
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6925?orig=1 |
@paulp said: scala> List(1).flatMap(n => Set(1).collect { case w => w })
<console>:8: error: no type parameters for method flatMap: (f: Int => scala.collection.GenTraversableOnce[B])(implicit bf: scala.collection.generic.CanBuildFrom[List[Int],B,That])That exist so that it can be applied to arguments (Int => scala.collection.immutable.Set[_ <: Int])
--- because ---
argument expression's type is not compatible with formal parameter type;
found : Int => scala.collection.immutable.Set[_ <: Int]
required: Int => scala.collection.GenTraversableOnce[?B]
List(1).flatMap(n => Set(1).collect { case w => w })
^
<console>:8: error: type mismatch;
found : Int => scala.collection.immutable.Set[_ <: Int]
required: Int => scala.collection.GenTraversableOnce[B]
List(1).flatMap(n => Set(1).collect { case w => w })
^
<console>:8: error: Cannot construct a collection of type That with elements of type B based on a collection of type List[Int].
List(1).flatMap(n => Set(1).collect { case w => w })
^ Mined from stackoverflow: http://stackoverflow.com/questions/14174639/flatmap-behavior-changed-in-2-10-0 |
@adriaanm said: I was thinking about the way we synthesize the pattern matching partial functions some more, and was struck by (thankfully unjustified) fear about what happens in: object X { val pf: PartialFunction[Any, Any] = { case _ => this } } Serendipitously, the chicken/egg problem prevents us unhygenically binding // should use the DefDef for the context's tree, but it doesn't exist yet (we need the typer we're creating to create it) The This node carries the symbol for // cases.head.body.expr Any local classes/methods defined in the case body do have correct parentage: the second argument to |
@adriaanm said: |
As of scala/scala@28483739c3 this infers different types with and without -Xoldpatmat:
It's a large change not to be mentioned in the commit message - is it unintentional? I assume it's not intentional that it's in one pattern matcher and not the other.
commit 28483739c3
Author: Adriaan Moors adriaan.moors@epfl.ch
Date: 9 months ago
The text was updated successfully, but these errors were encountered: