@@ -1138,20 +1138,34 @@ object Semantic:
1138
1138
1139
1139
val errors = Reporter .stopEarly {
1140
1140
for klass <- warm.klass.baseClasses if klass.hasSource do
1141
- for member <- klass.info.decls do
1142
- if ! member.isType && ! member.isConstructor && member.hasSource && ! member.is(Flags .Deferred ) then
1143
- if member.is(Flags .Method , butNot = Flags .Accessor ) then
1144
- withTrace(Trace .empty) {
1145
- val args = member.info.paramInfoss.flatten.map(_ => ArgInfo (Hot , Trace .empty))
1146
- val res = warm.call(member, args, receiver = warm.klass.typeRef, superType = NoType )
1147
- res.promote(" Cannot prove that the return value of " + member.show + " is hot. Found = " + res.show + " . " )
1148
- }
1149
- else
1150
- withTrace(Trace .empty) {
1151
- val res = warm.select(member, receiver = warm.klass.typeRef)
1152
- res.promote(" Cannot prove that the field " + member.show + " is hot. Found = " + res.show + " . " )
1153
- }
1154
- end for
1141
+ val obj = warm.objekt
1142
+ val outer = obj.outer(klass)
1143
+ val ctor = klass.primaryConstructor
1144
+ val hotSegmentCountered = ! ctor.hasSource || outer.isHot && {
1145
+ val ctorDef = ctor.defTree.asInstanceOf [DefDef ]
1146
+ val params = ctorDef.termParamss.flatten.map(_.symbol)
1147
+ // We have cached all parameters on the object
1148
+ params.forall(param => obj.field(param).isHot)
1149
+ }
1150
+
1151
+ // If the outer and parameters of a class are all hot, then accessing fields and methods of the current
1152
+ // segment of the object should be OK. They may only create problems via virtual method calls on `this`, but
1153
+ // those methods are checked as part of the check for the class where they are defined.
1154
+ if ! hotSegmentCountered then
1155
+ for member <- klass.info.decls do
1156
+ if ! member.isType && ! member.isConstructor && member.hasSource && ! member.is(Flags .Deferred ) then
1157
+ if member.is(Flags .Method , butNot = Flags .Accessor ) then
1158
+ withTrace(Trace .empty) {
1159
+ val args = member.info.paramInfoss.flatten.map(_ => ArgInfo (Hot , Trace .empty))
1160
+ val res = warm.call(member, args, receiver = warm.klass.typeRef, superType = NoType )
1161
+ res.promote(" Cannot prove that the return value of " + member.show + " is hot. Found = " + res.show + " . " )
1162
+ }
1163
+ else
1164
+ withTrace(Trace .empty) {
1165
+ val res = warm.select(member, receiver = warm.klass.typeRef)
1166
+ res.promote(" Cannot prove that the field " + member.show + " is hot. Found = " + res.show + " . " )
1167
+ }
1168
+ end for
1155
1169
end for
1156
1170
}
1157
1171
0 commit comments