@@ -111,7 +111,7 @@ class EnclosingExecutableContext {
111111 }
112112
113113 String ? get displayName {
114- return element ? .displayName;
114+ return element2 ? .displayName;
115115 }
116116
117117 ExecutableElement2 ? get element2 => element.asElement2;
@@ -120,7 +120,7 @@ class EnclosingExecutableContext {
120120 return element is FunctionElement && element! .displayName.isEmpty;
121121 }
122122
123- bool get isConstructor => element is ConstructorElement ;
123+ bool get isConstructor => element2 is ConstructorElement2 ;
124124
125125 bool get isFunction {
126126 if (element is FunctionElement ) {
@@ -129,12 +129,12 @@ class EnclosingExecutableContext {
129129 return element is PropertyAccessorElement ;
130130 }
131131
132- bool get isMethod => element is MethodElement ;
132+ bool get isMethod => element2 is MethodElement2 ;
133133
134134 bool get isSynchronous => ! isAsynchronous;
135135
136136 DartType get returnType {
137- return catchErrorOnErrorReturnType ?? element ! .returnType;
137+ return catchErrorOnErrorReturnType ?? element2 ! .returnType;
138138 }
139139
140140 static bool _inFactoryConstructor (Element ? element) {
@@ -435,8 +435,8 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
435435 void visitBreakStatement (BreakStatement node) {
436436 var labelNode = node.label;
437437 if (labelNode != null ) {
438- var labelElement = labelNode.staticElement ;
439- if (labelElement is LabelElementImpl && labelElement.isOnSwitchMember) {
438+ var labelElement = labelNode.element ;
439+ if (labelElement is LabelElementImpl2 && labelElement.isOnSwitchMember) {
440440 errorReporter.atNode (
441441 labelNode,
442442 CompileTimeErrorCode .BREAK_LABEL_ON_SWITCH_MEMBER ,
@@ -657,7 +657,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
657657 checkForAssignableExpressionAtType (
658658 defaultValue,
659659 defaultValue.typeOrThrow,
660- node.declaredElement ! .type,
660+ node.declaredFragment ! .element .type,
661661 CompileTimeErrorCode .INVALID_ASSIGNMENT ,
662662 );
663663 }
@@ -926,7 +926,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
926926 @override
927927 void visitForEachPartsWithDeclaration (ForEachPartsWithDeclaration node) {
928928 DeclaredIdentifier loopVariable = node.loopVariable;
929- if (_checkForEachParts (node, loopVariable.declaredElement )) {
929+ if (_checkForEachParts (node, loopVariable.declaredFragment ? .element )) {
930930 if (loopVariable.isConst) {
931931 errorReporter.atToken (
932932 loopVariable.keyword! ,
@@ -940,7 +940,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
940940 @override
941941 void visitForEachPartsWithIdentifier (ForEachPartsWithIdentifier node) {
942942 SimpleIdentifier identifier = node.identifier;
943- if (_checkForEachParts (node, identifier.staticElement )) {
943+ if (_checkForEachParts (node, identifier.element )) {
944944 _checkForAssignmentToFinal (identifier);
945945 }
946946 super .visitForEachPartsWithIdentifier (node);
@@ -994,7 +994,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
994994 if (node.parent is FunctionDeclaration ) {
995995 super .visitFunctionExpression (node);
996996 } else {
997- _withEnclosingExecutable (node.declaredElement ! , () {
997+ _withEnclosingExecutable2 (node.declaredFragment ! .element , () {
998998 super .visitFunctionExpression (node);
999999 });
10001000 }
@@ -1283,11 +1283,11 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
12831283 void visitNamedType (NamedType node) {
12841284 _checkForAmbiguousImport (
12851285 name: node.name2,
1286- element: node.element ,
1286+ element: node.element2 ,
12871287 );
12881288 _checkForTypeParameterReferencedByStatic (
12891289 name: node.name2,
1290- element: node.element ,
1290+ element: node.element2 ,
12911291 );
12921292 _typeArgumentsVerifier.checkNamedType (node);
12931293 super .visitNamedType (node);
@@ -1435,7 +1435,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
14351435 void visitSimpleIdentifier (SimpleIdentifier node) {
14361436 _checkForAmbiguousImport (
14371437 name: node.token,
1438- element: node.writeOrReadElement ,
1438+ element: node.writeOrReadElement2 ,
14391439 );
14401440 _checkForReferenceBeforeDeclaration (
14411441 nameToken: node.token,
@@ -1444,7 +1444,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
14441444 _checkForInvalidInstanceMemberAccess (node);
14451445 _checkForTypeParameterReferencedByStatic (
14461446 name: node.token,
1447- element: node.staticElement ,
1447+ element: node.element ,
14481448 );
14491449 if (! _isUnqualifiedReferenceToNonLocalStaticMemberAllowed (node)) {
14501450 _checkForUnqualifiedReferenceToNonLocalStaticMember (node);
@@ -1964,9 +1964,9 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
19641964
19651965 void _checkForAbstractOrExternalVariableInitializer (
19661966 VariableDeclaration node) {
1967- var declaredElement = node.declaredElement ;
1967+ var declaredElement = node.declaredFragment ? .element ;
19681968 if (node.initializer != null ) {
1969- if (declaredElement is FieldElement ) {
1969+ if (declaredElement is FieldElement2 ) {
19701970 if (declaredElement.isAbstract) {
19711971 errorReporter.atToken (
19721972 node.name,
@@ -1979,7 +1979,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
19791979 CompileTimeErrorCode .EXTERNAL_FIELD_INITIALIZER ,
19801980 );
19811981 }
1982- } else if (declaredElement is TopLevelVariableElement ) {
1982+ } else if (declaredElement is TopLevelVariableElement2 ) {
19831983 if (declaredElement.isExternal) {
19841984 errorReporter.atToken (
19851985 node.name,
@@ -2054,7 +2054,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
20542054 }
20552055
20562056 // Prepare redirected constructor type
2057- var redirectedElement = redirectedConstructor.staticElement ;
2057+ var redirectedElement = redirectedConstructor.element ;
20582058 if (redirectedElement == null ) {
20592059 // If the element is null, we check for the
20602060 // REDIRECT_TO_MISSING_CONSTRUCTOR case
@@ -2078,7 +2078,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
20782078 DartType redirectedReturnType = redirectedType.returnType;
20792079
20802080 // Report specific problem when return type is incompatible
2081- FunctionType constructorType = declaration.declaredElement ! .type;
2081+ FunctionType constructorType = declaration.declaredFragment ! .element .type;
20822082 DartType constructorReturnType = constructorType.returnType;
20832083 if (! typeSystem.isAssignableTo (redirectedReturnType, constructorReturnType,
20842084 strictCasts: strictCasts)) {
@@ -2134,10 +2134,10 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
21342134 /// imported from two or more imports.
21352135 void _checkForAmbiguousImport ({
21362136 required Token name,
2137- required Element ? element,
2137+ required Element2 ? element,
21382138 }) {
2139- if (element is MultiplyDefinedElementImpl ) {
2140- var conflictingMembers = element.conflictingElements ;
2139+ if (element is MultiplyDefinedElementImpl2 ) {
2140+ var conflictingMembers = element.conflictingElements2 ;
21412141 var libraryNames =
21422142 conflictingMembers.map ((e) => _getLibraryName (e)).toList ();
21432143 libraryNames.sort ();
@@ -2357,16 +2357,16 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
23572357 for (NamedType withMixin in withClause.mixinTypes) {
23582358 var withType = withMixin.type;
23592359 if (withType is InterfaceType ) {
2360- var withElement = withType.element ;
2361- if (withElement is ClassElementImpl &&
2360+ var withElement = withType.element3 ;
2361+ if (withElement is ClassElementImpl2 &&
23622362 ! withElement.isMixinClass &&
2363- withElement.library .featureSet
2363+ withElement.library2 .featureSet
23642364 .isEnabled (Feature .class_modifiers) &&
2365- ! _mayIgnoreClassModifiers (withElement.library )) {
2365+ ! _mayIgnoreClassModifiers (withElement.library2 )) {
23662366 errorReporter.atNode (
23672367 withMixin,
23682368 CompileTimeErrorCode .CLASS_USED_AS_MIXIN ,
2369- arguments: [withElement.name ],
2369+ arguments: [withElement.name3 ! ],
23702370 );
23712371 }
23722372 }
@@ -2550,31 +2550,34 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
25502550
25512551 /// Verify all conflicts between type variable and enclosing class.
25522552 void _checkForConflictingClassTypeVariableErrorCodes () {
2553- var enclosingClass = _enclosingClass! ;
2554- for (TypeParameterElement typeParameter in enclosingClass.typeParameters) {
2553+ var enclosingClass = _enclosingClass! .asElement2;
2554+ for (TypeParameterElement2 typeParameter
2555+ in enclosingClass.typeParameters2) {
25552556 if (typeParameter.isWildcardVariable) continue ;
25562557
2557- String name = typeParameter.name;
2558+ var name = typeParameter.name3;
2559+ if (name == null ) continue ;
2560+
25582561 // name is same as the name of the enclosing class
2559- if (enclosingClass.name == name) {
2560- var code = enclosingClass is MixinElement
2562+ if (enclosingClass.name3 == name) {
2563+ var code = enclosingClass is MixinElement2
25612564 ? CompileTimeErrorCode .CONFLICTING_TYPE_VARIABLE_AND_MIXIN
25622565 : CompileTimeErrorCode .CONFLICTING_TYPE_VARIABLE_AND_CLASS ;
2563- errorReporter.atElement (
2566+ errorReporter.atElement2 (
25642567 typeParameter,
25652568 code,
25662569 arguments: [name],
25672570 );
25682571 }
25692572 // check members
2570- if (enclosingClass.getNamedConstructor (name) != null ||
2571- enclosingClass.getMethod (name) != null ||
2572- enclosingClass.getGetter (name) != null ||
2573- enclosingClass.getSetter (name) != null ) {
2574- var code = enclosingClass is MixinElement
2573+ if (enclosingClass.getNamedConstructor2 (name) != null ||
2574+ enclosingClass.getMethod2 (name) != null ||
2575+ enclosingClass.getGetter2 (name) != null ||
2576+ enclosingClass.getSetter2 (name) != null ) {
2577+ var code = enclosingClass is MixinElement2
25752578 ? CompileTimeErrorCode .CONFLICTING_TYPE_VARIABLE_AND_MEMBER_MIXIN
25762579 : CompileTimeErrorCode .CONFLICTING_TYPE_VARIABLE_AND_MEMBER_CLASS ;
2577- errorReporter.atElement (
2580+ errorReporter.atElement2 (
25782581 typeParameter,
25792582 code,
25802583 arguments: [name],
@@ -3120,7 +3123,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
31203123
31213124 /// Return `true` if the caller should continue checking the rest of the
31223125 /// information in the for-each part.
3123- bool _checkForEachParts (ForEachParts node, Element ? variableElement) {
3126+ bool _checkForEachParts (ForEachParts node, Element2 ? variableElement) {
31243127 if (checkForUseOfVoidResult (node.iterable)) {
31253128 return false ;
31263129 }
@@ -3154,7 +3157,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
31543157
31553158 // The type of the loop variable.
31563159 DartType variableType;
3157- if (variableElement is VariableElement ) {
3160+ if (variableElement is VariableElement2 ) {
31583161 variableType = variableElement.type;
31593162 } else {
31603163 return false ;
@@ -5448,11 +5451,11 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
54485451
54495452 void _checkForTypeParameterReferencedByStatic ({
54505453 required Token name,
5451- required Element ? element,
5454+ required Element2 ? element,
54525455 }) {
54535456 if (_enclosingExecutable.inStaticMethod || _isInStaticVariableDeclaration) {
5454- if (element is TypeParameterElement &&
5455- element.enclosingElement3 is InstanceElement ) {
5457+ if (element is TypeParameterElement2 &&
5458+ element.enclosingElement2 is InstanceElement2 ) {
54565459 // The class's type parameters are not in scope for static methods.
54575460 // However all other type parameters are legal (e.g. the static method's
54585461 // type parameters, or a local function's type parameters).
@@ -6317,15 +6320,15 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
63176320 }
63186321
63196322 /// Return the name of the library that defines given [element] .
6320- String _getLibraryName (Element ? element) {
6323+ String _getLibraryName (Element2 ? element) {
63216324 if (element == null ) {
63226325 return '' ;
63236326 }
6324- var library = element.library ;
6327+ var library = element.library2 ;
63256328 if (library == null ) {
63266329 return '' ;
63276330 }
6328- var name = element.name ;
6331+ var name = element.name3 ;
63296332 if (name == null ) {
63306333 return '' ;
63316334 }
@@ -6335,22 +6338,22 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
63356338 int count = imports.length;
63366339 for (int i = 0 ; i < count; i++ ) {
63376340 if (identical (imports[i].importedLibrary, library)) {
6338- return library.definingCompilationUnit.source. uri.toString ();
6341+ return library.uri.toString ();
63396342 }
63406343 }
63416344 List <String > indirectSources = < String > [];
63426345 for (var import in imports) {
63436346 var importedLibrary = import.importedLibrary;
63446347 if (importedLibrary != null ) {
6345- if (import.namespace.get (name) == element) {
6348+ if (import.namespace.get2 (name) == element) {
63466349 indirectSources.add (
63476350 importedLibrary.definingCompilationUnit.source.uri.toString ());
63486351 }
63496352 }
63506353 }
63516354 int indirectCount = indirectSources.length;
63526355 StringBuffer buffer = StringBuffer ();
6353- buffer.write (library.definingCompilationUnit.source. uri.toString ());
6356+ buffer.write (library.uri.toString ());
63546357 if (indirectCount > 0 ) {
63556358 buffer.write (" (via " );
63566359 if (indirectCount > 1 ) {
0 commit comments