Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
scabug opened this issue Aug 27, 2012 · 3 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Aug 27, 2012

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)
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 27, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6287?orig=1
Reporter: arjan blokzijl (arjanblokzijl)
Affected Versions: 2.10.0
Other Milestones: 2.10.0

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 17, 2012

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 19, 2012

@scabug scabug closed this Sep 19, 2012
@scabug scabug added this to the 2.10.0-M7 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.