Skip to content

Commit 3655254

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Issue 42788. Report MISSING_REQUIRED_ARGUMENT for 'call'.
Bug: dart-lang/sdk#42788 Change-Id: Icece8f0e9865e659187d556c582929efcb7d242e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156841 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 352262e commit 3655254

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ class RequiredParametersVerifier extends SimpleAstVisitor<void> {
4040

4141
@override
4242
void visitMethodInvocation(MethodInvocation node) {
43+
if (node.methodName.name == FunctionElement.CALL_METHOD_NAME) {
44+
var targetType = node.realTarget?.staticType;
45+
if (targetType is FunctionType) {
46+
_check(targetType.parameters, node.argumentList, node.argumentList);
47+
return;
48+
}
49+
}
50+
4351
_check(
4452
_executableElement(node.methodName.staticElement)?.parameters,
4553
node.argumentList,

pkg/analyzer/test/src/diagnostics/missing_required_param_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,18 @@ main() {
309309
]);
310310
}
311311

312+
test_function_call() async {
313+
await assertErrorsInCode(r'''
314+
void f({required int a}) {}
315+
316+
main() {
317+
f.call();
318+
}
319+
''', [
320+
error(CompileTimeErrorCode.MISSING_REQUIRED_ARGUMENT, 46, 2),
321+
]);
322+
}
323+
312324
test_functionInvocation() async {
313325
await assertErrorsInCode(r'''
314326
void Function({required int a}) f() => throw '';

0 commit comments

Comments
 (0)