Re: Toolbox typecheck throws MatchError for higher-kinded path-dependent type
Jason Zaugg <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <CAG3_yeWzu_6GD7pxDDaAJpVNtJgBbvqnaSXGrgOm-EUSnbf8bA@mail.gmail.com> |
On Wed, Jul 29, 2015 at 6:54 AM Daniel Armak <[email protected]> wrote: > Hi, > > I encountered this error trying to compile code that uses the shapeless > ~?> typeclass with the toolbox, and simplified it to this: > > > import scala.reflect.runtime.currentMirror > import scala.tools.reflect.ToolBox > > val tb = ToolBox(currentMirror).mkToolBox() > val source = """{ > import scala.language.higherKinds > > class Outer[X] { > class Inner[Y] > } > class Other[T[_]] > > new Other[Outer[Int]#Inner]() > }""" > > val tree = tb.parse(source) > tb.typecheck(tree).tpe > > This fails with: > > Exception in thread "main" scala.MatchError: <tree with deferred refcheck> (of class scala.tools.nsc.ast.Trees$TypeTreeWithDeferredRefCheck) > at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:309) > > (Full stack trace here > <https://gist.github.com/danarmak/c917b4f35e5d4d6ccbc7>) > > I’m using scala 2.11.7. > Thanks for the report. The bug is in Importers, which copies a tree from one compiler universe into another. I notice that @mandubian also ran into the same problem <https://gist.github.com/mandubian/807961eb9a8911f45894>. It fails to account for a special tree, TypeTreeWithDeferredWithRefCheck that exists between the typer and refchecks compiler phases, and is used when typechecking higher kinded type applications. I’ve lodged your report as SI-9421 <https://issues.scala-lang.org/browse/SI-9421>. Fixing it would require adding a default case in src/reflect/scala/reflect/internal/Importers.scala importTree that forwarded to an extension hook that could be implemented in nsc.Global. This pattern is already used in TreePrinters, see in particular xprinttree <https://github.com/scala/scala/blob/v2.11.6/src/compiler/scala/tools/nsc/ast/Printers.scala#L46-46> -jason -- You received this message because you are subscribed to the Google Groups "scala-language" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.