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 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

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 3, 2011

@scabug scabug closed this Jan 14, 2012
@scabug

This comment has been minimized.

Copy link
Author

@scabug 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.