blob: 6aa9d0cb16779ced93199cd8055462d42817656b [file] [log] [blame]
// 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 verifies that neither an `== null` nor an `is` test can promote the
// type of a property access on a variable. (In principle, we could soundly
// promote some such accesses, but we have decided not to do so at this time).
class _C {
final int? _f;
_C(this._f);
}
void equality(_C c) {
if (c._f == null) {
c._f.expectStaticType<Exactly<int?>>();
} else {
c._f.expectStaticType<Exactly<int?>>();
}
}
void is_(_C c) {
if (c._f is int) {
c._f.expectStaticType<Exactly<int?>>();
} else {
c._f.expectStaticType<Exactly<int?>>();
}
}
main() {
equality(_C(1));
is_(_C(1));
equality(_C(null));
is_(_C(null));
}