mirror of
https://github.com/dart-lang/sdk
synced 2024-10-03 00:45:16 +00:00
Fix context type when recovering from "too many positional parameters".
See discussion at https://dart-review.googlesource.com/c/sdk/+/234864/comments/0512a739_f86ad5be. Change-Id: I201dcd9d8eca07d14579d00d76e08fe824d9d1e7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235560 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
5f0afa0ac4
commit
4f5d82d312
|
@ -388,8 +388,9 @@ abstract class InvocationInferrer<Node extends AstNodeImpl> {
|
|||
parameter = namedParameters[argument.name.label.name];
|
||||
} else if (parameters != null) {
|
||||
while (positionalParameterIndex < parameters.length) {
|
||||
parameter = parameters[positionalParameterIndex++];
|
||||
if (!parameter.isNamed) {
|
||||
var candidate = parameters[positionalParameterIndex++];
|
||||
if (!candidate.isNamed) {
|
||||
parameter = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,23 @@ main() {
|
|||
]);
|
||||
}
|
||||
|
||||
test_context() async {
|
||||
// No context type should be supplied when type inferring an extra
|
||||
// positional argument, even if there is an unmatched name parameter.
|
||||
await assertErrorsInCode(r'''
|
||||
T f<T>() => throw '$T';
|
||||
g({int? named}) {}
|
||||
main() {
|
||||
g(f());
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED, 56,
|
||||
3),
|
||||
]);
|
||||
assertType(
|
||||
findNode.methodInvocation('f()').typeArgumentTypes!.single, 'dynamic');
|
||||
}
|
||||
|
||||
test_enumConstant() async {
|
||||
await assertErrorsInCode(r'''
|
||||
enum E {
|
||||
|
|
Loading…
Reference in a new issue