mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Local declarations take precedence over exports.
R=ahe@google.com, paulberry@google.com, sigmund@google.com BUG= Review-Url: https://codereview.chromium.org/2894183002 .
This commit is contained in:
parent
011f8c5873
commit
d7be9e36e8
2 changed files with 35 additions and 0 deletions
|
@ -98,6 +98,11 @@ abstract class LibraryBuilder<T extends TypeBuilder, R> extends Builder {
|
|||
Builder existing = map[name];
|
||||
if (existing == member) return false;
|
||||
if (existing != null) {
|
||||
// For each entry mapping key `k` to declaration `d` in `NS` an entry
|
||||
// mapping `k` to `d` is added to the exported namespace of `L` unless a
|
||||
// top-level declaration with the name `k` exists in `L`.
|
||||
if (existing.parent == this) return false;
|
||||
|
||||
Builder result =
|
||||
buildAmbiguousBuilder(name, existing, member, -1, isExport: true);
|
||||
map[name] = result;
|
||||
|
|
|
@ -208,6 +208,36 @@ static field core::int c;
|
|||
}
|
||||
}
|
||||
|
||||
test_compile_export_hideWithLocal() async {
|
||||
writeFile('/test/.packages', 'test:lib/');
|
||||
String aPath = '/test/lib/a.dart';
|
||||
String bPath = '/test/lib/b.dart';
|
||||
String cPath = '/test/lib/c.dart';
|
||||
writeFile(aPath, 'class A {} class B {}');
|
||||
writeFile(bPath, 'export "a.dart"; class B {}');
|
||||
Uri cUri = writeFile(
|
||||
cPath,
|
||||
r'''
|
||||
import 'b.dart';
|
||||
A a;
|
||||
B b;
|
||||
''');
|
||||
|
||||
Program program = await getInitialState(cUri);
|
||||
Library library = _getLibrary(program, cUri);
|
||||
expect(
|
||||
_getLibraryText(library),
|
||||
r'''
|
||||
library;
|
||||
import self as self;
|
||||
import "./a.dart" as a;
|
||||
import "./b.dart" as b;
|
||||
|
||||
static field a::A a;
|
||||
static field b::B b;
|
||||
''');
|
||||
}
|
||||
|
||||
test_compile_typedef() async {
|
||||
writeFile('/test/.packages', 'test:lib/');
|
||||
String aPath = '/test/lib/a.dart';
|
||||
|
|
Loading…
Reference in a new issue