Skip to content

Commit

Permalink
[wildcards] ensure signatures with wildcard params have types
Browse files Browse the repository at this point in the history
See: #55681

Change-Id: Ibbb2771cea0311a6bf2145f663efff07f2f97d31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
  • Loading branch information
pq authored and Commit Queue committed Jul 31, 2024
1 parent 932be2e commit 10cbc8f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/analysis_server/test/analysis/get_signature_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,25 @@ void f() {
ParameterInfo(ParameterKind.REQUIRED_POSITIONAL, 'length', 'int')));
}

Future<void> test_function_wildcardParams() async {
newFile(testFilePath, '''
void g(int _, [String _]) {}
void f() {
g(/*^*/);
}
''');
var result = await prepareSignature('/*^*/');
expect(result.name, equals('g'));
expect(result.parameters, hasLength(2));
// Ensure wildcard params have their types.
expect(result.parameters[0],
equals(ParameterInfo(ParameterKind.REQUIRED_POSITIONAL, '_', 'int')));
expect(
result.parameters[1],
equals(
ParameterInfo(ParameterKind.OPTIONAL_POSITIONAL, '_', 'String')));
}

Future<void> test_function_zero_arguments() async {
newFile(testFilePath, '''
/// one doc
Expand Down

0 comments on commit 10cbc8f

Please sign in to comment.