 Chromium Code Reviews
 Chromium Code Reviews Issue 2894183002:
  Local declarations take precedence over exports.  (Closed)
    
  
    Issue 2894183002:
  Local declarations take precedence over exports.  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a | 
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. | 
| 4 | 4 | 
| 5 library fasta.library_builder; | 5 library fasta.library_builder; | 
| 6 | 6 | 
| 7 import '../combinator.dart' show Combinator; | 7 import '../combinator.dart' show Combinator; | 
| 8 | 8 | 
| 9 import '../errors.dart' show InputError, internalError, printUnexpected; | 9 import '../errors.dart' show InputError, internalError, printUnexpected; | 
| 10 | 10 | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 | 91 | 
| 92 /// Returns true if the export scope was modified. | 92 /// Returns true if the export scope was modified. | 
| 93 bool addToExportScope(String name, Builder member) { | 93 bool addToExportScope(String name, Builder member) { | 
| 94 if (name.startsWith("_")) return false; | 94 if (name.startsWith("_")) return false; | 
| 95 if (member is PrefixBuilder) return false; | 95 if (member is PrefixBuilder) return false; | 
| 96 Map<String, Builder> map = | 96 Map<String, Builder> map = | 
| 97 member.isSetter ? exports.setters : exports.local; | 97 member.isSetter ? exports.setters : exports.local; | 
| 98 Builder existing = map[name]; | 98 Builder existing = map[name]; | 
| 99 if (existing == member) return false; | 99 if (existing == member) return false; | 
| 100 if (existing != null) { | 100 if (existing != null) { | 
| 101 // For each entry mapping key `k` to declaration `d` in `NS` an entry | |
| 102 // mapping `k` to `d` is added to the exported namespace of `L` unless a | |
| 103 // top-level declaration with the name `k` exists in `L`. | |
| 104 if (existing.parent == this) return false; | |
| 
ahe
2017/05/22 11:39:45
buildAmbiguousBuilder should take care of this.
 
scheglov
2017/05/22 18:35:24
Ah, I see now.
https://codereview.chromium.org/289
 | |
| 105 | |
| 101 Builder result = | 106 Builder result = | 
| 102 buildAmbiguousBuilder(name, existing, member, -1, isExport: true); | 107 buildAmbiguousBuilder(name, existing, member, -1, isExport: true); | 
| 103 map[name] = result; | 108 map[name] = result; | 
| 104 return result != existing; | 109 return result != existing; | 
| 105 } else { | 110 } else { | 
| 106 map[name] = member; | 111 map[name] = member; | 
| 107 } | 112 } | 
| 108 return true; | 113 return true; | 
| 109 } | 114 } | 
| 110 | 115 | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 /// Don't use for scope lookup. Only use when an element is known to exist | 167 /// Don't use for scope lookup. Only use when an element is known to exist | 
| 163 /// (and not a setter). | 168 /// (and not a setter). | 
| 164 Builder operator [](String name) { | 169 Builder operator [](String name) { | 
| 165 return scope.local[name] ?? internalError("Not found: '$name'."); | 170 return scope.local[name] ?? internalError("Not found: '$name'."); | 
| 166 } | 171 } | 
| 167 | 172 | 
| 168 Builder lookup(String name, int charOffset, Uri fileUri) { | 173 Builder lookup(String name, int charOffset, Uri fileUri) { | 
| 169 return scope.lookup(name, charOffset, fileUri); | 174 return scope.lookup(name, charOffset, fileUri); | 
| 170 } | 175 } | 
| 171 } | 176 } | 
| OLD | NEW |