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

Compiler Crash with manifest type-aliased existential type #9155

Closed
scabug opened this issue Feb 16, 2015 · 5 comments
Closed

Compiler Crash with manifest type-aliased existential type #9155

scabug opened this issue Feb 16, 2015 · 5 comments

Comments

@scabug
Copy link

scabug commented Feb 16, 2015

I found a crash bug in the compiler & REPL related to type aliases of wild-carded types. Compiling or running the following in the REPL, version 2.11.5, will produce a compiler crash:

class C[T]
def f[T](implicit m: Manifest[T]) = 0

type CAlias = C[_]
val x = f[CAlias]

There are several conditions for this crash: the type C must be parameterized, the alias must use a wildcard (C[_]), and finally, the call must use a type alias (just calling f[C[_]] works fine).

For reference, I have also created the following stack overflow regarding the issue: http://stackoverflow.com/questions/28510867/scala-2-11-5-compiler-crash-with-type-aliases-and-manifests

@scabug
Copy link
Author

scabug commented Feb 16, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9155?orig=1
Reporter: Yona Appletree (Yona.Appletree)
Affected Versions: 2.11.5

@scabug
Copy link
Author

scabug commented Jun 14, 2015

@retronym said:
From the duplicate:

class M[T]
 
object M {
  type Any = M[ _ <: String]
}
 
manifest[M[_ <: String]] // Ok
manifest[M.Any]   // crash

@adriaanm
Copy link
Contributor

We should at least crash a bit more informatively.

@adriaanm adriaanm modified the milestones: Backlog, 2.12.5 Jan 11, 2018
@lrytz
Copy link
Member

lrytz commented Mar 5, 2018

Here's a fix: scala/scala#6380 - submitted to check how it does on the test suite.

@adriaanm / @retronym does that look viable? What I see in the debugger:

  • tp is A.T, the type alias. So in the first call to mot, tp0 is A.T
  • tp1 = tp0.dealias is an ExistentialType, so mot called recursively with tp0 = tp1.skolemizeExistential.

The reason I picked tp.dealias in my patch is simply because it makes the example work, because the cast is inserted (like when the direct type A[_] is used instead of the alias). It's not that I understand the code very well :)

@lrytz
Copy link
Member

lrytz commented Mar 8, 2018

scala/scala#6380

@lrytz lrytz closed this as completed Mar 8, 2018
@lrytz lrytz assigned lrytz and unassigned retronym Mar 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants