@@ -694,27 +694,8 @@ class Semantic {
694
694
}
695
695
696
696
/** Evaluate a list of expressions */
697
- def eval (exprs : List [Tree ], thisV : Addr , klass : ClassSymbol ): Contextual [(List [Result ], Env )] = exprs match {
698
- case Nil => (Nil , env)
699
- case h :: t => h match {
700
- case v : ValDef => {
701
- val res = eval(h, thisV, klass)
702
- val newEnv =
703
- if res.value.promote(" Try early promotion" , h).isEmpty then Env (Map (v.symbol -> Hot )) else Env (Map (v.symbol -> res.value))
704
- withEnv(env.union(newEnv)) {
705
- val (res2, env2) = eval(t, thisV, klass)
706
- (res :: res2, env2)
707
- }
708
- }
709
- case _ => {
710
- val res = eval(h, thisV, klass)
711
- withEnv(env) {
712
- val (res2, env2) = eval(t, thisV, klass)
713
- (res :: res2, env2)
714
- }
715
- }
716
- }
717
- }
697
+ def eval (exprs : List [Tree ], thisV : Addr , klass : ClassSymbol ): Contextual [List [Result ]] =
698
+ exprs.map { expr => eval(expr, thisV, klass) }
718
699
719
700
/** Evaluate arguments of methods */
720
701
def evalArgs (args : List [Arg ], thisV : Addr , klass : ClassSymbol ): Contextual [(List [Error ], List [ArgInfo ])] =
@@ -878,7 +859,7 @@ class Semantic {
878
859
case vdef : ValDef =>
879
860
// local val definition
880
861
// TODO: support explicit @cold annotation for local definitions
881
- eval(vdef.rhs, thisV, klass)
862
+ eval(vdef.rhs, thisV, klass, true )
882
863
// .ensureHot("Local definitions may only hold initialized values", vdef)
883
864
884
865
case ddef : DefDef =>
@@ -924,7 +905,9 @@ class Semantic {
924
905
// It's always safe to approximate them with `Cold`.
925
906
Result (Cold , Nil )
926
907
else
927
- Result (env.getOrElse(sym, Hot ), Nil )
908
+ // resolve this for local variable
909
+ val enclosingClass = sym.owner.enclosingClass.asClass
910
+ val thisValue2 = resolveThis(enclosingClass, thisV, klass, source)
928
911
929
912
case tmref : TermRef =>
930
913
cases(tmref.prefix, thisV, klass, source).select(tmref.symbol, source)
0 commit comments