Files
sdk/pkg/front_end/testcases/general/null_aware.dart
T
Johnni Winther 6bec589f00 [cfe] Add least supported version check of 2.12
Change-Id: Iff8a3ea624b7130cb09359fbc9787a98ba07c4e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364700
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2024-05-08 09:28:45 +00:00

24 lines
517 B
Dart

// Copyright (c) 2016, 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.
class Foo {
int field;
static int staticField;
}
test() {
Foo foo = new Foo();
foo?.field = 5;
Foo?.staticField = 5;
foo.field ??= 5;
Foo.staticField ??= 5;
foo?.field ??= 5;
Foo?.staticField ??= 5;
int intValue = foo.field ?? 6;
num numValue = foo.field ?? 4.5;
}
main() {}