Skip to content

Commit 463c7cb

Browse files
alexmarkovCommit Queue
authored and
Commit Queue
committed
[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 <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 3a598b4 commit 463c7cb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3941,14 +3941,16 @@ Fragment StreamingFlowGraphBuilder::BuildAsExpression(TokenPosition* p) {
39413941
if (p != nullptr) *p = position;
39423942

39433943
const uint8_t flags = ReadFlags(); // read flags.
3944+
const bool is_unchecked_cast = (flags & kAsExpressionFlagUnchecked) != 0;
39443945
const bool is_type_error = (flags & kAsExpressionFlagTypeError) != 0;
39453946

39463947
Fragment instructions = BuildExpression(); // read operand.
39473948

39483949
const AbstractType& type = T.BuildType(); // read type.
3949-
if (type.IsInstantiated() && type.IsTopTypeForSubtyping()) {
3950+
if (is_unchecked_cast ||
3951+
(type.IsInstantiated() && type.IsTopTypeForSubtyping())) {
39503952
// We already evaluated the operand on the left and just leave it there as
3951-
// the result of the `obj as dynamic` expression.
3953+
// the result of unchecked cast or `obj as dynamic` expression.
39523954
} else {
39533955
// We do not care whether the 'as' cast as implicitly added by the frontend
39543956
// or explicitly written by the user, in both cases we use an assert

0 commit comments

Comments
 (0)