885c6e22dd
This fixes an assertion getting triggered in dart2wasm when compiling ACX gallery. The bad state is an InstanceInvocation where the receiver is a type with no instantiable subtypes. Dart2wasm expects TFA to tree shake such unreachable calls. The issue arises when an awaited expression includes a call where the receiver is promoted to an uninstantiable type. Dart2wasm does a modular transform to hoist the awaited expression to its own statement: https://github.com/dart-lang/sdk/blob/main/pkg/dart2wasm/lib/await_transformer.dart#L12 This hoisting takes the expression out of the promotion context and TFA is then unable to mark the call as unreachable (given the unpromoted type *is* instantiable). The CFE includes the promoted type on the VariableGet which gets copied over in the hoist transform. So a solution here is to narrow the inferred type with the promoted static type when available. An alternative solution here is to hoist *after* TFA. But that doesn't protect other transforms that could trigger this same issue. Change-Id: I903bdde53f57a007568cd47a20cbac986c42d18d Tested: Test cases added Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456900 Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>