Skip to content

Commit

Permalink
Analyzer: Report on more invlid error handlers.
Browse files Browse the repository at this point in the history
Bug: #35825
Change-Id: I43060e9b0b0a764f14be041c5cbdf1d884d92326
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181740
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
srawlins authored and commit-bot@chromium.org committed Feb 17, 2021
1 parent 3a79bae commit d2bbb91
Show file tree
Hide file tree
Showing 9 changed files with 999 additions and 439 deletions.
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/error/error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ const List<ErrorCode> errorCodeValues = [
FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_EXTENDS,
FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_IMPLEMENTS,
FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_WITH,
HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE_CATCH_ERROR_ON_ERROR,
HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE_TO_ERROR_HANDLER,
HintCode.ASSIGNMENT_OF_DO_NOT_STORE,
HintCode.CAN_BE_NULL_AFTER_NULL_AWARE,
HintCode.DEAD_CODE,
Expand Down
4 changes: 2 additions & 2 deletions pkg/analyzer/lib/src/dart/error/hint_codes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class HintCode extends AnalyzerErrorCode {
* 0: the name of the actual argument type
* 1: the name of the expected function return type
*/
static const HintCode ARGUMENT_TYPE_NOT_ASSIGNABLE_CATCH_ERROR_ON_ERROR =
static const HintCode ARGUMENT_TYPE_NOT_ASSIGNABLE_TO_ERROR_HANDLER =
HintCode(
'ARGUMENT_TYPE_NOT_ASSIGNABLE_CATCH_ERROR_ON_ERROR',
'ARGUMENT_TYPE_NOT_ASSIGNABLE_TO_ERROR_HANDLER',
"The argument type '{0}' can't be assigned to the parameter type "
"'{1} Function(Object)' or '{1} Function(Object, StackTrace)'.");

Expand Down
10 changes: 5 additions & 5 deletions pkg/analyzer/lib/src/error/best_practices_verifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import 'package:analyzer/src/dart/element/type_system.dart';
import 'package:analyzer/src/dart/resolver/body_inference_context.dart';
import 'package:analyzer/src/dart/resolver/exit_detector.dart';
import 'package:analyzer/src/dart/resolver/scope.dart';
import 'package:analyzer/src/error/catch_error_verifier.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/error/deprecated_member_use_verifier.dart';
import 'package:analyzer/src/error/error_handler_verifier.dart';
import 'package:analyzer/src/error/must_call_super_verifier.dart';
import 'package:analyzer/src/generated/constant.dart';
import 'package:analyzer/src/generated/engine.dart';
Expand Down Expand Up @@ -70,7 +70,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {

final MustCallSuperVerifier _mustCallSuperVerifier;

final CatchErrorVerifier _catchErrorVerifier;
final ErrorHandlerVerifier _errorHandlerVerifier;

/// The [WorkspacePackage] in which [_currentLibrary] is declared.
final WorkspacePackage? _workspacePackage;
Expand Down Expand Up @@ -109,8 +109,8 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
_deprecatedVerifier =
DeprecatedMemberUseVerifier(workspacePackage, _errorReporter),
_mustCallSuperVerifier = MustCallSuperVerifier(_errorReporter),
_catchErrorVerifier =
CatchErrorVerifier(_errorReporter, typeProvider, typeSystem),
_errorHandlerVerifier =
ErrorHandlerVerifier(_errorReporter, typeProvider, typeSystem),
_workspacePackage = workspacePackage {
_deprecatedVerifier.pushInDeprecatedValue(_currentLibrary.hasDeprecated);
_inDoNotStoreMember = _currentLibrary.hasDoNotStore;
Expand Down Expand Up @@ -596,7 +596,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
void visitMethodInvocation(MethodInvocation node) {
_deprecatedVerifier.methodInvocation(node);
_checkForNullAwareHints(node, node.operator);
_catchErrorVerifier.verifyMethodInvocation(node);
_errorHandlerVerifier.verifyMethodInvocation(node);
super.visitMethodInvocation(node);
}

Expand Down
150 changes: 0 additions & 150 deletions pkg/analyzer/lib/src/error/catch_error_verifier.dart

This file was deleted.

Loading

0 comments on commit d2bbb91

Please sign in to comment.