Issue 53683. Give a not existing file different API signature, than no an empty file.
Bug: https://github.com/dart-lang/sdk/issues/53683 Change-Id: Ie4ac0eaea773e3a0d0da15ecb1d4645fe27a835c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329660 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
Commit Queue
parent
f36fedd4bf
commit
d0efd60595
@@ -693,6 +693,7 @@ class FileState {
|
||||
return _fsState._logger.run('Create unlinked for $path', () {
|
||||
var unlinkedUnit = serializeAstUnlinked2(
|
||||
unit,
|
||||
exists: exists,
|
||||
isDartCore: uriStr == 'dart:core',
|
||||
);
|
||||
var definedNames = computeDefinedNames(unit);
|
||||
@@ -853,6 +854,7 @@ class FileState {
|
||||
|
||||
static UnlinkedUnit serializeAstUnlinked2(
|
||||
CompilationUnit unit, {
|
||||
required bool exists,
|
||||
required bool isDartCore,
|
||||
}) {
|
||||
UnlinkedLibraryDirective? libraryDirective;
|
||||
@@ -984,8 +986,12 @@ class FileState {
|
||||
}
|
||||
}
|
||||
|
||||
final apiSignature = ApiSignature();
|
||||
apiSignature.addBytes(computeUnlinkedApiSignature(unit));
|
||||
apiSignature.addBool(exists);
|
||||
|
||||
return UnlinkedUnit(
|
||||
apiSignature: Uint8List.fromList(computeUnlinkedApiSignature(unit)),
|
||||
apiSignature: apiSignature.toByteList(),
|
||||
augmentations: augmentations.toFixedList(),
|
||||
exports: exports.toFixedList(),
|
||||
imports: imports.toFixedList(),
|
||||
|
||||
@@ -1082,6 +1082,27 @@ var A = B;
|
||||
}, throwsArgumentError);
|
||||
}
|
||||
|
||||
test_changeFile_notExisting_toEmpty() async {
|
||||
final b = newFile('/test/lib/b.dart', '''
|
||||
// ignore:unused_import
|
||||
import 'a.dart';
|
||||
''');
|
||||
|
||||
driver.addFile(b.path);
|
||||
await waitForIdleWithoutExceptions();
|
||||
|
||||
// Has CompileTimeErrorCode.URI_DOES_NOT_EXIST
|
||||
expect(allResults.withPath(b.path).errors, isNotEmpty);
|
||||
allResults.clear();
|
||||
|
||||
final a = newFile('/test/lib/a.dart', '');
|
||||
driver.changeFile(a.path);
|
||||
await waitForIdleWithoutExceptions();
|
||||
|
||||
// No errors anymore.
|
||||
expect(allResults.withPath(b.path).errors, isEmpty);
|
||||
}
|
||||
|
||||
test_changeFile_notUsed() async {
|
||||
var a = convertPath('/test/lib/a.dart');
|
||||
var b = convertPath('/other/b.dart');
|
||||
|
||||
Reference in New Issue
Block a user