[dart2wasm] Simplify and fix async* element type computation

Fixes tests:

- co19/Language/Functions/element_type_A02_t03
- co19/Language/Functions/element_type_A02_t04

Change-Id: Ifc186cb463fee26c59f81012c6da8925d902d9d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342561
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Ömer Sinan Ağacan 2023-12-20 08:31:25 +00:00 committed by Commit Queue
parent 6bca7060de
commit 72fd1e01d2

View file

@ -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<U>` 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,