Skip to content

Commit dd5fa60

Browse files
committed
SI-7558 Fix capture of free local vars in toolbox compiler
It was creating an `ObjectRef[<notype>]` because of a small bug in `capturedVariableType`.
1 parent 1472dad commit dd5fa60

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/reflect/scala/reflect/internal/CapturedVariables.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ trait CapturedVariables { self: SymbolTable =>
2929
def refType(valueRef: Map[Symbol, Symbol], objectRefClass: Symbol) =
3030
if (isPrimitiveValueClass(symClass) && symClass != UnitClass) valueRef(symClass).tpe
3131
else if (erasedTypes) objectRefClass.tpe
32-
else appliedType(objectRefClass, tpe)
32+
else appliedType(objectRefClass, tpe1)
3333
if (vble.hasAnnotation(VolatileAttr)) refType(volatileRefClass, VolatileObjectRefClass)
3434
else refType(refClass, ObjectRefClass)
3535
}

test/files/run/t7558.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
object Test extends App {
2+
val cm = reflect.runtime.currentMirror
3+
val u = cm.universe
4+
import scala.tools.reflect.ToolBox
5+
val tb = cm.mkToolBox()
6+
val t = { var x = "ab".toList; u.reify { x = x.reverse; x }.tree }
7+
val evaluated = tb.eval(t)
8+
assert(evaluated == "ba".toList, evaluated)
9+
}

0 commit comments

Comments
 (0)