@@ -2941,13 +2941,13 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
29412941 case closure(_, _, _) =>
29422942 case _ =>
29432943 val recovered = typed(qual)(using ctx.fresh.setExploreTyperState())
2944- report.errorOrMigrationWarning(
2945- OnlyFunctionsCanBeFollowedByUnderscore (recovered.tpe.widen, tree), tree.srcPos, from = `3.0`
2946- )
2944+ val msg = OnlyFunctionsCanBeFollowedByUnderscore (recovered.tpe.widen, tree)
2945+ report.errorOrMigrationWarning(msg, tree.srcPos, from = `3.0`)
29472946 if (migrateTo3) {
29482947 // Under -rewrite, patch `x _` to `(() => x)`
2949- patch(Span (tree.span.start), " (() => " )
2950- patch(Span (qual.span.end, tree.span.end), " )" )
2948+ msg.actions
2949+ .flatMap(_.patches)
2950+ .map(actionPatch => patch(actionPatch.srcPos.span, actionPatch.replacement))
29512951 return typed(untpd.Function (Nil , qual), pt)
29522952 }
29532953 }
@@ -3951,10 +3951,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
39513951 def adaptNoArgsUnappliedMethod (wtp : MethodType , functionExpected : Boolean , arity : Int ): Tree = {
39523952 /** Is reference to this symbol `f` automatically expanded to `f()`? */
39533953 def isAutoApplied (sym : Symbol ): Boolean =
3954+ lazy val msg = MissingEmptyArgumentList (sym.show, tree)
3955+
39543956 sym.isConstructor
39553957 || sym.matchNullaryLoosely
3956- || Feature .warnOnMigration(MissingEmptyArgumentList (sym.show, tree), tree.srcPos, version = `3.0`)
3957- && { patch(tree.span.endPos, " ()" ); true }
3958+ || Feature .warnOnMigration(msg, tree.srcPos, version = `3.0`)
3959+ && {
3960+ msg.actions
3961+ .flatMap(_.patches)
3962+ .map(actionPatch => patch(actionPatch.srcPos.span, actionPatch.replacement))
3963+ true
3964+ }
39583965
39593966 /** If this is a selection prototype of the form `.apply(...): R`, return the nested
39603967 * function prototype `(...)R`. Otherwise `pt`.
0 commit comments