| Index: pkg/analyzer/lib/src/generated/resolver.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
|
| index df3ad03b5db7488cf0265ee48f554e1d04641400..c041f3dce4a2a044e402ff4cd6facfb05725aa5d 100644
|
| --- a/pkg/analyzer/lib/src/generated/resolver.dart
|
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart
|
| @@ -7,6 +7,7 @@ library analyzer.src.generated.resolver;
|
| import 'dart:collection';
|
|
|
| import 'package:analyzer/dart/ast/ast.dart';
|
| +import 'package:analyzer/dart/ast/resolution_accessors.dart';
|
| import 'package:analyzer/dart/ast/token.dart';
|
| import 'package:analyzer/dart/ast/visitor.dart';
|
| import 'package:analyzer/dart/element/element.dart';
|
| @@ -105,7 +106,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
|
|
| @override
|
| Object visitAnnotation(Annotation node) {
|
| - if (node.elementAnnotation?.isFactory == true) {
|
| + if (elementAnnotationForAnnotation(node)?.isFactory == true) {
|
| AstNode parent = node.parent;
|
| if (parent is MethodDeclaration) {
|
| _checkForInvalidFactory(parent);
|
| @@ -193,7 +194,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
|
|
| @override
|
| Object visitConstructorDeclaration(ConstructorDeclaration node) {
|
| - if (node.element.isFactory) {
|
| + if (elementForConstructorDeclaration(node).isFactory) {
|
| if (node.body is BlockFunctionBody) {
|
| // Check the block for a return statement, if not, create the hint.
|
| if (!ExitDetector.exits(node.body)) {
|
| @@ -648,7 +649,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| node is MethodInvocation &&
|
| node.staticInvokeType is InterfaceType) {
|
| displayName =
|
| - "${node.staticInvokeType.displayName}.${element.displayName}";
|
| + "${staticInvokeTypeForInvocationExpression(node).displayName}.${element.displayName}";
|
| }
|
| _errorReporter.reportErrorForNode(
|
| HintCode.DEPRECATED_MEMBER_USE, node, [displayName]);
|
| @@ -2287,7 +2288,7 @@ class DirectiveResolver extends SimpleAstVisitor {
|
|
|
| @override
|
| void visitCompilationUnit(CompilationUnit node) {
|
| - _enclosingLibrary = node.element.library;
|
| + _enclosingLibrary = elementForCompilationUnit(node).library;
|
| for (Directive directive in node.directives) {
|
| directive.accept(this);
|
| }
|
| @@ -3594,7 +3595,7 @@ class HintGenerator {
|
| GatherUsedLocalElementsVisitor _usedLocalElementsVisitor;
|
|
|
| HintGenerator(this._compilationUnits, this._context, this._errorListener) {
|
| - _library = _compilationUnits[0].element.library;
|
| + _library = elementForCompilationUnit(_compilationUnits[0]).library;
|
| _usedImportedElementsVisitor =
|
| new GatherUsedImportedElementsVisitor(_library);
|
| _enableDart2JSHints = _context.analysisOptions.dart2jsHint;
|
| @@ -3614,8 +3615,8 @@ class HintGenerator {
|
| }
|
| }
|
| CompilationUnit definingUnit = _compilationUnits[0];
|
| - ErrorReporter definingUnitErrorReporter =
|
| - new ErrorReporter(_errorListener, definingUnit.element.source);
|
| + ErrorReporter definingUnitErrorReporter = new ErrorReporter(
|
| + _errorListener, elementForCompilationUnit(definingUnit).source);
|
| {
|
| ImportsVerifier importsVerifier = new ImportsVerifier();
|
| importsVerifier.addImports(definingUnit);
|
| @@ -5788,7 +5789,8 @@ class ResolverVisitor extends ScopedVisitor {
|
|
|
| @override
|
| Object visitDefaultFormalParameter(DefaultFormalParameter node) {
|
| - InferenceContext.setType(node.defaultValue, node.parameter.element?.type);
|
| + InferenceContext.setType(
|
| + node.defaultValue, elementForFormalParameter(node.parameter)?.type);
|
| super.visitDefaultFormalParameter(node);
|
| ParameterElement element = node.element;
|
| if (element.initializer != null && node.defaultValue != null) {
|
| @@ -5906,8 +5908,8 @@ class ResolverVisitor extends ScopedVisitor {
|
| InterfaceType targetType = (node.awaitKeyword == null)
|
| ? typeProvider.iterableType
|
| : typeProvider.streamType;
|
| - InferenceContext.setType(
|
| - iterable, targetType.instantiate([loopVariable.type.type]));
|
| + InferenceContext.setType(iterable,
|
| + targetType.instantiate([typeForTypeName(loopVariable.type)]));
|
| }
|
| iterable?.accept(this);
|
| loopVariable?.accept(this);
|
| @@ -6017,7 +6019,9 @@ class ResolverVisitor extends ScopedVisitor {
|
| _inferFormalParameterList(node.parameters, functionType);
|
|
|
| DartType returnType;
|
| - if (isFutureThen(node.staticParameterElement?.enclosingElement)) {
|
| + ParameterElement parameterElement =
|
| + staticParameterElementForExpression(node);
|
| + if (isFutureThen(parameterElement?.enclosingElement)) {
|
| var futureThenType =
|
| InferenceContext.getContext(node.parent) as FunctionType;
|
|
|
| @@ -6178,7 +6182,7 @@ class ResolverVisitor extends ScopedVisitor {
|
| List<DartType> targs =
|
| inferenceContext.matchTypes(classTypeName.type, contextType);
|
| if (targs != null && targs.any((t) => !t.isDynamic)) {
|
| - ClassElement classElement = classTypeName.type.element;
|
| + ClassElement classElement = typeForTypeName(classTypeName).element;
|
| InterfaceType rawType = classElement.type;
|
| InterfaceType fullType =
|
| rawType.substitute2(targs, rawType.typeArguments);
|
| @@ -6191,7 +6195,8 @@ class ResolverVisitor extends ScopedVisitor {
|
| }
|
| }
|
| node.constructorName?.accept(this);
|
| - FunctionType constructorType = node.constructorName.staticElement?.type;
|
| + FunctionType constructorType =
|
| + staticElementForConstructorReference(node.constructorName)?.type;
|
| if (constructorType != null) {
|
| InferenceContext.setType(node.argumentList, constructorType);
|
| }
|
| @@ -6350,7 +6355,8 @@ class ResolverVisitor extends ScopedVisitor {
|
| // because it needs to be visited in the context of the constructor
|
| // invocation.
|
| //
|
| - InferenceContext.setType(node.argumentList, node.staticElement?.type);
|
| + InferenceContext.setType(
|
| + node.argumentList, staticElementForConstructorReference(node)?.type);
|
| node.argumentList?.accept(this);
|
| node.accept(elementResolver);
|
| node.accept(typeAnalyzer);
|
| @@ -6384,7 +6390,8 @@ class ResolverVisitor extends ScopedVisitor {
|
| // because it needs to be visited in the context of the constructor
|
| // invocation.
|
| //
|
| - InferenceContext.setType(node.argumentList, node.staticElement?.type);
|
| + InferenceContext.setType(
|
| + node.argumentList, staticElementForConstructorReference(node)?.type);
|
| node.argumentList?.accept(this);
|
| node.accept(elementResolver);
|
| node.accept(typeAnalyzer);
|
| @@ -6457,7 +6464,8 @@ class ResolverVisitor extends ScopedVisitor {
|
| @override
|
| visitVariableDeclarationList(VariableDeclarationList node) {
|
| for (VariableDeclaration decl in node.variables) {
|
| - InferenceContext.setType(decl, decl.element?.type);
|
| + VariableElement variableElement = elementForVariableDeclaration(decl);
|
| + InferenceContext.setType(decl, variableElement?.type);
|
| }
|
| super.visitVariableDeclarationList(node);
|
| }
|
| @@ -6744,7 +6752,7 @@ class ResolverVisitor extends ScopedVisitor {
|
| FunctionType expectedClosureType = mayByFunctionType as FunctionType;
|
| // If the expectedClosureType is not more specific than the static type,
|
| // return.
|
| - DartType staticClosureType = closure.element?.type;
|
| + DartType staticClosureType = elementForFunctionExpression(closure)?.type;
|
| if (staticClosureType != null &&
|
| !FunctionTypeImpl.relate(
|
| expectedClosureType,
|
|
|