@@ -840,6 +840,8 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
840
840
}
841
841
_checkForImplicitDynamicInvoke (node);
842
842
_checkForNullableDereference (node.function);
843
+ _checkForMissingRequiredParam (
844
+ node.staticInvokeType, node.argumentList, node);
843
845
super .visitFunctionExpressionInvocation (node);
844
846
}
845
847
@@ -947,6 +949,8 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
947
949
_checkForConstOrNewWithAbstractClass (node, typeName, type);
948
950
_checkForConstOrNewWithEnum (node, typeName, type);
949
951
_checkForConstOrNewWithMixin (node, typeName, type);
952
+ _checkForMissingRequiredParam (
953
+ node.staticElement? .type, node.argumentList, node.constructorName);
950
954
if (_isInConstInstanceCreation) {
951
955
_checkForConstWithNonConst (node);
952
956
_checkForConstWithUndefinedConstructor (
@@ -1046,6 +1050,8 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
1046
1050
}
1047
1051
_checkTypeArguments (node);
1048
1052
_checkForImplicitDynamicInvoke (node);
1053
+ _checkForMissingRequiredParam (
1054
+ node.staticInvokeType, node.argumentList, node.methodName);
1049
1055
if (node.operator ? .type != TokenType .QUESTION_PERIOD &&
1050
1056
methodName.name != 'toString' &&
1051
1057
methodName.name != 'noSuchMethod' ) {
@@ -1165,6 +1171,11 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
1165
1171
@override
1166
1172
void visitRedirectingConstructorInvocation (
1167
1173
RedirectingConstructorInvocation node) {
1174
+ DartType type =
1175
+ resolutionMap.staticElementForConstructorReference (node)? .type;
1176
+ if (type != null ) {
1177
+ _checkForMissingRequiredParam (type, node.argumentList, node);
1178
+ }
1168
1179
_isInConstructorInitializer = true ;
1169
1180
try {
1170
1181
super .visitRedirectingConstructorInvocation (node);
@@ -1259,6 +1270,11 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
1259
1270
1260
1271
@override
1261
1272
void visitSuperConstructorInvocation (SuperConstructorInvocation node) {
1273
+ DartType type =
1274
+ resolutionMap.staticElementForConstructorReference (node)? .type;
1275
+ if (type != null ) {
1276
+ _checkForMissingRequiredParam (type, node.argumentList, node);
1277
+ }
1262
1278
_isInConstructorInitializer = true ;
1263
1279
try {
1264
1280
super .visitSuperConstructorInvocation (node);
@@ -4101,6 +4117,24 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
4101
4117
}
4102
4118
}
4103
4119
4120
+ void _checkForMissingRequiredParam (
4121
+ DartType type, ArgumentList argumentList, AstNode node) {
4122
+ if (type is FunctionType ) {
4123
+ for (ParameterElement parameter in type.parameters) {
4124
+ if (parameter.isRequiredNamed) {
4125
+ String parameterName = parameter.name;
4126
+ if (! RequiredConstantsComputer ._containsNamedExpression (
4127
+ argumentList, parameterName)) {
4128
+ _errorReporter.reportErrorForNode (
4129
+ CompileTimeErrorCode .MISSING_REQUIRED_PARAM ,
4130
+ node,
4131
+ [parameterName]);
4132
+ }
4133
+ }
4134
+ }
4135
+ }
4136
+ }
4137
+
4104
4138
/**
4105
4139
* Verify that the given function [body] does not contain return statements
4106
4140
* that both have and do not have return values.
@@ -5955,14 +5989,14 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
5955
5989
return result;
5956
5990
}
5957
5991
5958
- // Find a method which is overridden by [node] and which is annotated with
5959
- // `@mustCallSuper`.
5960
- //
5961
- // As per the definition of `mustCallSuper` [1], every method which overrides
5962
- // a method annotated with `@mustCallSuper` is implicitly annotated with
5963
- // `@mustCallSuper`.
5964
- //
5965
- // [1] https://pub.dartlang.org/documentation/meta/latest/meta/mustCallSuper-constant.html
5992
+ /// Find a method which is overridden by [node] and which is annotated with
5993
+ /// `@mustCallSuper` .
5994
+ ///
5995
+ /// As per the definition of `mustCallSuper` [1] , every method which overrides
5996
+ /// a method annotated with `@mustCallSuper` is implicitly annotated with
5997
+ /// `@mustCallSuper` .
5998
+ ///
5999
+ /// [1] https://pub.dartlang.org/documentation/meta/latest/meta/mustCallSuper-constant.html
5966
6000
MethodElement _findOverriddenMemberThatMustCallSuper (MethodDeclaration node) {
5967
6001
Element member = node.declaredElement;
5968
6002
ClassElement classElement = member.enclosingElement;
@@ -6108,7 +6142,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
6108
6142
return setterParameters[0 ].type;
6109
6143
}
6110
6144
6111
- // Returns whether [node] overrides a concrete method.
6145
+ /// Returns whether [node] overrides a concrete method.
6112
6146
bool _hasConcreteSuperMethod (MethodDeclaration node) {
6113
6147
ClassElement classElement = node.declaredElement.enclosingElement;
6114
6148
String name = node.declaredElement.name;
@@ -6499,7 +6533,7 @@ class RequiredConstantsComputer extends RecursiveAstVisitor {
6499
6533
DartType type, ArgumentList argumentList, AstNode node) {
6500
6534
if (type is FunctionType ) {
6501
6535
for (ParameterElement parameter in type.parameters) {
6502
- if (parameter.isNamed ) {
6536
+ if (parameter.isOptionalNamed ) {
6503
6537
ElementAnnotationImpl annotation = _getRequiredAnnotation (parameter);
6504
6538
if (annotation != null ) {
6505
6539
String parameterName = parameter.name;
@@ -6514,7 +6548,11 @@ class RequiredConstantsComputer extends RecursiveAstVisitor {
6514
6548
}
6515
6549
}
6516
6550
6517
- bool _containsNamedExpression (ArgumentList args, String name) {
6551
+ ElementAnnotationImpl _getRequiredAnnotation (ParameterElement param) => param
6552
+ .metadata
6553
+ .firstWhere ((ElementAnnotation e) => e.isRequired, orElse: () => null );
6554
+
6555
+ static bool _containsNamedExpression (ArgumentList args, String name) {
6518
6556
NodeList <Expression > arguments = args.arguments;
6519
6557
for (int i = arguments.length - 1 ; i >= 0 ; i-- ) {
6520
6558
Expression expression = arguments[i];
@@ -6526,10 +6564,6 @@ class RequiredConstantsComputer extends RecursiveAstVisitor {
6526
6564
}
6527
6565
return false ;
6528
6566
}
6529
-
6530
- ElementAnnotationImpl _getRequiredAnnotation (ParameterElement param) => param
6531
- .metadata
6532
- .firstWhere ((ElementAnnotation e) => e.isRequired, orElse: () => null );
6533
6567
}
6534
6568
6535
6569
class _HasTypedefSelfReferenceVisitor extends GeneralizingElementVisitor <void > {
0 commit comments