@@ -295,9 +295,10 @@ extends NotFoundMsg(MissingIdentID) {
295295class TypeMismatch (val found : Type , expected : Type , val inTree : Option [untpd.Tree ], addenda : => String * )(using Context )
296296 extends TypeMismatchMsg (found, expected)(TypeMismatchID ):
297297
298- private var shouldSuggestNN = false
299- // Ensures that shouldSuggestNN will always be correctly computed before `actions` is called
300- msg
298+ private val shouldSuggestNN =
299+ if expected.isValueType then
300+ found frozen_<:< OrNull (expected)
301+ else false
301302
302303 def msg (using Context ) =
303304 // replace constrained TypeParamRefs and their typevars by their bounds where possible
@@ -343,7 +344,6 @@ class TypeMismatch(val found: Type, expected: Type, val inTree: Option[untpd.Tre
343344 val (found2, expected2) =
344345 if (found1 frozen_<:< expected1) || reported.fbounded then (found, expected)
345346 else (found1, expected1)
346- if found2 frozen_<:< OrNull (expected) then shouldSuggestNN = true
347347 val (foundStr, expectedStr) = Formatting .typeDiff(found2.normalized, expected2.normalized)
348348 i """ |Found: $foundStr
349349 |Required: $expectedStr${reported.notes}"""
@@ -367,7 +367,7 @@ class TypeMismatch(val found: Type, expected: Type, val inTree: Option[untpd.Tre
367367 val content = tree.source.content().slice(tree.srcPos.startPos.start, tree.srcPos.endPos.end).mkString
368368 val replacement = tree match
369369 case a @ Apply (fun, args) => " (" + content + " ).nn"
370- case _ => content
370+ case _ => content + " .nn "
371371 List (
372372 CodeAction (title = """ Add .nn""" ,
373373 description = None ,
0 commit comments