@@ -185,7 +185,15 @@ object Inlines:
185185 // transforms the patterns into terms, the `inlinePatterns` phase removes this anonymous class by β-reducing
186186 // the call to the `unapply`.
187187
188- val UnApply (fun, implicits, patterns) = unapp
188+ object SplitFunAndGivenArgs :
189+ def unapply (tree : Tree ): (Tree , List [List [Tree ]]) = tree match
190+ case Apply (SplitFunAndGivenArgs (fn, argss), args) => (fn, argss :+ args)
191+ case _ => (tree, Nil )
192+ val UnApply (SplitFunAndGivenArgs (fun, leadingImplicits), trailingImplicits, patterns) = unapp
193+ if leadingImplicits.flatten.nonEmpty then
194+ // To support them see https://github.com/lampepfl/dotty/pull/13158
195+ report.error(" inline unapply methods with given parameters before the scrutinee are not supported" , fun)
196+
189197 val sym = unapp.symbol
190198 val cls = newNormalizedClassSymbol(ctx.owner, tpnme.ANON_CLASS , Synthetic | Final , List (defn.ObjectType ), coord = sym.coord)
191199 val constr = newConstructor(cls, Synthetic , Nil , Nil , coord = sym.coord).entered
@@ -204,7 +212,7 @@ object Inlines:
204212 val cdef = ClassDef (cls, DefDef (constr), List (unapply))
205213 val newUnapply = Block (cdef :: Nil , New (cls.typeRef, Nil ))
206214 val newFun = newUnapply.select(unappplySym).withSpan(unapp.span)
207- cpy.UnApply (unapp)(newFun, implicits , patterns)
215+ cpy.UnApply (unapp)(newFun, trailingImplicits , patterns)
208216 end inlinedUnapply
209217
210218 /** For a retained inline method, another method that keeps track of
0 commit comments