5b964887ee
The feature is not turned on yet; these tests will verify that it's working properly once it is enabled. Bug: https://github.com/dart-lang/language/issues/1274 Change-Id: Ia48996d4525b84b523627a7b254cba18bdef48c7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177641 Reviewed-by: Leaf Petersen <leafp@google.com>
28 lines
686 B
Dart
28 lines
686 B
Dart
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import '../../static_type_helper.dart';
|
|
|
|
// This test checks that a local variable whose value is `null` cannot be used
|
|
// in place of a literal `null` in flow analysis.
|
|
|
|
test(int? x) {
|
|
if (x == null) {
|
|
x.expectStaticType<Exactly<int?>>();
|
|
} else {
|
|
x.expectStaticType<Exactly<int>>();
|
|
}
|
|
int? y = null;
|
|
if (x == y) {
|
|
x.expectStaticType<Exactly<int?>>();
|
|
} else {
|
|
x.expectStaticType<Exactly<int?>>();
|
|
}
|
|
}
|
|
|
|
main() {
|
|
test(0);
|
|
test(null);
|
|
}
|