File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import dotty.tools.dotc.util.SourcePosition;
1111
1212import java .io .OutputStreamWriter
1313import java .nio .charset .StandardCharsets .UTF_8
14+ import dotty .tools .dotc .reporting .CodeAction
1415
1516/** Handles rewriting of Scala2 files to Dotty */
1617object Rewrites {
@@ -99,6 +100,14 @@ object Rewrites {
99100 report.echo(s " [patched file ${source.file.path}] " )
100101 rewrites.patched(source).writeBack()
101102 }
103+
104+ /** Given a CodeAction take the patches and apply them.
105+ *
106+ * @param action The CodeAction containing the patches
107+ */
108+ def applyAction (action : CodeAction )(using Context ): Unit =
109+ action.patches.foreach: actionPatch =>
110+ patch(actionPatch.srcPos.span, actionPatch.replacement)
102111}
103112
104113/** A completely encapsulated class representing rewrite state, used
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ import cc.CheckCaptures
5454import config .Config
5555
5656import scala .annotation .constructorOnly
57+ import dotty .tools .dotc .rewrites .Rewrites
5758
5859object Typer {
5960
@@ -2946,8 +2947,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
29462947 if (migrateTo3) {
29472948 // Under -rewrite, patch `x _` to `(() => x)`
29482949 msg.actions
2949- .flatMap(_.patches)
2950- .map(actionPatch => patch(actionPatch.srcPos.span, actionPatch.replacement) )
2950+ .headOption
2951+ .foreach( Rewrites .applyAction )
29512952 return typed(untpd.Function (Nil , qual), pt)
29522953 }
29532954 }
You can’t perform that action at this time.
0 commit comments