@@ -398,6 +398,7 @@ class Objects(using Context @constructorOnly):
398
398
case Some (theValue) =>
399
399
theValue
400
400
case _ =>
401
+ throw new RuntimeException (" valValue" )
401
402
report.warning(" [Internal error] Value not found " + x.show + " \n env = " + data.show + " . " + Trace .show, Trace .position)
402
403
Bottom
403
404
@@ -771,9 +772,9 @@ class Objects(using Context @constructorOnly):
771
772
end if
772
773
773
774
case _ =>
774
- // by-name closure
775
- given Env . Data = env
776
- extendTrace(code) { eval(code, thisV, klass, cacheResult = true ) }
775
+ // Should be unreachable, by-name closures are handled by readLocal
776
+ report.warning( " [Internal error] Only DefDef should be possible here, but found " + code.show + " . " + Trace .show, Trace .position)
777
+ Bottom
777
778
778
779
case ValueSet (vs) =>
779
780
vs.map(v => call(v, meth, args, receiver, superType)).join
@@ -976,12 +977,13 @@ class Objects(using Context @constructorOnly):
976
977
* @param sym The symbol of the variable.
977
978
* @param value The value of the initializer.
978
979
*/
979
- def initLocal (sym : Symbol , value : Value ): Contextual [Unit ] = log(" initialize local " + sym.show + " with " + value.show, printer) {
980
+ def initLocal (sym : Symbol , value : Value )( using data : Env . Data , ctx : Context ) : Contextual [Unit ] = log(" initialize local " + sym.show + " with " + value.show, printer) {
980
981
if sym.is(Flags .Mutable ) then
981
982
val addr = Heap .localVarAddr(summon[Regions .Data ], sym, State .currentObject)
982
983
Env .setLocalVar(sym, addr)
983
984
Heap .writeJoin(addr, value)
984
985
else
986
+ System .out.println(" initLocal sym: " + sym.show + " val: " + value.show + " data: " + data.show)
985
987
Env .setLocalVal(sym, value)
986
988
}
987
989
@@ -1015,12 +1017,15 @@ class Objects(using Context @constructorOnly):
1015
1017
val rhs = sym.defTree.asInstanceOf [ValDef ].rhs
1016
1018
eval(rhs, thisV, sym.enclosingClass.asClass, cacheResult = true )
1017
1019
else
1020
+ System .out.println(" env: " + env.show)
1021
+ System .out.println(" sym: " + sym.show)
1018
1022
// Assume forward reference check is doing a good job
1019
1023
val value = Env .valValue(sym)
1020
1024
if isByNameParam(sym) then
1021
1025
value match
1022
1026
case fun : Fun =>
1023
1027
given Env .Data = Env .ofByName(sym, fun.env)
1028
+ System .out.println(" created new env " + fun.code.show)
1024
1029
eval(fun.code, fun.thisV, fun.klass)
1025
1030
case Cold =>
1026
1031
report.warning(" Calling cold by-name alias. " + Trace .show, Trace .position)
0 commit comments