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:
131
131
/** Report implicit parameter lists and rewrite implicit parameter list to contextual params */
132
132
def implicitParams (tree : Tree , tp : MethodOrPoly , pt : FunProto )(using Context ): Unit =
133
133
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
135
135
// The application can only be rewritten if it uses parentheses syntax.
136
136
// See issue #22927 and related tests.
137
137
val hasParentheses = checkParentheses(tree, pt)
@@ -160,8 +160,10 @@ trait Migrations:
160
160
end implicitParams
161
161
162
162
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)
165
167
.exists(_ == '(' )
166
168
167
169
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