Skip to content

Commit 4ec6751

Browse files
authored
Fix main: remove empty parentheses when rewriting implicits to givens (#23339)
1 parent 14c6331 commit 4ec6751

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Migrations.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ trait Migrations:
202202
patch(
203203
Span(ddef.mods.mods.last.span.end + 1, ddef.namePos.span.start), "given "
204204
)
205+
// remove empty parentheses
206+
patch(
207+
Span(ddef.namePos.span.end, ddef.tpt.span.start), ": "
208+
)
205209
ddef.tpt match
206210
case refinedType: untpd.RefinedTypeTree =>
207211
patch(refinedType.span.startPos, "(")

tests/rewrites/implicit-to-given.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object Def:
1717
val application = applicationTest(using 0)
1818
val implicitArg: Int => Unit = (implicit a => applicationTest) // should not change
1919

20-
given refined(): (A {type B = Int}) = ???
20+
given refined: (A {type B = Int}) = ???
2121

2222
class EmptyParamListClass()(using a: Int)
2323
def emptyParamListTest() = new EmptyParamListClass()(using 0)

0 commit comments

Comments
 (0)