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

Toolboxes can't compile references to synthetic classes that scalac can compile

    Details

      Description

      package test
      
      class Separate {
        for (i <- 1 to 10) println(i)
      }
      
      import scala.reflect.runtime.universe._
      import scala.reflect.runtime.{currentMirror => cm}
      import scala.tools.reflect.ToolBox
      
      object Test extends App {
        val tb = cm.mkToolBox()
        val code = tb.parse("{ val x: test.Separate$$anonfun$1 = null; x }")
        println(tb.eval(code))
      }
      
      14:36 ~/Projects/210x/sandbox (2.10.x)$ scalac Separate.scala && scalac Test.scala && scala Test
      scala.tools.reflect.ToolBoxError: reflective compilation has failed:
      
      type Separate$$anonfun$1 is not a member of package test
      	at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.throwIfErrors(ToolBoxFactory.scala:311)
      	at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.compile(ToolBoxFactory.scala:245)
      	at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.compile(ToolBoxFactory.scala:408)
      	at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.eval(ToolBoxFactory.scala:411)
      	at Test$delayedInit$body.apply(Test.scala:8)
      	at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
      	at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
      	at scala.App$$anonfun$main$1.apply(App.scala:71)
      	at scala.App$$anonfun$main$1.apply(App.scala:71)
      	at scala.collection.immutable.List.foreach(List.scala:318)
      	at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
      	at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:45)
      	at scala.App$class.main(App.scala:71)
      	at Test$.main(Test.scala:5)
      	at Test.main(Test.scala)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:71)
      	at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
      	at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:139)
      	at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:71)
      	at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:139)
      	at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:28)
      	at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:45)
      	at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:35)
      	at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:45)
      	at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:74)
      	at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
      	at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
      	at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
      

        Issue Links

          Activity

          Show
          Eugene Burmako added a comment - https://github.com/scala/scala/pull/2809

            People

            • Assignee:
              Eugene Burmako
              Reporter:
              Eugene Burmako
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development