Fix the case where an identity flow is appended to a Source with materialized value composition (#22442)

This commit is contained in:
drewhk 2017-03-02 13:44:35 +01:00 committed by GitHub
parent a2203d7b13
commit 46b869d041
2 changed files with 15 additions and 10 deletions

View file

@ -45,14 +45,16 @@ final class Source[+Out, +Mat](
override def via[T, Mat2](flow: Graph[FlowShape[Out, T], Mat2]): Repr[T] = viaMat(flow)(Keep.left)
override def viaMat[T, Mat2, Mat3](flow: Graph[FlowShape[Out, T], Mat2])(combine: (Mat, Mat2) Mat3): Source[T, Mat3] = {
if (flow.traversalBuilder eq Flow.identityTraversalBuilder) {
traversalBuilder.append(LinearTraversalBuilder.empty(), combine).asInstanceOf[Source[T, Mat3]]
} else {
new Source[T, Mat3](
traversalBuilder.append(flow.traversalBuilder, flow.shape, combine),
SourceShape(flow.shape.out)
)
}
val toAppend =
if (flow.traversalBuilder eq Flow.identityTraversalBuilder)
LinearTraversalBuilder.empty()
else
flow.traversalBuilder
new Source[T, Mat3](
traversalBuilder.append(toAppend, flow.shape, combine),
SourceShape(flow.shape.out)
)
}
/**