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

Runtime error with Scala reflection #5816

Closed
scabug opened this Issue May 21, 2012 · 2 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented May 21, 2012

import scala.reflect.mirror._

object Test extends App {
  val toolbox = mkToolBox()

  def printSource[T](expr: Expr[T]) {
    val ttree = toolbox typeCheck expr.tree
    println(ttree.toString)
  }

  var y = 3
  printSource(reify {
    5 + y
  })
}

Compiler output:

scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxError: reflective typecheck has failed: object y is not a member of package Test
	at scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxGlobal$$anonfun$typeCheckExpr$2.apply(ToolBoxes.scala:125)
	at scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxGlobal$$anonfun$typeCheckExpr$2.apply(ToolBoxes.scala:106)
	at scala.tools.nsc.typechecker.Contexts$Context.withMacrosEnabled(Contexts.scala:221)
  [...]
@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 21, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5816?orig=1
Reporter: @michelou
Affected Versions: 2.10.0-M3

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Jun 9, 2012

@xeno-by said:
Fixed in scala/scala@6bb5975

@scabug scabug closed this Jun 9, 2012

@scabug scabug added this to the 2.10.0-M3 milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment