File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ trait Migrations:
131131 /** Report implicit parameter lists and rewrite implicit parameter list to contextual params */
132132 def implicitParams (tree : Tree , tp : MethodOrPoly , pt : FunProto )(using Context ): Unit =
133133 val mversion = mv.ImplicitParamsWithoutUsing
134- if tp.companion == ImplicitMethodType && pt.applyKind != ApplyKind .Using && pt.args.nonEmpty then
134+ if tp.companion == ImplicitMethodType && pt.applyKind != ApplyKind .Using && pt.args.nonEmpty && pt.args.head.span.exists then
135135 // The application can only be rewritten if it uses parentheses syntax.
136136 // See issue #22927 and related tests.
137137 val hasParentheses = checkParentheses(tree, pt)
@@ -160,8 +160,10 @@ trait Migrations:
160160 end implicitParams
161161
162162 private def checkParentheses (tree : Tree , pt : FunProto )(using Context ): Boolean =
163- ctx.source.content
164- .slice(tree.span.end, pt.args.head.span.start)
163+ val ptSpan = pt.args.head.span
164+ ptSpan.exists
165+ && ctx.source.content
166+ .slice(tree.span.end, ptSpan.start)
165167 .exists(_ == '(' )
166168
167169 private def patchImplicitParams (tree : Tree , pt : FunProto )(using Context ): Unit =
Original file line number Diff line number Diff line change 1+ trait ExtractorWithImplicit :
2+
3+ object Yikes :
4+ def unapply (implicit M : String ): Option [Any ] = ???
5+
6+ def expand : Any =
7+ given String = " Hey"
8+ " Wut" match
9+ case Yikes (_) => ???
10+ case _ => ???
11+
12+
You can’t perform that action at this time.
0 commit comments