@@ -2901,13 +2901,13 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2901
2901
case closure(_, _, _) =>
2902
2902
case _ =>
2903
2903
val recovered = typed(qual)(using ctx.fresh.setExploreTyperState())
2904
- report.errorOrMigrationWarning(
2905
- OnlyFunctionsCanBeFollowedByUnderscore (recovered.tpe.widen, tree), tree.srcPos, from = `3.0`
2906
- )
2904
+ val msg = OnlyFunctionsCanBeFollowedByUnderscore (recovered.tpe.widen, tree)
2905
+ report.errorOrMigrationWarning(msg, tree.srcPos, from = `3.0`)
2907
2906
if (migrateTo3) {
2908
2907
// Under -rewrite, patch `x _` to `(() => x)`
2909
- patch(Span (tree.span.start), " (() => " )
2910
- patch(Span (qual.span.end, tree.span.end), " )" )
2908
+ msg.actions
2909
+ .flatMap(_.patches)
2910
+ .map(actionPatch => patch(actionPatch.srcPos.span, actionPatch.replacement))
2911
2911
return typed(untpd.Function (Nil , qual), pt)
2912
2912
}
2913
2913
}
@@ -3906,10 +3906,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3906
3906
def adaptNoArgsUnappliedMethod (wtp : MethodType , functionExpected : Boolean , arity : Int ): Tree = {
3907
3907
/** Is reference to this symbol `f` automatically expanded to `f()`? */
3908
3908
def isAutoApplied (sym : Symbol ): Boolean =
3909
+ lazy val msg = MissingEmptyArgumentList (sym.show, tree)
3910
+
3909
3911
sym.isConstructor
3910
3912
|| sym.matchNullaryLoosely
3911
- || Feature .warnOnMigration(MissingEmptyArgumentList (sym.show, tree), tree.srcPos, version = `3.0`)
3912
- && { patch(tree.span.endPos, " ()" ); true }
3913
+ || Feature .warnOnMigration(msg, tree.srcPos, version = `3.0`)
3914
+ && {
3915
+ msg.actions
3916
+ .flatMap(_.patches)
3917
+ .map(actionPatch => patch(actionPatch.srcPos.span, actionPatch.replacement))
3918
+ true
3919
+ }
3913
3920
3914
3921
/** If this is a selection prototype of the form `.apply(...): R`, return the nested
3915
3922
* function prototype `(...)R`. Otherwise `pt`.
0 commit comments