Issue 47404. Evaluate 'kIsWeb = identical(0, 0.0)' to BoolState.UNKNOWN_VALUE

Bug: https://github.com/dart-lang/sdk/issues/47404
Change-Id: I29626bd11379580c6a090384c57882de98f619b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216923
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Konstantin Shcheglov 2021-10-14 23:04:49 +00:00 committed by commit-bot@chromium.org
parent 391e900e5e
commit 7154635d4d
2 changed files with 5 additions and 5 deletions

View file

@ -537,13 +537,12 @@ class DartObjectImpl implements DartObject {
DartObjectImpl isIdentical2(
TypeSystemImpl typeSystem, DartObjectImpl rightOperand) {
// Workaround for Flutter `const kIsWeb = identical(0, 0.0)`.
if (type.isDartCoreInt && rightOperand.type.isDartCoreDouble) {
if (type.isDartCoreInt && rightOperand.type.isDartCoreDouble ||
type.isDartCoreDouble && rightOperand.type.isDartCoreInt) {
return DartObjectImpl(
typeSystem,
typeSystem.typeProvider.boolType,
BoolState(
toIntValue() == 0 && rightOperand.toDoubleValue() == 0.0,
),
BoolState.UNKNOWN_VALUE,
);
}

View file

@ -795,7 +795,8 @@ class DartObjectImplTest {
void test_identical_intZero_doubleZero() {
// Used in Flutter:
// const bool kIsWeb = identical(0, 0.0);
_assertIdentical(_boolValue(true), _intValue(0), _doubleValue(0.0));
_assertIdentical(_boolValue(null), _intValue(0), _doubleValue(0.0));
_assertIdentical(_boolValue(null), _doubleValue(0.0), _intValue(0));
}
void test_identical_list_empty() {