Skip to content

Commit eb01627

Browse files
stereotype441Commit Queue
authored andcommitted
[analyzer] Add name and token to ExpectedType enum.
Changes the analyzer's `ExpectedType` enum (which is used for runtime type checks of parameters to diagnostic messages) so that it includes the types `name` and `token`. These correspond with types used in parser error reporting. In a future CL, I will be adding `parameters` declarations to `pkg/front_end/messages.yaml`, following a similar format to the format used by `pkg/analyzer/messages.yaml`. When that happens, the analyzer's diagnostic message code generator will start trying to generate runtime type checking code for parameters of type `name` and `token`. Landing this change now ensures that when the new runtime type checking code gets generated, it will work properly. Change-Id: I6a6a69648c2fdff63d93da5c5c39ba75f65edc9c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448248 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 1a8334d commit eb01627

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

pkg/_fe_analyzer_shared/lib/src/base/errors.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ base mixin DiagnosticWithoutArguments on DiagnosticCode
619619
}
620620

621621
/// Expected type of a diagnostic code's parameter.
622-
enum ExpectedType { element, int, object, string, type, uri }
622+
enum ExpectedType { element, int, name, object, string, token, type, uri }
623623

624624
/// Interface for a diagnostic that does not have any unfilled template
625625
/// parameters, and hence is ready to be associated with a location in the

pkg/analyzer/lib/src/error/listener.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ Expected types: $expectedTypes''');
126126
var typeMatches = switch (expectedTypes[i]) {
127127
ExpectedType.element => argument is Element,
128128
ExpectedType.int => argument is int,
129+
ExpectedType.name => argument is String,
129130
ExpectedType.object => true,
130131
ExpectedType.string => argument is String,
132+
ExpectedType.token => argument is Token,
131133
ExpectedType.type => argument is DartType,
132134
ExpectedType.uri => argument is Uri,
133135
};

0 commit comments

Comments
 (0)