Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 2551023005: Prepare for decoupling analyzer ASTs from element model. (Closed)
Patch Set: Address review comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/generated/error_verifier.dart
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 0d6ecf83ff5ee7a4c3b5e83705b724de0a531009..666f63ecaa555c6359d74688e8b01379b27e7853 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -8,6 +8,7 @@ import 'dart:collection';
import "dart:math" as math;
import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/standard_resolution_map.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
@@ -857,7 +858,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
// we can get the function element via `node?.element?.type?.element` but
// it doesn't have hasImplicitReturnType set correctly.
if (!_options.implicitDynamic && node.returnType == null) {
- DartType parameterType = node.element.type;
+ DartType parameterType =
+ resolutionMap.elementDeclaredByFormalParameter(node).type;
if (parameterType is FunctionType &&
parameterType.returnType.isDynamic) {
_errorReporter.reportErrorForNode(
@@ -2238,7 +2240,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
DartType redirectedReturnType = redirectedType.returnType;
// Report specific problem when return type is incompatible
- FunctionType constructorType = declaration.element.type;
+ FunctionType constructorType =
+ resolutionMap.elementDeclaredByConstructorDeclaration(declaration).type;
DartType constructorReturnType = constructorType.returnType;
if (!_typeSystem.isAssignableTo(
redirectedReturnType, constructorReturnType)) {
@@ -2892,8 +2895,9 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
Element enclosingElementOfSetter = null;
ClassMember conflictingSetter = memberHashMap[setterName];
if (conflictingSetter != null) {
- enclosingElementOfSetter =
- conflictingSetter.element.enclosingElement;
+ enclosingElementOfSetter = resolutionMap
+ .elementDeclaredByDeclaration(conflictingSetter)
+ .enclosingElement;
} else {
ExecutableElement elementFromInheritance = _inheritanceManager
.lookupInheritance(_enclosingClass, setterName);
@@ -4733,7 +4737,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
void _checkForMissingJSLibAnnotation(Annotation node) {
- if (node.elementAnnotation?.isJS ?? false) {
+ if (resolutionMap.elementAnnotationForAnnotation(node)?.isJS ?? false) {
if (_currentLibrary.isJS != true) {
_errorReporter.reportErrorForNode(
HintCode.MISSING_JS_LIB_ANNOTATION, node);
@@ -6898,7 +6902,9 @@ class RequiredConstantsComputer extends RecursiveAstVisitor {
DartType type = node.constructorName.type.type;
if (type is InterfaceType) {
_checkForMissingRequiredParam(
- node.staticElement?.type, node.argumentList, node.constructorName);
+ resolutionMap.staticElementForConstructorReference(node)?.type,
+ node.argumentList,
+ node.constructorName);
}
return super.visitInstanceCreationExpression(node);
}
@@ -6913,7 +6919,8 @@ class RequiredConstantsComputer extends RecursiveAstVisitor {
@override
Object visitRedirectingConstructorInvocation(
RedirectingConstructorInvocation node) {
- DartType type = node.staticElement?.type;
+ DartType type =
+ resolutionMap.staticElementForConstructorReference(node)?.type;
if (type != null) {
_checkForMissingRequiredParam(type, node.argumentList, node);
}
@@ -6922,7 +6929,8 @@ class RequiredConstantsComputer extends RecursiveAstVisitor {
@override
Object visitSuperConstructorInvocation(SuperConstructorInvocation node) {
- DartType type = node.staticElement?.type;
+ DartType type =
+ resolutionMap.staticElementForConstructorReference(node)?.type;
if (type != null) {
_checkForMissingRequiredParam(type, node.argumentList, node);
}

Powered by Google App Engine
This is Rietveld 408576698