Include null suffix in Cider error verifier diagnostics.

Bug: https://buganizer.corp.google.com/issues/223932544
Change-Id: I860ee8b85a9ff6505df988df2ab50fe025d4a95e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237402
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2022-03-15 16:49:27 +00:00 committed by Commit Bot
parent fb1210590b
commit c4752d7f20
2 changed files with 16 additions and 1 deletions

View file

@ -434,7 +434,11 @@ class LibraryAnalyzer {
ErrorReporter _getErrorReporter(FileState file) {
return _errorReporters.putIfAbsent(file, () {
RecordingErrorListener listener = _getErrorListener(file);
return ErrorReporter(listener, file.source);
return ErrorReporter(
listener,
file.source,
isNonNullableByDefault: _libraryElement.isNonNullableByDefault,
);
});
}

View file

@ -363,6 +363,17 @@ p.dynamic f() {}
''');
}
test_errors_hasNullSuffix() {
assertErrorsInCode(r'''
String f(Map<int, String> a) {
return a[0];
}
''', [
error(CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION, 40, 4,
messageContains: ["'String'", 'String?']),
]);
}
test_findReferences_class() async {
var aPath = convertPath('/workspace/dart/test/lib/a.dart');
newFile2(aPath, r'''