44
55import 'package:analyzer/dart/ast/ast.dart' ;
66import 'package:analyzer/dart/ast/visitor.dart' ;
7- import 'package:analyzer/dart/element/element .dart' ;
7+ import 'package:analyzer/dart/element/element2 .dart' ;
88
99import '../analyzer.dart' ;
1010import '../ast.dart' ;
@@ -49,11 +49,11 @@ class _Visitor extends SimpleAstVisitor<void> {
4949 void visitThisExpression (ThisExpression node) {
5050 var parent = node.parent;
5151
52- Element ? element;
52+ Element2 ? element;
5353 if (parent is PropertyAccess && ! parent.isNullAware) {
54- element = getWriteOrReadElement (parent.propertyName);
54+ element = getWriteOrReadElement2 (parent.propertyName);
5555 } else if (parent is MethodInvocation && ! parent.isNullAware) {
56- element = parent.methodName.staticElement ;
56+ element = parent.methodName.element ;
5757 } else {
5858 return ;
5959 }
@@ -63,25 +63,23 @@ class _Visitor extends SimpleAstVisitor<void> {
6363 }
6464 }
6565
66- bool _canReferenceElementWithoutThisPrefix (Element ? element, AstNode node) {
67- if (element == null ) {
68- return false ;
69- }
66+ bool _canReferenceElementWithoutThisPrefix (Element2 ? element, AstNode node) {
67+ if (element == null ) return false ;
7068
7169 var id = element.displayName;
72- var isSetter = element is PropertyAccessorElement && element.isSetter;
73- var result = resolveNameInScope (id, node, shouldResolveSetter: isSetter );
70+ var result = resolveNameInScope (id, node,
71+ shouldResolveSetter: element is SetterElement );
7472
7573 // No result, definitely no shadowing.
7674 // The requested element is inherited, or from an extension.
77- if (result.isNone) {
78- return true ;
79- }
75+ if (result.isNone) return true ;
76+
77+ var resultElement = result.element2;
8078
8179 // The result has the matching name, might be shadowing.
8280 // Check that the element is the same.
8381 if (result.isRequestedName) {
84- return result.element == element;
82+ return resultElement == element;
8583 }
8684
8785 // The result has the same basename, but not the same name.
@@ -90,8 +88,8 @@ class _Visitor extends SimpleAstVisitor<void> {
9088 // - prevents us from going up to the library scope;
9189 // - the requested element must be inherited, or from an extension.
9290 if (result.isDifferentName) {
93- var enclosing = result.element ? .enclosingElement3 ;
94- return enclosing is ClassElement ;
91+ var enclosing = resultElement ? .enclosingElement2 ;
92+ return enclosing is ClassElement2 ;
9593 }
9694
9795 // Should not happen.
0 commit comments