@@ -1226,14 +1226,18 @@ trait Applications extends Compatibility {
1226
1226
}
1227
1227
val dummyArg = dummyTreeOfType(ownType)
1228
1228
val unapplyApp = typedExpr(untpd.TypedSplice (Apply (unapplyFn, dummyArg :: Nil )))
1229
- def unapplyImplicits (unapp : Tree ): List [Tree ] = unapp match {
1230
- case Apply (Apply (unapply, `dummyArg` :: Nil ), args2) => assert(args2.nonEmpty); args2
1231
- case Apply (unapply, `dummyArg` :: Nil ) => Nil
1232
- case Inlined (u, _, _) => unapplyImplicits(u)
1233
- case DynamicUnapply (_) =>
1234
- ctx.error(" Structural unapply is not supported" , unapplyFn.sourcePos)
1235
- Nil
1236
- case _ => Nil .assertingErrorsReported
1229
+ def unapplyImplicits (unapp : Tree ): List [List [Tree ]] = {
1230
+ val res = List .newBuilder[List [Tree ]]
1231
+ def loop (unapp : Tree ): Unit = unapp match {
1232
+ case Apply (Apply (unapply, `dummyArg` :: Nil ), args2) => assert(args2.nonEmpty); res += args2
1233
+ case Apply (unapply, `dummyArg` :: Nil ) =>
1234
+ case Inlined (u, _, _) => loop(u)
1235
+ case DynamicUnapply (_) => ctx.error(" Structural unapply is not supported" , unapplyFn.sourcePos)
1236
+ case Apply (fn, args) => assert(args.nonEmpty); loop(fn); res += args
1237
+ case _ => ().assertingErrorsReported
1238
+ }
1239
+ loop(unapp)
1240
+ res.result()
1237
1241
}
1238
1242
1239
1243
var argTypes = unapplyArgs(unapplyApp.tpe, unapplyFn, args, tree.sourcePos)
@@ -1250,7 +1254,7 @@ trait Applications extends Compatibility {
1250
1254
List .fill(argTypes.length - args.length)(WildcardType )
1251
1255
}
1252
1256
val unapplyPatterns = bunchedArgs.lazyZip(argTypes) map (typed(_, _))
1253
- val result = assignType(cpy.UnApply (tree)(unapplyFn, unapplyImplicits(unapplyApp), unapplyPatterns), ownType)
1257
+ val result = assignType(cpy.UnApply (tree)(unapplyFn, unapplyImplicits(unapplyApp).flatten , unapplyPatterns), ownType)
1254
1258
unapp.println(s " unapply patterns = $unapplyPatterns" )
1255
1259
if ((ownType eq selType) || ownType.isError) result
1256
1260
else tryWithClassTag(Typed (result, TypeTree (ownType)), selType)
0 commit comments