visitDefaultFormalParameter method

  1. @override
void visitDefaultFormalParameter(
  1. DefaultFormalParameter node
)
override

Implementation

@override
void visitDefaultFormalParameter(DefaultFormalParameter node) {
  final expression = node.defaultValue;
  if (expression == null) return;
  if (expression.isDotShorthand) return;

  final declaredType = switch (node.parameter) {
    SimpleFormalParameter(type: NamedType(type: final type)) => type,
    _ => null,
  };

  // not same as `variableDeclaration`, function parameter won't do type inference
  if (declaredType == null) return;

  _checkAndReport(expression: expression, declaredType: declaredType);
}