Skip to content

Commit cb23ff2

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[vm, compiler] Fix propagating type from polymorphic call when it is not exhaustive.
TEST=vm/dart/regress_61442_test Bug: #61442 Change-Id: I33745534711fd0f71e52dcfa98173a44143188d8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448231 Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent eb01627 commit cb23ff2

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// VMOptions=--no_polymorphic_with_deopt
6+
7+
import "dart:typed_data";
8+
9+
Int64List var19 = Int64List(0);
10+
int var61 = -9223372034707292161;
11+
int? var62 = -34;
12+
Map<int, String> var113 = <int, String>{39: 'kR\u{1f600}gSx', 5: ''};
13+
14+
foo0_2() {
15+
for (int loc1 in var19) {}
16+
}
17+
18+
foo0_Extension0() {
19+
for (int loc0 = 0; loc0 < 35; loc0++) {
20+
int loc1 = 0;
21+
do {
22+
print(Int32x4List(42));
23+
} while (++loc1 < 15);
24+
}
25+
}
26+
27+
foo1_Extension0() {
28+
for (int loc0 in Int16List(42)) {
29+
int loc1 = 0;
30+
do {
31+
var113.addAll(<int, String>{
32+
loc1: 'N3+&'.replaceRange(var61, var62, "X"),
33+
});
34+
} while (++loc1 < 4);
35+
}
36+
}
37+
38+
main() {
39+
foo0_2();
40+
foo0_Extension0();
41+
try {
42+
foo1_Extension0();
43+
} catch (e) {
44+
print(e);
45+
}
46+
}

runtime/vm/compiler/backend/il.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5649,8 +5649,10 @@ Definition* PolymorphicInstanceCallInstr::Canonicalize(FlowGraph* flow_graph) {
56495649
}
56505650

56515651
bool PolymorphicInstanceCallInstr::IsSureToCallSingleRecognizedTarget() const {
5652-
if (CompilerState::Current().is_aot() && !complete()) return false;
5653-
return targets_.HasSingleRecognizedTarget();
5652+
if (complete() || FLAG_polymorphic_with_deopt) {
5653+
return targets_.HasSingleRecognizedTarget();
5654+
}
5655+
return false;
56545656
}
56555657

56565658
bool StaticCallInstr::InitResultType(Zone* zone) {

0 commit comments

Comments
 (0)