@@ -181,9 +181,9 @@ object Inlines:
181
181
// as its right hand side. The call to the wrapper unapply serves as the signpost for pattern matching.
182
182
// After pattern matching, the anonymous class is removed in phase InlinePatterns with a beta reduction step.
183
183
//
184
- // An inline unapply `P.unapply` in a plattern `P(x1,x2,...)` is transformed into
185
- // `{ class $anon { def unapply(t0: T0)( using t1: T1, t2: T2, ...): R = P.unapply(t0)( using t1, t2, ...) }; new $anon }.unapply`
186
- // and the call `P.unapply(x1, x2, ...)` is inlined.
184
+ // An inline unapply `P.unapply` in a pattern `P(using y1,y2,...) (x1,x2,...)` is transformed into
185
+ // `{ class $anon { def unapply(using l1: L1, l2: L2, ...)(s: S)( using t1: T1, t2: T2, ...): R = P.unapply(using l1, l2, ...)(s)( using t1, t2, ...) }; new $anon }.unapply(using y1,y2,...) `
186
+ // and the call `P.unapply(using l1, l2,...)( x1, x2, ...)(using t1, t2 , ...)` is inlined.
187
187
// This serves as a placeholder for the inlined body until the `patternMatcher` phase. After pattern matcher
188
188
// transforms the patterns into terms, the `inlinePatterns` phase removes this anonymous class by β-reducing
189
189
// the call to the `unapply`.
@@ -193,9 +193,6 @@ object Inlines:
193
193
case Apply (SplitFunAndGivenArgs (fn, argss), args) => (fn, argss :+ args)
194
194
case _ => (tree, Nil )
195
195
val UnApply (SplitFunAndGivenArgs (fun, leadingImplicits), trailingImplicits, patterns) = unapp
196
- if leadingImplicits.flatten.nonEmpty then
197
- // To support them see https://github.com/lampepfl/dotty/pull/13158
198
- report.error(" inline unapply methods with given parameters before the scrutinee are not supported" , fun)
199
196
200
197
val sym = unapp.symbol
201
198
@@ -217,7 +214,7 @@ object Inlines:
217
214
List (unapply)
218
215
}
219
216
220
- val newFun = newUnapply.select(unapplySym1).withSpan(unapp.span)
217
+ val newFun = newUnapply.select(unapplySym1).appliedToArgss(leadingImplicits). withSpan(unapp.span)
221
218
cpy.UnApply (unapp)(newFun, trailingImplicits, patterns)
222
219
end inlinedUnapply
223
220
0 commit comments