Scala Programming Language
  1. Scala Programming Language
  2. SI-7558

toolbox compiler fails to capture free local vars

    Details

      Description

      scala-hash v2.10.2-RC2 -nc # same with 2.11.0-M3
      [info] v2.10.2-RC => /Users/jason/usr/scala-v2.10.2-RC2-0-g60d462e
      Welcome to Scala version 2.10.2-20130530-074427-60d462ef6e (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37).
      Type in expressions to have them evaluated.
      Type :help for more information.
      
      scala> val cm = reflect.runtime.currentMirror; val u = cm.universe; import scala.tools.reflect.ToolBox; val tb = cm.mkToolBox()
      cm: reflect.runtime.universe.Mirror = JavaMirror with scala.tools.nsc.interpreter.IMain$TranslatingClassLoader@78c0dc2 of type class scala.tools.nsc.interpreter.IMain$TranslatingClassLoader with classpath [(memory)] and parent being scala.tools.nsc.util.ScalaClassLoader$URLClassLoader@7bdb3f6c of type class scala.tools.nsc.util.ScalaClassLoader$URLClassLoader with classpath [file:/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Classes/classes.jar,file:/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Classes/ui.jar,file:/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Classes/jsse.jar,file:/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Classes/jce.jar,file:/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Classe...
      scala> var t = { var x = "ab".toList; u.reify { x = x.reverse; x }.tree }
      t: u.Tree =
      {
        x.elem = x.elem.reverse;
        x.elem
      }
      
      scala> tb.eval(t)
      scala.tools.reflect.ToolBoxError: reflective compilation has failed:
      
      value reverse is not a member of <notype>
      type mismatch;
       found   : <notype>
       required: Any
      Note that <none> extends Any, not AnyRef.
      Such types can participate in value classes, but instances
      cannot appear in singleton types or in reference comparisons.
      	at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.throwIfErrors(ToolBoxFactory.scala:311)
      

      I have a patch for this.

        Issue Links

          Activity

          Show
          Jason Zaugg added a comment - https://github.com/scala/scala/pull/2629

            People

            • Assignee:
              Jason Zaugg
              Reporter:
              Jason Zaugg
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development