Handle invalid deferred prefix declarations.
R=het@google.com Review URL: https://codereview.chromium.org/2116473002 .
This commit is contained in:
@@ -922,7 +922,12 @@ abstract class Compiler implements LibraryLoaderListener {
|
||||
library.implementation.forEachLocalMember(enqueueAll);
|
||||
library.imports.forEach((ImportElement import) {
|
||||
if (import.isDeferred) {
|
||||
world.addToWorkList(import.prefix.loadLibrary);
|
||||
// `import.prefix` and `loadLibrary` may be `null` when the deferred
|
||||
// import has compile-time errors.
|
||||
GetterElement loadLibrary = import.prefix?.loadLibrary;
|
||||
if (loadLibrary != null) {
|
||||
world.addToWorkList(loadLibrary);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -490,6 +490,43 @@ test() {
|
||||
'b.dart': '''
|
||||
''',
|
||||
}),
|
||||
|
||||
const Test('Deferred without prefix', const {
|
||||
'main.dart': '''
|
||||
import 'a.dart';
|
||||
|
||||
main() {
|
||||
test();
|
||||
}
|
||||
''',
|
||||
}, preserializedSourceFiles: const {
|
||||
'a.dart': '''
|
||||
import 'b.dart' deferred;
|
||||
test() {}
|
||||
''',
|
||||
'b.dart': '''
|
||||
''',
|
||||
}, expectedErrorCount: 1),
|
||||
|
||||
const Test('Deferred with duplicate prefix', const {
|
||||
'main.dart': '''
|
||||
import 'a.dart';
|
||||
|
||||
main() {
|
||||
test();
|
||||
}
|
||||
''',
|
||||
}, preserializedSourceFiles: const {
|
||||
'a.dart': '''
|
||||
import 'b.dart' deferred as pre;
|
||||
import 'c.dart' deferred as pre;
|
||||
test() {}
|
||||
''',
|
||||
'b.dart': '''
|
||||
''',
|
||||
'c.dart': '''
|
||||
''',
|
||||
}, expectedErrorCount: 1),
|
||||
];
|
||||
|
||||
class Test {
|
||||
|
||||
Reference in New Issue
Block a user