Files
sdk/tests/language/null_aware_elements/warnings_simple_test.dart
Lasse R.H. Nielsen 83b2c5d3c3 Retire and remove 3.9 experiment flags.
Change-Id: I72262910b590f93ca5de7b3286c226d5ecaf3276
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443803
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2025-09-09 04:50:35 -07:00

37 lines
1.0 KiB
Dart

// Copyright (c) 2024, 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 'package:expect/expect.dart';
List<int> testList(int x) {
return <int>[?x];
// ^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
}
Set<int> testSet(int x) {
return <int>{?x};
// ^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
}
Map<int, String> testMapKey(int x) {
return <int, String>{?x: ""};
// ^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
}
Map<String, int> testMapValue(int x) {
return <String, int>{"": ?x};
// ^
// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
}
main() {
Expect.listEquals(testList(0), <int>[0]);
Expect.setEquals(testSet(0), <int>{0});
Expect.mapEquals(testMapKey(0), <int, String>{0: ""});
Expect.mapEquals(testMapValue(0), <String, int>{"": 0});
}