@@ -2877,13 +2877,13 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2877
2877
case closure(_, _, _) =>
2878
2878
case _ =>
2879
2879
val recovered = typed(qual)(using ctx.fresh.setExploreTyperState())
2880
- report.errorOrMigrationWarning(
2881
- OnlyFunctionsCanBeFollowedByUnderscore (recovered.tpe.widen, tree), tree.srcPos, from = `3.0`
2882
- )
2880
+ val msg = OnlyFunctionsCanBeFollowedByUnderscore (recovered.tpe.widen, tree)
2881
+ report.errorOrMigrationWarning(msg, tree.srcPos, from = `3.0`)
2883
2882
if (migrateTo3) {
2884
2883
// Under -rewrite, patch `x _` to `(() => x)`
2885
- patch(Span (tree.span.start), " (() => " )
2886
- patch(Span (qual.span.end, tree.span.end), " )" )
2884
+ msg.actions
2885
+ .flatMap(_.patches)
2886
+ .map(actionPatch => patch(actionPatch.srcPos.span, actionPatch.replacement))
2887
2887
return typed(untpd.Function (Nil , qual), pt)
2888
2888
}
2889
2889
}
@@ -3880,10 +3880,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3880
3880
def adaptNoArgsUnappliedMethod (wtp : MethodType , functionExpected : Boolean , arity : Int ): Tree = {
3881
3881
/** Is reference to this symbol `f` automatically expanded to `f()`? */
3882
3882
def isAutoApplied (sym : Symbol ): Boolean =
3883
+ lazy val msg = MissingEmptyArgumentList (sym.show, tree)
3884
+
3883
3885
sym.isConstructor
3884
3886
|| sym.matchNullaryLoosely
3885
- || Feature .warnOnMigration(MissingEmptyArgumentList (sym.show, tree), tree.srcPos, version = `3.0`)
3886
- && { patch(tree.span.endPos, " ()" ); true }
3887
+ || Feature .warnOnMigration(msg, tree.srcPos, version = `3.0`)
3888
+ && {
3889
+ msg.actions
3890
+ .flatMap(_.patches)
3891
+ .map(actionPatch => patch(actionPatch.srcPos.span, actionPatch.replacement))
3892
+ true
3893
+ }
3887
3894
3888
3895
/** If this is a selection prototype of the form `.apply(...): R`, return the nested
3889
3896
* function prototype `(...)R`. Otherwise `pt`.
0 commit comments