diff --git a/pkg/dart2wasm/lib/transformers.dart b/pkg/dart2wasm/lib/transformers.dart index db79faa5c2b..e8c3d9b37e3 100644 --- a/pkg/dart2wasm/lib/transformers.dart +++ b/pkg/dart2wasm/lib/transformers.dart @@ -602,17 +602,7 @@ class _WasmTransformer extends Transformer { // Finally call cast. - // Stream element type is defined in language spec section 9. If the return - // type is `Stream` then the element type is `U`. Otherwise it needs to - // be a supertype of `Object` and the element type is `dynamic`. - final DartType streamTypeArgument; - final DartType functionReturnType = functionNode.returnType; - if (functionReturnType is InterfaceType && - functionReturnType.classNode == coreTypes.streamClass) { - streamTypeArgument = functionReturnType.typeArguments.single; - } else { - streamTypeArgument = const DynamicType(); - } + final DartType streamTypeArgument = functionNode.emittedValueType!; Procedure castProc = coreTypes.index.getProcedure('dart:async', 'Stream', 'cast'); final returnStreamType = InterfaceType(coreTypes.streamClass,