@@ -928,38 +928,41 @@ object Semantic {
928928 extension (value : Value )
929929 /** Promotion of values to hot */
930930 def promote (msg : String , source : Tree ): Contextual [Unit ] = log(" promoting " + value + " , promoted = " + promoted, printer) {
931+ val trace2 = trace.add(source)
931932 if promoted.isCurrentObjectPromoted then Nil else
933+ given Trace = trace2
932934
933- value.match
934- case Hot =>
935+ value.match
936+ case Hot =>
935937
936- case Cold =>
937- reporter.report(PromoteError (msg, source, trace.toVector))
938-
939- case thisRef : ThisRef =>
940- if ! thisRef.tryPromoteCurrentObject() then
938+ case Cold =>
941939 reporter.report(PromoteError (msg, source, trace.toVector))
942940
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)
960963
961- case RefSet (refs) =>
962- refs.foreach(_.promote(msg, source))
964+ case RefSet (refs) =>
965+ refs.foreach(_.promote(msg, source))
963966 }
964967 end extension
965968
@@ -1005,7 +1008,7 @@ object Semantic {
10051008 }
10061009
10071010 if errors.isEmpty then Nil
1008- else UnsafePromotion (msg, source, trace.toVector, errors) :: Nil
1011+ else UnsafePromotion (msg, source, trace.toVector, errors.head ) :: Nil
10091012 }
10101013
10111014 end extension
@@ -1281,7 +1284,6 @@ object Semantic {
12811284
12821285 case vdef : ValDef =>
12831286 // local val definition
1284- // TODO: support explicit @cold annotation for local definitions
12851287 eval(vdef.rhs, thisV, klass)
12861288
12871289 case ddef : DefDef =>
0 commit comments