@@ -2941,13 +2941,13 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2941
2941
case closure(_, _, _) =>
2942
2942
case _ =>
2943
2943
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`)
2947
2946
if (migrateTo3) {
2948
2947
// 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))
2951
2951
return typed(untpd.Function (Nil , qual), pt)
2952
2952
}
2953
2953
}
@@ -3951,10 +3951,17 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3951
3951
def adaptNoArgsUnappliedMethod (wtp : MethodType , functionExpected : Boolean , arity : Int ): Tree = {
3952
3952
/** Is reference to this symbol `f` automatically expanded to `f()`? */
3953
3953
def isAutoApplied (sym : Symbol ): Boolean =
3954
+ lazy val msg = MissingEmptyArgumentList (sym.show, tree)
3955
+
3954
3956
sym.isConstructor
3955
3957
|| 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
+ }
3958
3965
3959
3966
/** If this is a selection prototype of the form `.apply(...): R`, return the nested
3960
3967
* function prototype `(...)R`. Otherwise `pt`.
0 commit comments