Skip to content

Commit b647e32

Browse files
bwilkersoncommit-bot@chromium.org
authored andcommitted
Fix an assertion to support migration of part files
I'm not sure where the test for this should go. I found it while migrating vector_math.dart. Change-Id: I0c1c5ba91375b2a36540f4c270cef6dc9558a745 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124103 Commit-Queue: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Paul Berry <paulberry@google.com>
1 parent 335b85f commit b647e32

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

pkg/nnbd_migration/lib/src/node_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class NodeBuilder extends GeneralizingAstVisitor<DecoratedType>
156156

157157
@override
158158
DecoratedType visitCompilationUnit(CompilationUnit node) {
159-
_graph.migrating(source);
159+
_graph.migrating(node.declaredElement.library.source);
160160
return super.visitCompilationUnit(node);
161161
}
162162

pkg/nnbd_migration/test/api_test.dart

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ abstract class _ProvisionalApiTestBase extends AbstractContextTest {
3838
Future<void> _checkMultipleFileChanges(
3939
Map<String, String> input, Map<String, String> expectedOutput) async {
4040
for (var path in input.keys) {
41-
newFile(path, content: input[path]);
41+
driver.getFileSync(newFile(path, content: input[path]).path);
4242
}
4343
var listener = new TestMigrationListener();
4444
var migration =
@@ -1847,6 +1847,32 @@ bool f(a) => a is List<int?>;
18471847
await _checkSingleFileChanges(content, expected);
18481848
}
18491849

1850+
test_libraryWithParts() async {
1851+
var root = '/home/test/lib';
1852+
var path1 = convertPath('$root/lib.dart');
1853+
var file1 = '''
1854+
part 'src/foo/part.dart';
1855+
''';
1856+
var expected1 = '''
1857+
part 'src/foo/part.dart';
1858+
''';
1859+
var path2 = convertPath('$root/src/foo/part.dart');
1860+
var file2 = '''
1861+
part of '../../lib.dart';
1862+
class C {
1863+
static void m(C c) {}
1864+
}
1865+
''';
1866+
var expected2 = '''
1867+
part of '../../lib.dart';
1868+
class C {
1869+
static void m(C c) {}
1870+
}
1871+
''';
1872+
await _checkMultipleFileChanges(
1873+
{path2: file2, path1: file1}, {path1: expected1, path2: expected2});
1874+
}
1875+
18501876
test_local_function() async {
18511877
var content = '''
18521878
int f(int i) {

0 commit comments

Comments
 (0)