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

reflection in REPL gives an error when runExpr is called the third time on a tree

    Details

      Description

      I've tried using -Yrepl-sync as well, but with the same results. It is always on the third runExpr that I got the error below (it doesn't matter whether I used the same or different trees).

      Welcome to Scala version 2.10.0-20120825-035903-a23edefac6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
      Type in expressions to have them evaluated.
      Type :help for more information.
      
      scala> import scala.reflect.runtime.{universe => u}
      import scala.reflect.runtime.{universe=>u}
      
      scala> import scala.tools.reflect.ToolBox
      import scala.tools.reflect.ToolBox
      
      scala> import scala.reflect.runtime.{currentMirror => m}
      import scala.reflect.runtime.{currentMirror=>m}
      
      scala> val tb = m.mkToolBox()
      tb: scala.tools.reflect.ToolBox[reflect.runtime.universe.type] = scala.tools.reflect.ToolBoxFactory$ToolBoxImpl@42ff665a
      
      scala> val t1 = tb.parseExpr("1 to 3 map (_+1)")
      t1: tb.u.Tree = 1.to(3).map(((x$1) => x$1.$plus(1)))
      
      scala> tb.runExpr(t1)
      res1: Any = Vector(2, 3, 4)
      
      scala> tb.runExpr(t1)
      res2: Any = Vector(2, 3, 4)
      
      scala> tb.runExpr(t1)
      scala.tools.reflect.ToolBoxError: reflective compilation has failed: 
      
      anonymous class $anonfun$wrapper$1 is defined twice
        conflicting symbols both originated in file '<no file>'
      	at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.throwIfErrors(ToolBoxFactory.scala:295)
      	at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.compileExpr(ToolBoxFactory.scala:223)
      	at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.runExpr(ToolBoxFactory.scala:251)
      	at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.runExpr(ToolBoxFactory.scala:393)
      	at .<init>(<console>:13)
      	at .<clinit>(<console>)
      	at .<init>(<console>:7)
      	at .<clinit>(<console>)
      	at $print(<console>)
      	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.interpreter.IMain$ReadEvalPrint.call(IMain.scala:732)
      	at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:981)
      	at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:571)
      	at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:602)
      	at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:566)
      	at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:745)
      	at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:790)
      	at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:702)
      	at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:566)
      	at scala.tools.nsc.interpreter.ILoop.innerLoop$1(ILoop.scala:573)
      	at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:576)
      	at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:867)
      	at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:822)
      	at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:822)
      	at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
      	at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:822)
      	at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:83)
      	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)
      
      

        Activity

        Show
        Eugene Burmako added a comment - https://github.com/scala/scala/pull/1327
        Hide
        Grzegorz Kossakowski added a comment -
        Show
        Grzegorz Kossakowski added a comment - Fixed in https://github.com/scala/scala/pull/1327

          People

          • Assignee:
            Eugene Burmako
            Reporter:
            arjan blokzijl
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development