File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +14
-4
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,9 +160,7 @@ 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)
165- .exists(_ == '(' )
163+ pt.args.head.span.exists && ctx.source.content.slice(tree.span.end, pt.args.head.span.start).exists(_ == '(' )
166164
167165 private def patchImplicitParams (tree : Tree , pt : FunProto )(using Context ): Unit =
168166 patch(Span (pt.args.head.span.start), " using " )
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