@@ -685,27 +685,8 @@ class Semantic {
685
685
}
686
686
687
687
/** Evaluate a list of expressions */
688
- def eval (exprs : List [Tree ], thisV : Addr , klass : ClassSymbol ): Contextual [(List [Result ], Env )] = exprs match {
689
- case Nil => (Nil , env)
690
- case h :: t => h match {
691
- case v : ValDef => {
692
- val res = eval(h, thisV, klass)
693
- val newEnv =
694
- if res.value.promote(" Try early promotion" , h).isEmpty then Env (Map (v.symbol -> Hot )) else Env (Map (v.symbol -> res.value))
695
- withEnv(env.union(newEnv)) {
696
- val (res2, env2) = eval(t, thisV, klass)
697
- (res :: res2, env2)
698
- }
699
- }
700
- case _ => {
701
- val res = eval(h, thisV, klass)
702
- withEnv(env) {
703
- val (res2, env2) = eval(t, thisV, klass)
704
- (res :: res2, env2)
705
- }
706
- }
707
- }
708
- }
688
+ def eval (exprs : List [Tree ], thisV : Addr , klass : ClassSymbol ): Contextual [List [Result ]] =
689
+ exprs.map { expr => eval(expr, thisV, klass) }
709
690
710
691
/** Evaluate arguments of methods */
711
692
def evalArgs (args : List [Arg ], thisV : Addr , klass : ClassSymbol ): Contextual [(List [Error ], List [ArgInfo ])] =
@@ -869,7 +850,7 @@ class Semantic {
869
850
case vdef : ValDef =>
870
851
// local val definition
871
852
// TODO: support explicit @cold annotation for local definitions
872
- eval(vdef.rhs, thisV, klass)
853
+ eval(vdef.rhs, thisV, klass, true )
873
854
// .ensureHot("Local definitions may only hold initialized values", vdef)
874
855
875
856
case ddef : DefDef =>
@@ -915,7 +896,9 @@ class Semantic {
915
896
// It's always safe to approximate them with `Cold`.
916
897
Result (Cold , Nil )
917
898
else
918
- Result (env.getOrElse(sym, Hot ), Nil )
899
+ // resolve this for local variable
900
+ val enclosingClass = sym.owner.enclosingClass.asClass
901
+ val thisValue2 = resolveThis(enclosingClass, thisV, klass, source)
919
902
920
903
case tmref : TermRef =>
921
904
cases(tmref.prefix, thisV, klass, source).select(tmref.symbol, source)
0 commit comments