Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.2
    • Fix Version/s: None
    • Component/s: Reflection
    • Labels:
      None

      Description

      import scala.tools.nsc.reporters._
      import scala.tools.nsc.Settings
      import reflect.runtime.Mirror.ToolBox
      
      object Test extends App {
        val code = scala.reflect.Code.lift{
          def factorial(n: BigInt): BigInt =
            if (n == 0) 1 else n * factorial(n-1)
      
          val f50 = factorial(50); val f49 = factorial(49)
          println("50! = " + f50)
          println("49! = " + f49)
          println("50!/49! = " + (f50 / f49))
        };
      
        val reporter = new ConsoleReporter(new Settings)
        val toolbox = new ToolBox(reporter)
        val ttree = toolbox.typeCheck(code.tree)
        toolbox.runExpr(ttree)
      }
      
      error: recursive method factorial needs result type
      java.lang.ClassNotFoundException: __wrapper$1$
        at scala.tools.nsc.interpreter.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:65)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at scala.tools.nsc.interpreter.AbstractFileClassLoader.scala$tools$nsc$util$ScalaClassLoader$$super$loadClass(AbstractFileClassLoader.scala:18)
        at scala.tools.nsc.util.ScalaClassLoader$class.loadClass(ScalaClassLoader.scala:63)
        at scala.tools.nsc.interpreter.AbstractFileClassLoader.loadClass(AbstractFileClassLoader.scala:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxGlobal.runExpr(ToolBoxes.scala:93)
        at scala.reflect.runtime.ToolBoxes$ToolBox.runExpr(ToolBoxes.scala:162)
        at scala.reflect.runtime.ToolBoxes$ToolBox.runExpr(ToolBoxes.scala:165)
        at Test$delayedInit$body.apply(reify_abstracttypes.scala:19)
        at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
        at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
        at scala.App$$anonfun$main$1.apply(App.scala:61)
        at scala.App$$anonfun$main$1.apply(App.scala:61)
        at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
        at scala.collection.immutable.List.foreach(List.scala:77)
        at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:31)
        at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:42)
        at scala.App$class.main(App.scala:61)
        at Test$.main(reify_abstracttypes.scala:5)
        at Test.main(reify_abstracttypes.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:90)
        at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:38)
        at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:159)
        at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:90)
        at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:159)
        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:70)
        at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:92)
        at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:101)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
      

        Activity

        Show
        Eugene Burmako added a comment - Fixed by https://github.com/scala/scala/commit/d940371bd50098c4146e52941880ccdbcb4ea47a

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development