[vm] Support unchecked AsExpressions in the VM

This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/307044.

TEST=ci

Change-Id: Ib08ca334b463a4926347dcdeb965f81d1979b703
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307660
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Alexander Markov 2023-06-06 16:26:25 +00:00 committed by Commit Queue
parent 3a598b4c03
commit 463c7cb5a2

View file

@ -3941,14 +3941,16 @@ Fragment StreamingFlowGraphBuilder::BuildAsExpression(TokenPosition* p) {
if (p != nullptr) *p = position;
const uint8_t flags = ReadFlags(); // read flags.
const bool is_unchecked_cast = (flags & kAsExpressionFlagUnchecked) != 0;
const bool is_type_error = (flags & kAsExpressionFlagTypeError) != 0;
Fragment instructions = BuildExpression(); // read operand.
const AbstractType& type = T.BuildType(); // read type.
if (type.IsInstantiated() && type.IsTopTypeForSubtyping()) {
if (is_unchecked_cast ||
(type.IsInstantiated() && type.IsTopTypeForSubtyping())) {
// We already evaluated the operand on the left and just leave it there as
// the result of the `obj as dynamic` expression.
// the result of unchecked cast or `obj as dynamic` expression.
} else {
// We do not care whether the 'as' cast as implicitly added by the frontend
// or explicitly written by the user, in both cases we use an assert