dbaf041ae4
Change-Id: Ia3238c1781422ec5eb7a219a5cf8af645a4c5876 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409000 Commit-Queue: Bob Nystrom <rnystrom@google.com> Reviewed-by: Lasse Nielsen <lrn@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com>
35 lines
1.0 KiB
Dart
35 lines
1.0 KiB
Dart
// Copyright (c) 2023, 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.
|
|
|
|
/// Test that the appropriate errors are generated if a nullable type is used in
|
|
/// an object pattern.
|
|
|
|
typedef A = int?;
|
|
|
|
void nullableWithField(x) {
|
|
// This is an error because `isEven` can't be called on `int?`.
|
|
switch (x) {
|
|
case A(isEven: true):
|
|
// ^
|
|
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
|
|
// ^
|
|
// [cfe] The getter 'isEven' isn't defined for the class 'int?'.
|
|
break;
|
|
}
|
|
}
|
|
|
|
void potentiallyNullableWithField<T extends int?>(x) {
|
|
// This is an error because `isEven` can't be called on `int?`.
|
|
switch (x) {
|
|
case T(isEven: true):
|
|
// ^
|
|
// [analyzer] COMPILE_TIME_ERROR.UNCHECKED_USE_OF_NULLABLE_VALUE
|
|
// ^
|
|
// [cfe] The getter 'isEven' isn't defined for the class 'int?'.
|
|
break;
|
|
}
|
|
}
|
|
|
|
main() {}
|