Skip to content
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

inferred existential type crasher #4869

Closed
scabug opened this issue Aug 3, 2011 · 2 comments
Closed

inferred existential type crasher #4869

scabug opened this issue Aug 3, 2011 · 2 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Aug 3, 2011

I initially reported this about getClass, but actually it has nothing to do with it.

class C[T]
class A {
  def f[T](x: T): C[_ <: T] = null
  def g = List(1d) map f
}
% scalac3 ./a.scala 
exception when traversing ((x: Double) => A.this.f[Double](x))
...
error: scala.reflect.internal.Types$TypeError: type mismatch;
 found   : C[(some other)_$1(in value $anonfun)] where type (some other)_$1(in value $anonfun) <: T
 required: C[_ <: Double]
	at scala.tools.nsc.typechecker.Contexts$Context.error(Contexts.scala:295)
	at scala.tools.nsc.typechecker.Infer$Inferencer.error(Infer.scala:207)
	at scala.tools.nsc.typechecker.Infer$Inferencer.typeError(Infer.scala:217)

The problem is hinted at via -Yinfer-debug:

[inferImplicit] result: SearchResult(immutable.this.List.canBuildFrom[C[_ <: Double]], TreeTypeSubstituter(List(type That),List(List[C[_ <: Double]])))

The type C[_ <: T] is inferred at multiple points, and the trip through inference ends up unpacking more than one existential. This is not too surprising given how much is taking place in a line like List(1d) map f.

@scabug
Copy link
Author

scabug commented Aug 3, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4869?orig=1
Reporter: @paulp

@scabug scabug closed this as completed Jan 14, 2012
@scabug
Copy link
Author

scabug commented Jan 14, 2012

@paulp said:
066b1a1f5d

@scabug scabug added this to the 2.10.0 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants