Fix for import directive in part while checking for IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE.

Bug: https://github.com/dart-lang/sdk/issues/44280
Change-Id: I6a8ef25deaedc55ef33e83ba7614f23fd56fe788
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2020-11-27 21:29:05 +00:00 committed by commit-bot@chromium.org
parent 6905e30446
commit fe3dd43995
2 changed files with 17 additions and 0 deletions

View file

@ -929,6 +929,10 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
}
var importElement = node.element;
if (importElement == null) {
return;
}
var importedLibrary = importElement.importedLibrary;
if (importedLibrary == null || importedLibrary.isNonNullableByDefault) {
return;

View file

@ -63,6 +63,19 @@ class A {}
import 'a.dart';
void f(A a) {}
''');
}
test_nullSafe_into_nullSafe_part() async {
newFile('$testPackageLibPath/a.dart', content: '');
newFile('$testPackageLibPath/b.dart', content: r'''
part of 'test.dart';
import 'a.dart';
''');
await assertNoErrorsInCode(r'''
part 'b.dart';
''');
}
}