33// BSD-style license that can be found in the LICENSE file.
44
55import 'package:analyzer/dart/ast/ast.dart' ;
6- import 'package:analyzer/dart/element/element .dart' ;
6+ import 'package:analyzer/dart/element/element2 .dart' ;
77import 'package:analyzer/dart/element/type.dart' ;
88import 'package:analyzer/error/listener.dart' ;
99import 'package:analyzer/src/dart/element/element.dart' ;
@@ -29,12 +29,12 @@ class AssignmentVerifier {
2929 /// [CompileTimeErrorCode.UNDEFINED_IDENTIFIER] .
3030 void verify ({
3131 required SimpleIdentifier node,
32- required Element ? requested,
33- required Element ? recovery,
32+ required Element2 ? requested,
33+ required Element2 ? recovery,
3434 required DartType ? receiverType,
3535 }) {
3636 if (requested != null ) {
37- if (requested is VariableElement ) {
37+ if (requested is VariableElement2 ) {
3838 if (requested.isConst) {
3939 _errorReporter.atNode (
4040 node,
@@ -45,54 +45,66 @@ class AssignmentVerifier {
4545 return ;
4646 }
4747
48- if (recovery is DynamicElementImpl ||
49- recovery is InterfaceElement ||
50- recovery is TypeAliasElement ||
51- recovery is TypeParameterElement ) {
48+ if (recovery is DynamicElementImpl2 ||
49+ recovery is InterfaceElement2 ||
50+ recovery is TypeAliasElement2 ||
51+ recovery is TypeParameterElement2 ) {
5252 _errorReporter.atNode (
5353 node,
5454 CompileTimeErrorCode .ASSIGNMENT_TO_TYPE ,
5555 );
56- } else if (recovery is FunctionElement ) {
56+ } else if (recovery is LocalFunctionElement ||
57+ recovery is TopLevelFunctionElement ) {
5758 _errorReporter.atNode (
5859 node,
5960 CompileTimeErrorCode .ASSIGNMENT_TO_FUNCTION ,
6061 );
61- } else if (recovery is MethodElement ) {
62+ } else if (recovery is MethodElement2 ) {
6263 _errorReporter.atNode (
6364 node,
6465 CompileTimeErrorCode .ASSIGNMENT_TO_METHOD ,
6566 );
66- } else if (recovery is PrefixElement ) {
67- _errorReporter.atNode (
68- node,
69- CompileTimeErrorCode .PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT ,
70- arguments: [recovery.name],
71- );
72- } else if (recovery is PropertyAccessorElement && recovery.isGetter) {
73- var variable = recovery.variable2;
67+ } else if (recovery is PrefixElement2 ) {
68+ if (recovery.name3 case var prefixName? ) {
69+ _errorReporter.atNode (
70+ node,
71+ CompileTimeErrorCode .PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT ,
72+ arguments: [prefixName],
73+ );
74+ }
75+ } else if (recovery is GetterElement ) {
76+ var variable = recovery.variable3;
7477 if (variable == null ) {
7578 return ;
7679 }
80+
81+ var variableName = variable.name3;
82+ if (variableName == null ) {
83+ return ;
84+ }
85+
7786 if (variable.isConst) {
7887 _errorReporter.atNode (
7988 node,
8089 CompileTimeErrorCode .ASSIGNMENT_TO_CONST ,
8190 );
82- } else if (variable is FieldElement && variable.isSynthetic) {
91+ } else if (variable is FieldElement2 && variable.isSynthetic) {
8392 _errorReporter.atNode (
8493 node,
8594 CompileTimeErrorCode .ASSIGNMENT_TO_FINAL_NO_SETTER ,
86- arguments: [variable.name, variable.enclosingElement3.displayName],
95+ arguments: [
96+ variableName,
97+ variable.enclosingElement2.displayName,
98+ ],
8799 );
88100 } else {
89101 _errorReporter.atNode (
90102 node,
91103 CompileTimeErrorCode .ASSIGNMENT_TO_FINAL ,
92- arguments: [variable.name ],
104+ arguments: [variableName ],
93105 );
94106 }
95- } else if (recovery is MultiplyDefinedElementImpl ) {
107+ } else if (recovery is MultiplyDefinedElementImpl2 ) {
96108 // Will be reported in ErrorVerifier.
97109 } else {
98110 if (node.isSynthetic) {
0 commit comments