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
inference regression with existentials #5330
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5330?orig=1 |
@lrytz said: |
@paulp said: |
@retronym said: trait FM[A] {
def map(f: A => Any)
}
trait M[A] extends FM[A] {
def map(f: A => Any)
}
trait N[A] extends FM[A]
object test {
def kaboom(xs: M[_]) = xs map (x => ()) // missing parameter type.
def okay1[A](xs: M[A]) = xs map (x => ())
def okay2(xs: FM[_]) = xs map (x => ())
def okay3(xs: N[_]) = xs map (x => ())
} |
@paulp said: // compiles
class CC1(xs: List[_]) {
def f(x1: Any) = null
def g = xs map (x => f(x))
}
// does not compile
class CC2(xs: List[_]) {
def f(x1: Any, x2: Any) = null
def g = xs map (x => f(x, x))
} In 2.9, -Xprint:typer for g in CC1 and CC2
As similar as one might suppose. In trunk:
So the existential in the function parameter type has been crushed to Any. |
@retronym said: 2.9.2 typed xs.map: (f: Any => Any)Unit
adapted xs.map: (f: Any => Any)Unit to ?,
typing ((x) => ()): pt = Any => Any: undetparams=, implicitsEnabled=true, silent=true, context.owner=method kaboom
[loaded class file /Users/jason/usr/scala-2.9.1/lib/scala-library.jar(scala/reflect/Code.class) in 2ms]
typing (): pt = Any: undetparams=, implicitsEnabled=true, silent=true, context.owner=value $anonfun
typed (): Unit
[loaded class file /Users/jason/usr/scala-2.9.1/lib/scala-library.jar(scala/AnyVal.class) in 2ms]
adapted (): Unit to Any,
typed ((x: Any) => ()): Any => Unit
adapted ((x: Any) => ()): Any => Unit to Any => Any, 2.10 typed xs.map: (f: _$1 => Any)Unit <and> (f: _$1 => Any)Unit
adapted xs.map: (f: _$1 => Any)Unit <and> (f: _$1 => Any)Unit to ?,
typing ((x) => ()): pt = ?: undetparams=, implicitsEnabled=true, enrichmentEnabled=true, mode=EXPRmode BYVALmode, silent=true, context.owner=method kaboom
typing (): pt = ?: undetparams=, implicitsEnabled=true, enrichmentEnabled=true, mode=EXPRmode, silent=true, context.owner=value $anonfun
typed (): Unit
adapted (): Unit to ?,
typed ((x: <error>) => ()): <error> => Unit
adapted ((x: <error>) => ()): <error> => Unit to ?,
no second try: xs.map and ((x: <error>) => ()) because error not in result: Disturbingly, |
@retronym said (edited on Jun 10, 2012 9:09:00 AM UTC): At least this example compiles with that reverted (actually, just with this line scala/scala@b7b81ca2#L0L567): trait FM[A] {
def map(f: A => Any)
}
trait M[A] extends FM[A] {
def map(f: A => Any)
}
object test {
def kaboom(xs: M[_]) = xs map (x => ()) // missing parameter type.
} Without this, {(f#7469: A#7103 => Any#3533)Unit#1690}.asSeenFrom(xs#8667.type, trait M#9)
tp1 = (f#8670: _$1#8669 => Any#3533)Unit#1690
result = (f#8673: _$1#8671 => Any#3533)Unit#1690 |
@retronym said: |
@retronym said: |
@adriaanm said: |
@retronym said: |
@adriaanm said (edited on Jun 19, 2012 1:36:34 PM UTC): |
@adriaanm said: |
@adriaanm said: |
@retronym said: val s: Set[_ >: Char] = Set('A')
s forall ("ABC" contains _)
s.forall( c => "ABC".toSeq.contains( c )) |
@paulp said: |
@adriaanm said: |
This compiled in 2.9, no longer.
If it's a type parameter bounded by AnyRef, compiles.
The text was updated successfully, but these errors were encountered: