[SI-5816] Runtime error with Scala reflection Created: 21/May/12  Updated: 04/Jan/13  Resolved: 09/Jun/12

Status: CLOSED
Project: Scala Programming Language
Component/s: Compiler (Misc)
Affects Version/s: Scala 2.10.0-M3
Fix Version/s: Scala 2.10.0-M3

Type: Bug Priority: Major
Reporter: Stephane Micheloud Assignee: Eugene Burmako
Resolution: Fixed Votes: 0
Labels: None


import scala.reflect.mirror._
object Test extends App {
  val toolbox = mkToolBox()
  def printSource[T](expr: Expr[T]) {
    val ttree = toolbox typeCheck expr.tree
  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)

Comment by Eugene Burmako [ 09/Jun/12 ]

Fixed in https://github.com/scala/scala/commit/6bb5975289c5b11cb8c88dd4629286956b5d3d27

Generated at Fri Nov 16 17:20:14 CET 2018 using JIRA 7.9.1#79001-sha1:60970b42586a2ec2760ed6cfe825b26961e62b9e.