b8b072ed3b
This updates the message text for undefined access. Instead of saying that the member is not defined on the "class", it now says on the "type". Closes #60290 Change-Id: I9387f892e99ba109b9b1d99af25714ab83b5350c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433941 Reviewed-by: Erik Ernst <eernst@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jens Johansen <jensj@google.com> Reviewed-by: Nicholas Shahan <nshahan@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 type '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 type 'int?'.
|
|
break;
|
|
}
|
|
}
|
|
|
|
main() {}
|