@@ -82,39 +82,6 @@ class LibraryBuilder {
8282 }
8383 }
8484
85- /// Add top-level declaration of the library units to the local scope.
86- void addLocalDeclarations () {
87- for (var linkingUnit in context.units) {
88- for (var node in linkingUnit.unit.declarations) {
89- if (node is ast.ClassDeclaration ) {
90- // Handled in ElementBuilder.
91- } else if (node is ast.ClassTypeAlias ) {
92- // Handled in ElementBuilder.
93- } else if (node is ast.EnumDeclarationImpl ) {
94- // Handled in ElementBuilder.
95- } else if (node is ast.ExtensionDeclarationImpl ) {
96- // Handled in ElementBuilder.
97- } else if (node is ast.FunctionDeclarationImpl ) {
98- // Handled in ElementBuilder.
99- } else if (node is ast.FunctionTypeAlias ) {
100- // Handled in ElementBuilder.
101- } else if (node is ast.GenericTypeAlias ) {
102- // Handled in ElementBuilder.
103- } else if (node is ast.MixinDeclarationImpl ) {
104- // Handled in ElementBuilder.
105- } else if (node is ast.TopLevelVariableDeclaration ) {
106- // Handled in ElementBuilder.
107- } else {
108- throw UnimplementedError ('${node .runtimeType }' );
109- }
110- }
111- }
112- if ('$uri ' == 'dart:core' ) {
113- localScope.declare ('dynamic' , reference.getChild ('dynamic' ));
114- localScope.declare ('Never' , reference.getChild ('Never' ));
115- }
116- }
117-
11885 /// Return `true` if the export scope was modified.
11986 bool addToExportScope (String name, Reference reference) {
12087 if (name.startsWith ('_' )) return false ;
@@ -135,6 +102,8 @@ class LibraryBuilder {
135102 as LibraryElementImpl ;
136103 }
137104
105+ /// Build elements for declarations in the library units, add top-level
106+ /// declarations to the local scope, for combining into export scopes.
138107 void buildElements () {
139108 for (var unitContext in context.units) {
140109 var elementBuilder = ElementBuilder (
@@ -147,6 +116,10 @@ class LibraryBuilder {
147116 }
148117 elementBuilder.buildDeclarationElements (unitContext.unit);
149118 }
119+ if ('$uri ' == 'dart:core' ) {
120+ localScope.declare ('dynamic' , reference.getChild ('dynamic' ));
121+ localScope.declare ('Never' , reference.getChild ('Never' ));
122+ }
150123 }
151124
152125 void buildEnumChildren () {
0 commit comments