@@ -1181,10 +1181,37 @@ class Objects(using Context @constructorOnly):
1181
1181
1182
1182
case v @ SafeValue (_) =>
1183
1183
if v.typeSymbol != defn.NullClass then
1184
- // selection on Null is sensible on AST level; no warning for it
1184
+ // call on Null is sensible on AST level but not in practice
1185
1185
report.warning(" [Internal error] Unexpected selection on safe value " + v.show + " , field = " + field.show + " . " + Trace .show, Trace .position)
1186
1186
end if
1187
1187
Bottom
1188
+ // case v @ SafeValue(_) =>
1189
+ // if v.typeSymbol == defn.NullClass then
1190
+ // // call on Null is sensible on AST level but not in practice
1191
+ // Bottom
1192
+ // else if field.is(Flags.Method) then
1193
+ // // Assume such method is pure. Check return type, only try to analyze body if return type is not safe
1194
+ // val target = resolve(v.typeSymbol.asClass, field)
1195
+ // val targetInfo = target.info
1196
+
1197
+ // val returnType = targetInfo match {
1198
+ // case tpe: MethodicType => tpe.resType
1199
+ // case _ =>
1200
+ // report.warning("[Internal error] Unexpected selection on safe value " + v.show + ", field = " + field.show + " with type " + targetInfo.show + ". " + Trace.show, Trace.position)
1201
+ // Bottom
1202
+ // }
1203
+
1204
+ // val typeSymbol = SafeValue.getSafeTypeSymbol(returnType)
1205
+ // if typeSymbol.isDefined then
1206
+ // // since method is pure and return type is safe, no need to analyze method body
1207
+ // SafeValue(typeSymbol.get)
1208
+ // else if !target.hasSource then
1209
+ // UnknownValue
1210
+ // else
1211
+ // call(v, target, args = Nil, receiver = receiver, superType = NoType, needResolve = false)
1212
+ // else
1213
+ // report.warning("[Internal error] Unexpected selection of a non-method on safe value " + v.show + ", field = " + field.show + ". " + Trace.show, Trace.position)
1214
+ // Bottom
1188
1215
1189
1216
case Package (packageModuleClass) =>
1190
1217
if field.isStaticObject then
@@ -1580,7 +1607,13 @@ class Objects(using Context @constructorOnly):
1580
1607
val target = expr.tpe.widenSingleton.classSymbol.asClass
1581
1608
withTrace(trace2) { resolveThis(target, qual.asInstanceOf [ThisValue ], klass) }
1582
1609
case _ =>
1583
- withTrace(trace2) { select(qual, expr.symbol, receiver = qualifier.tpe) }
1610
+ qual match {
1611
+ // Check if expression is a selection of a method
1612
+ case v : SafeValue if expr.symbol.is(Flags .Method ) =>
1613
+ withTrace(trace2) { call(v, expr.symbol, args = Nil , receiver = qualifier.tpe, superType = NoType ) }
1614
+ case _ =>
1615
+ withTrace(trace2) { select(qual, expr.symbol, receiver = qualifier.tpe) }
1616
+ }
1584
1617
1585
1618
case _ : This =>
1586
1619
evalType(expr.tpe, thisV, klass)
0 commit comments