@@ -944,14 +944,14 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
944944
945945 @override
946946 void visitFunctionDeclaration (covariant FunctionDeclarationImpl node) {
947- var fragment = node.declaredFragment! ;
948- var element = node.declaredElement ! ;
949- if (element.enclosingElement3 is ! CompilationUnitElement ) {
947+ var fragment = node.declaredFragment! ;
948+ var element = fragment.element ;
949+ if (element.enclosingElement2 is ! LibraryElement2 ) {
950950 _hiddenElements! .declare (element);
951951 }
952952
953953 _withEnclosingExecutable (
954- element.asElement2 ,
954+ element,
955955 () {
956956 TypeAnnotation ? returnType = node.returnType;
957957 if (node.isSetter) {
@@ -962,11 +962,11 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
962962 }
963963 _checkForTypeAnnotationDeferredClass (returnType);
964964 _returnTypeVerifier.verifyReturnType (returnType);
965- _checkForMainFunction1 (node.name, element );
965+ _checkForMainFunction1 (node.name, fragment );
966966 _checkForMainFunction2 (node);
967967 _checkAugmentations (
968968 augmentKeyword: node.augmentKeyword,
969- element: element ,
969+ element: fragment ,
970970 );
971971 super .visitFunctionDeclaration (node);
972972 },
@@ -1326,7 +1326,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
13261326 ) {
13271327 super .visitPatternVariableDeclarationStatement (node);
13281328 for (var variable in node.declaration.elements) {
1329- _hiddenElements? .declare (variable);
1329+ _hiddenElements? .declare (variable.asElement2 );
13301330 }
13311331 }
13321332
@@ -1642,7 +1642,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
16421642 AstNode grandparent = node.parent! .parent! ;
16431643 if (grandparent is ! TopLevelVariableDeclaration &&
16441644 grandparent is ! FieldDeclaration ) {
1645- VariableElement element = node.declaredElement ! ;
1645+ var element = node.declaredFragment ! .element ;
16461646 // There is no hidden elements if we are outside of a function body,
16471647 // which will happen for variables declared in control flow elements.
16481648 _hiddenElements? .declare (element);
@@ -5194,7 +5194,8 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
51945194 }) {
51955195 if (element != null &&
51965196 _hiddenElements != null &&
5197- _hiddenElements! .contains (element.asElement! )) {
5197+ _hiddenElements! .contains (element)) {
5198+ _hiddenElements! .contains (element);
51985199 errorReporter.reportError (
51995200 DiagnosticFactory ().referencedBeforeDeclaration (
52005201 errorReporter.source,
@@ -6584,7 +6585,7 @@ class HiddenElements {
65846585
65856586 /// A set containing the elements that will be declared in this scope, but are
65866587 /// not yet declared.
6587- final Set <Element > _elements = HashSet < Element >() ;
6588+ final Set <Element2 > _elements = {} ;
65886589
65896590 /// Initialize a newly created set of hidden elements to include all of the
65906591 /// elements defined in the set of [outerElements] and all of the elements
@@ -6600,11 +6601,11 @@ class HiddenElements {
66006601 this .outerElements,
66016602 GuardedPatternImpl guardedPattern,
66026603 ) {
6603- _elements.addAll (guardedPattern.variables.values. map ((e) => e.asElement ! ) );
6604+ _elements.addAll (guardedPattern.variables.values);
66046605 }
66056606
66066607 /// Return `true` if this set of elements contains the given [element] .
6607- bool contains (Element element) {
6608+ bool contains (Element2 element) {
66086609 if (_elements.contains (element)) {
66096610 return true ;
66106611 } else if (outerElements != null ) {
@@ -6615,7 +6616,7 @@ class HiddenElements {
66156616
66166617 /// Record that the given [element] has been declared, so it is no longer
66176618 /// hidden.
6618- void declare (Element element) {
6619+ void declare (Element2 element) {
66196620 _elements.remove (element);
66206621 }
66216622
0 commit comments