[dart2wasm] Fix completer.future type in for-in lowering
Currently the `InstanceGet` node result type for for `Completer<bool>.future` is `Future<bool> Function()`, but it should be `Future<bool>`. This causes problems in CL 301020 where we generate temporaries for nested `await` expressions and use the expression type for the types of those temporaries. Incorrect expression type in `completer.future` causes a temporary with incorrect type to be generated. Change-Id: Ib8193c66afee9454a275c00fb958c11fd35cd3eb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301382 Reviewed-by: Joshua Litt <joshualitt@google.com> Commit-Queue: Ömer Ağacan <omersa@google.com>
This commit is contained in:
committed by
Commit Queue
parent
6d903906f3
commit
e20d2d2103
@@ -298,11 +298,9 @@ class _WasmTransformer extends Transformer {
|
||||
VariableDeclaration completer, int fileOffset) {
|
||||
Procedure completerFuture =
|
||||
coreTypes.index.getProcedure('dart:async', 'Completer', 'get:future');
|
||||
FunctionType completerFutureType =
|
||||
Substitution.fromInterfaceType(completerBoolType).substituteType(
|
||||
completerFuture.function
|
||||
.computeThisFunctionType(Nullability.nonNullable))
|
||||
as FunctionType;
|
||||
// Future<bool>
|
||||
DartType completerFutureType = InterfaceType(coreTypes.futureClass,
|
||||
Nullability.nonNullable, [coreTypes.boolNonNullableRawType]);
|
||||
return AwaitExpression(InstanceGet(
|
||||
InstanceAccessKind.Instance, VariableGet(completer), Name('future'),
|
||||
interfaceTarget: completerFuture, resultType: completerFutureType)
|
||||
|
||||
@@ -13,19 +13,19 @@ static method asyncMethod(asy::Stream<core::int> stream) → asy::Stream<core::i
|
||||
synthesized () → asy::Future<void> #body = () → asy::Future<void> async /* futureValueType= void */ {
|
||||
synthesized asy::Completer<core::bool> #completer = asy::Completer::•<core::bool>();
|
||||
#controller.{asy::StreamController::add}(#completer){(core::Object?) → void};
|
||||
await #completer.{asy::Completer::future}{() → asy::Future<core::bool>};
|
||||
await #completer.{asy::Completer::future}{asy::Future<core::bool>};
|
||||
{
|
||||
{
|
||||
#controller.{asy::StreamController::add}(1){(core::Object?) → void};
|
||||
#completer = asy::Completer::•<core::bool>();
|
||||
#controller.{asy::StreamController::add}(#completer){(core::Object?) → void};
|
||||
await #completer.{asy::Completer::future}{() → asy::Future<core::bool>};
|
||||
await #completer.{asy::Completer::future}{asy::Future<core::bool>};
|
||||
}
|
||||
{
|
||||
#controller.{asy::StreamController::add}(2){(core::Object?) → void};
|
||||
#completer = asy::Completer::•<core::bool>();
|
||||
#controller.{asy::StreamController::add}(#completer){(core::Object?) → void};
|
||||
await #completer.{asy::Completer::future}{() → asy::Future<core::bool>};
|
||||
await #completer.{asy::Completer::future}{asy::Future<core::bool>};
|
||||
}
|
||||
{
|
||||
synthesized asy::_StreamIterator<core::int> #forIterator = new asy::_StreamIterator::•<core::int>(stream);
|
||||
@@ -37,7 +37,7 @@ static method asyncMethod(asy::Stream<core::int> stream) → asy::Stream<core::i
|
||||
#controller.{asy::StreamController::add}(#awaitForVar){(core::Object?) → void};
|
||||
#completer = asy::Completer::•<core::bool>();
|
||||
#controller.{asy::StreamController::add}(#completer){(core::Object?) → void};
|
||||
await #completer.{asy::Completer::future}{() → asy::Future<core::bool>};
|
||||
await #completer.{asy::Completer::future}{asy::Future<core::bool>};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user