@@ -928,38 +928,41 @@ object Semantic {
928
928
extension (value : Value )
929
929
/** Promotion of values to hot */
930
930
def promote (msg : String , source : Tree ): Contextual [Unit ] = log(" promoting " + value + " , promoted = " + promoted, printer) {
931
+ val trace2 = trace.add(source)
931
932
if promoted.isCurrentObjectPromoted then Nil else
933
+ given Trace = trace2
932
934
933
- value.match
934
- case Hot =>
935
+ value.match
936
+ case Hot =>
935
937
936
- case Cold =>
937
- reporter.report(PromoteError (msg, source, trace.toVector))
938
-
939
- case thisRef : ThisRef =>
940
- if ! thisRef.tryPromoteCurrentObject() then
938
+ case Cold =>
941
939
reporter.report(PromoteError (msg, source, trace.toVector))
942
940
943
- case warm : Warm =>
944
- if ! promoted.contains(warm) then
945
- promoted.add(warm)
946
- val errors = warm.tryPromote(msg, source)
947
- if errors.nonEmpty then promoted.remove(warm)
948
- for error <- errors do reporter.report(error)
949
-
950
- case fun @ Fun (body, thisV, klass, env) =>
951
- if ! promoted.contains(fun) then
952
- val errors = Reporter .stopEarly {
953
- val res = withEnv(env) { eval(body, thisV, klass) }
954
- res.promote(" The function return value is not fully initialized." , source)
955
- }
956
- if (errors.nonEmpty)
957
- reporter.report(UnsafePromotion (msg, source, trace.toVector, errors))
958
- else
959
- promoted.add(fun)
941
+ case thisRef : ThisRef =>
942
+ if ! thisRef.tryPromoteCurrentObject() then
943
+ reporter.report(PromoteError (msg, source, trace.toVector))
944
+
945
+ case warm : Warm =>
946
+ if ! promoted.contains(warm) then
947
+ promoted.add(warm)
948
+ val errors = warm.tryPromote(msg, source)
949
+ if errors.nonEmpty then promoted.remove(warm)
950
+ for error <- errors do reporter.report(error)
951
+
952
+ case fun @ Fun (body, thisV, klass, env) =>
953
+ if ! promoted.contains(fun) then
954
+ val errors = Reporter .stopEarly {
955
+ given Trace = Trace .empty.add(body)
956
+ val res = withEnv(env) { eval(body, thisV, klass) }
957
+ res.promote(" The function return value is not fully initialized." , body)
958
+ }
959
+ if (errors.nonEmpty)
960
+ reporter.report(UnsafePromotion (msg, source, trace.toVector, errors.head))
961
+ else
962
+ promoted.add(fun)
960
963
961
- case RefSet (refs) =>
962
- refs.foreach(_.promote(msg, source))
964
+ case RefSet (refs) =>
965
+ refs.foreach(_.promote(msg, source))
963
966
}
964
967
end extension
965
968
@@ -1005,7 +1008,7 @@ object Semantic {
1005
1008
}
1006
1009
1007
1010
if errors.isEmpty then Nil
1008
- else UnsafePromotion (msg, source, trace.toVector, errors) :: Nil
1011
+ else UnsafePromotion (msg, source, trace.toVector, errors.head ) :: Nil
1009
1012
}
1010
1013
1011
1014
end extension
@@ -1281,7 +1284,6 @@ object Semantic {
1281
1284
1282
1285
case vdef : ValDef =>
1283
1286
// local val definition
1284
- // TODO: support explicit @cold annotation for local definitions
1285
1287
eval(vdef.rhs, thisV, klass)
1286
1288
1287
1289
case ddef : DefDef =>
0 commit comments