Skip to content

Commit 347e38e

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Migrate ErrorHandlerVerifier.
Change-Id: I830443b807c04dffe6ffd1c14c099bd48f7072af Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395048 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
1 parent d064073 commit 347e38e

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

pkg/analyzer/analyzer_use_new_elements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ lib/src/error/correct_override.dart
108108
lib/src/error/dead_code_verifier.dart
109109
lib/src/error/deprecated_member_use_verifier.dart
110110
lib/src/error/duplicate_definition_verifier.dart
111-
lib/src/error/error_handler_verifier.dart
112111
lib/src/error/getter_setter_types_verifier.dart
113112
lib/src/error/imports_verifier.dart
114113
lib/src/error/inheritance_override.dart

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class ErrorHandlerVerifier {
188188
);
189189
}
190190

191-
var parameters = expressionType.parameters;
191+
var parameters = expressionType.formalParameters;
192192
if (parameters.isEmpty) {
193193
return report();
194194
}
@@ -226,8 +226,8 @@ class ErrorHandlerVerifier {
226226
var callbackType = callback.staticType as FunctionType;
227227
_checkErrorHandlerFunctionType(
228228
callback, callbackType, expectedReturnType);
229-
var catchErrorOnErrorExecutable = EnclosingExecutableContext(
230-
callback.declaredElement,
229+
var catchErrorOnErrorExecutable = EnclosingExecutableContext.tmp(
230+
callback.declaredElement2,
231231
isAsynchronous: true,
232232
catchErrorOnErrorReturnType: expectedReturnType);
233233
var returnStatementVerifier =
@@ -263,8 +263,8 @@ class ErrorHandlerVerifier {
263263
/// the 'dart:async' library.
264264
bool _isDartCoreAsyncType(DartType type, String typeName) =>
265265
type is InterfaceType &&
266-
type.element.name == typeName &&
267-
type.element.library.isDartAsync;
266+
type.element3.name3 == typeName &&
267+
type.element3.library2.isDartAsync;
268268
}
269269

270270
/// Visits a function body, looking for return statements.

pkg/analyzer/lib/src/generated/error_verifier.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ class EnclosingExecutableContext {
105105

106106
EnclosingExecutableContext.empty() : this(null);
107107

108+
factory EnclosingExecutableContext.tmp(ExecutableElement2? element,
109+
{bool? isAsynchronous, InterfaceType? catchErrorOnErrorReturnType}) {
110+
return EnclosingExecutableContext(
111+
element.asElement,
112+
isAsynchronous: isAsynchronous,
113+
catchErrorOnErrorReturnType: catchErrorOnErrorReturnType,
114+
);
115+
}
116+
108117
String? get displayName {
109118
return element?.displayName;
110119
}
@@ -835,7 +844,8 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
835844
.addConstructors(errorReporter, declaredElement, members);
836845
_checkForNonCovariantTypeParameterPositionInRepresentationType(
837846
node, declaredFragment);
838-
_checkForExtensionTypeRepresentationDependsOnItself(node, declaredFragment);
847+
_checkForExtensionTypeRepresentationDependsOnItself(
848+
node, declaredFragment);
839849
_checkForExtensionTypeRepresentationTypeBottom(node, declaredFragment);
840850
_checkForExtensionTypeImplementsDeferred(node);
841851
_checkForExtensionTypeImplementsItself(node, declaredFragment);

pkg/analyzer/lib/src/utilities/extensions/element.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ extension ExecutableElement2Extension on ExecutableElement2 {
201201
}
202202
}
203203

204+
extension ExecutableElement2OrNullExtension on ExecutableElement2? {
205+
ExecutableElement? get asElement {
206+
return this?.asElement;
207+
}
208+
}
209+
204210
extension ExecutableElementExtension on ExecutableElement {
205211
ExecutableElement2 get asElement2 {
206212
return switch (this) {

0 commit comments

Comments
 (0)