Files
sdk/tests/language/null_aware/access_runtime_4_test.dart
T
Robert Nystrom 67618b0542 Migrate language_2/null_aware to NNBD.
Change-Id: I4466165b3ce2b79325a29db2a4d40d7f98f86007
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149885
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-06-19 01:38:55 +00:00

59 lines
1.3 KiB
Dart

// TODO(multitest): This was automatically migrated from a multitest and may
// contain strange or dead code.
// Copyright (c) 2015, 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.
// Verify semantics of the ?. operator when it does not appear on the LHS of an
// assignment.
import "package:expect/expect.dart";
import "conditional_access_helper.dart" as h;
class B {}
class C extends B {
int? v;
C(this.v);
static int? staticInt;
}
C? nullC() => null;
main() {
// Make sure the "none" test fails if property access using "?." is not
// implemented. This makes status files easier to maintain.
nullC()?.v;
// e1?.id is equivalent to ((x) => x == null ? null : x.id)(e1).
// C?.id is equivalent to C.id.
{ h.C.staticInt = 1; Expect.equals(1, h.C?.staticInt); }
// The static type of e1?.d is the static type of e1.id.
// Let T be the static type of e1 and let y be a fresh variable of type T.
// Exactly the same static warnings that would be caused by y.id are also
// generated in the case of e1?.id.
// '?.' cannot be used to access toplevel properties in libraries imported via
// prefix.
// Nor can it be used to access the hashCode getter on the class Type.
}