Interface TypePreservingFanIn
- All Known Implementing Classes:
Concat,Interleave,Merge,MergePrioritized,MergeSequence
T => T).
Built-in stages with this trait: scaladsl.Merge, scaladsl.Concat,
scaladsl.Interleave, scaladsl.MergePrioritized, OrElse,
and scaladsl.MergeSequence.
Note: some of these stages (Concat, Interleave, MergeSequence) have factory methods
that wrap the stage via withDetachedInputs, which loses this trait. In those cases,
Source.combine routes through the fan-in graph instead of bypassing—functionally
correct, just slightly less optimal. The bypass optimization fires for stages whose
factory methods return the raw class (e.g., Merge, MergePrioritized).
This trait is used by Source.combine (and its Java API counterpart)
to safely optimize the single-source case. When only one source is provided,
the fan-in strategy can be bypassed with a direct pass-through if and only if the
strategy is type-preserving (output type equals input type). Without this marker,
a bypass via asInstanceOf would be unsafe for type-transforming strategies
like MergeLatest (where T => List[T]) or ZipWithN (where A => O).
This design uses a "safe default": strategies '''without''' this trait will always be routed through the fan-in graph, even for a single source. This ensures correct behavior for unknown or third-party fan-in strategies that may transform the element type.
- Since:
- 1.5.0