@@ -181,9 +181,9 @@ object Inlines:
181181 // as its right hand side. The call to the wrapper unapply serves as the signpost for pattern matching.
182182 // After pattern matching, the anonymous class is removed in phase InlinePatterns with a beta reduction step.
183183 //
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.
187187 // This serves as a placeholder for the inlined body until the `patternMatcher` phase. After pattern matcher
188188 // transforms the patterns into terms, the `inlinePatterns` phase removes this anonymous class by β-reducing
189189 // the call to the `unapply`.
@@ -193,9 +193,6 @@ object Inlines:
193193 case Apply (SplitFunAndGivenArgs (fn, argss), args) => (fn, argss :+ args)
194194 case _ => (tree, Nil )
195195 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)
199196
200197 val sym = unapp.symbol
201198
@@ -217,7 +214,7 @@ object Inlines:
217214 List (unapply)
218215 }
219216
220- val newFun = newUnapply.select(unapplySym1).withSpan(unapp.span)
217+ val newFun = newUnapply.select(unapplySym1).appliedToArgss(leadingImplicits). withSpan(unapp.span)
221218 cpy.UnApply (unapp)(newFun, trailingImplicits, patterns)
222219 end inlinedUnapply
223220
0 commit comments