It appears that passing an alias to a wild-carded parameterized type to a function that tries to get an implicit Manifest
for the type will crash the Scala 2.11.5 compiler.
The following can be pasted in the 2.11.5 REPL to reproduce the crash:
class C[T]
def f[T](implicit m: Manifest[T]) = 0
type CAlias = C[_]
val x = f[CAlias]
The crash output is very verbose, but contains this info:
scala.reflect.internal.FatalError:
?MethodType?
while compiling: <console>
during phase: globalPhase=erasure, enteringPhase=posterasure
library version: version 2.11.5
compiler version: version 2.11.5
reconstructed args:
last tree to typer: type $iw
tree position: line 9 of <console>
tree tpe: <notype>
symbol: object $iw
symbol definition: class $iw extends Object (a ModuleClassSymbol)
symbol package: $line10
symbol owners: object $iw -> object $iw -> object $read
call site: object $iw in package $line10
There are several conditions for this crash. The type C
must be parameterized. The alias must use a wildcard (C[_]
). The call must use a type alias, just calling f[C[_]]
works fine.
In my program the case is far more complex, and the only solution I've found is to have the method not accept a Manifest
, but just take a Class
parameter instead, which is ugly.
Am I doing something wrong? Any suggestions for better workaround? I didn't see a bug in the Scala bug tracker, so if this seems legit, I'll go ahead and report it.