@@ -1036,9 +1036,9 @@ object Semantic:
1036
1036
extension (value : Value )
1037
1037
/** Promotion of values to hot */
1038
1038
def promote (msg : String ): Contextual [Unit ] = log(" promoting " + value + " , promoted = " + promoted, printer) {
1039
- if promoted.isCurrentObjectPromoted then Nil else
1039
+ if ! promoted.isCurrentObjectPromoted then
1040
1040
1041
- value. match
1041
+ value match
1042
1042
case Hot =>
1043
1043
1044
1044
case Cold =>
@@ -1099,8 +1099,9 @@ object Semantic:
1099
1099
*/
1100
1100
def tryPromote (msg : String ): Contextual [List [Error ]] = log(" promote " + warm.show + " , promoted = " + promoted, printer) {
1101
1101
val classRef = warm.klass.appliedRef
1102
- if classRef.memberClasses.nonEmpty || ! warm.isFullyFilled then
1103
- return PromoteError (msg, trace.toVector) :: Nil
1102
+ val hasInnerClass = classRef.memberClasses.filter(_.symbol.hasSource).nonEmpty
1103
+ if hasInnerClass then
1104
+ return PromoteError (msg + " Promotion cancelled as the value contains inner classes. " , trace.toVector) :: Nil
1104
1105
1105
1106
val errors = Reporter .stopEarly {
1106
1107
for klass <- warm.klass.baseClasses if klass.hasSource do
@@ -1635,7 +1636,8 @@ object Semantic:
1635
1636
if thisV.isThisRef || ! thisV.asInstanceOf [Warm ].isPopulatingParams then tpl.body.foreach {
1636
1637
case vdef : ValDef if ! vdef.symbol.is(Flags .Lazy ) && ! vdef.rhs.isEmpty =>
1637
1638
val res = eval(vdef.rhs, thisV, klass)
1638
- thisV.updateField(vdef.symbol, res)
1639
+ val hasErrors = Reporter .hasErrors { res.promote(" try promote value to hot" ) }
1640
+ thisV.updateField(vdef.symbol, if hasErrors then res else Hot )
1639
1641
fieldsChanged = true
1640
1642
1641
1643
case _ : MemberDef =>
0 commit comments