Skip to content

Commit 533a04a

Browse files
parloughCommit Queue
authored andcommitted
[linter] Minor simplification to only_throw_errors
Looks like this was written before set literals. Change-Id: I0888ba349e9cc041b009f68604f9dea8fa16fe6a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397381 Commit-Queue: Phil Quitslund <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
1 parent 110c00d commit 533a04a

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

pkg/linter/lib/src/rules/only_throw_errors.dart

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'dart:collection';
6-
75
import 'package:analyzer/dart/ast/ast.dart';
86
import 'package:analyzer/dart/ast/visitor.dart';
97
import 'package:analyzer/dart/element/type.dart';
@@ -15,17 +13,10 @@ import '../util/dart_type_utilities.dart';
1513
const _desc =
1614
r'Only throw instances of classes extending either Exception or Error.';
1715

18-
const _errorClassName = 'Error';
19-
20-
const _exceptionClassName = 'Exception';
21-
22-
const _library = 'dart.core';
23-
24-
final LinkedHashSet<InterfaceTypeDefinition> _interfaceDefinitions =
25-
LinkedHashSet.of([
26-
InterfaceTypeDefinition(_exceptionClassName, _library),
27-
InterfaceTypeDefinition(_errorClassName, _library),
28-
]);
16+
final Set<InterfaceTypeDefinition> _interfaceDefinitions = {
17+
InterfaceTypeDefinition('Exception', 'dart.core'),
18+
InterfaceTypeDefinition('Error', 'dart.core'),
19+
};
2920

3021
bool _isThrowable(DartType? type) {
3122
var typeForInterfaceCheck = type?.typeForInterfaceCheck;

pkg/linter/lib/src/util/dart_type_utilities.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class InterfaceTypeDefinition {
215215
InterfaceTypeDefinition(this.name, this.library);
216216

217217
@override
218-
int get hashCode => name.hashCode ^ library.hashCode;
218+
int get hashCode => Object.hash(name, library);
219219

220220
@override
221221
bool operator ==(Object other) {

0 commit comments

Comments
 (0)