Skip to content

Commit ef521c8

Browse files
committed
Flatten directly
1 parent ca42229 commit ef521c8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,14 +1226,14 @@ trait Applications extends Compatibility {
12261226
}
12271227
val dummyArg = dummyTreeOfType(ownType)
12281228
val unapplyApp = typedExpr(untpd.TypedSplice(Apply(unapplyFn, dummyArg :: Nil)))
1229-
def unapplyImplicits(unapp: Tree): List[List[Tree]] = {
1230-
val res = List.newBuilder[List[Tree]]
1229+
def unapplyImplicits(unapp: Tree): List[Tree] = {
1230+
val res = List.newBuilder[Tree]
12311231
def loop(unapp: Tree): Unit = unapp match {
1232-
case Apply(Apply(unapply, `dummyArg` :: Nil), args2) => assert(args2.nonEmpty); res += args2
1232+
case Apply(Apply(unapply, `dummyArg` :: Nil), args2) => assert(args2.nonEmpty); res ++= args2
12331233
case Apply(unapply, `dummyArg` :: Nil) =>
12341234
case Inlined(u, _, _) => loop(u)
12351235
case DynamicUnapply(_) => ctx.error("Structural unapply is not supported", unapplyFn.sourcePos)
1236-
case Apply(fn, args) => assert(args.nonEmpty); loop(fn); res += args
1236+
case Apply(fn, args) => assert(args.nonEmpty); loop(fn); res ++= args
12371237
case _ => ().assertingErrorsReported
12381238
}
12391239
loop(unapp)
@@ -1254,7 +1254,7 @@ trait Applications extends Compatibility {
12541254
List.fill(argTypes.length - args.length)(WildcardType)
12551255
}
12561256
val unapplyPatterns = bunchedArgs.lazyZip(argTypes) map (typed(_, _))
1257-
val result = assignType(cpy.UnApply(tree)(unapplyFn, unapplyImplicits(unapplyApp).flatten, unapplyPatterns), ownType)
1257+
val result = assignType(cpy.UnApply(tree)(unapplyFn, unapplyImplicits(unapplyApp), unapplyPatterns), ownType)
12581258
unapp.println(s"unapply patterns = $unapplyPatterns")
12591259
if ((ownType eq selType) || ownType.isError) result
12601260
else tryWithClassTag(Typed(result, TypeTree(ownType)), selType)

0 commit comments

Comments
 (0)