Skip to content

Commit 6fee8e2

Browse files
committed
Version 2.12.0-29.7.beta
* Cherry-pick a0227f5 to beta * Cherry-pick 15c35c2 to beta * Cherry-pick b16c6a8 to beta * Cherry-pick da029c6 to beta * Cherry-pick 83cf6d6 to beta * Cherry-pick 4b3840d to beta
2 parents aceb1a6 + 116d0dc commit 6fee8e2

File tree

49 files changed

+441
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+441
-197
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ Updated the Linter to `0.1.124`, which includes:
9797
```
9898
9999
See [#44072][].
100+
101+
For legacy dependencies without an sdk constraint pub will now assume a
102+
default language version of 2.7.
100103
* The top level `pub` executable has been deprecated. Use `dart pub` instead.
101104
See [dart tool][].
102105
* New command `dart pub add` that adds new dependencies to your `pubspec.yaml`.

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ vars = {
132132
"ply_rev": "604b32590ffad5cbb82e4afef1d305512d06ae93",
133133
"pool_rev": "eedbd5fde84f9a1a8da643b475305a81841da599",
134134
"protobuf_rev": "3746c8fd3f2b0147623a8e3db89c3ff4330de760",
135-
"pub_rev": "b10966c6a8ad7d95c2023b7842fa2697001d2fdf",
135+
"pub_rev": "c00d4b4abf5b4ff265a7ce6282b748551f1b5b1f",
136136
"pub_semver_tag": "v1.4.4",
137137
"resource_rev": "6b79867d0becf5395e5819a75720963b8298e9a7",
138138
"root_certificates_rev": "7e5ec82c99677a2e5b95ce296c4d68b0d3378ed8",

pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8714,13 +8714,12 @@ const Template<
87148714
_names)> templateStrongModeNNBDPackageOptOut = const Template<
87158715
Message Function(List<String> _names)>(
87168716
messageTemplate:
8717-
r"""This project cannot run with sound null safety, because one or more project dependencies do not
8718-
support null safety:
8717+
r"""Cannot run with sound null safety, because the following dependencies
8718+
don't support null safety:
87198719
87208720
#names
87218721
8722-
Run 'pub outdated --mode=null-safety' to determine if versions of your
8723-
dependencies supporting null safety are available.""",
8722+
For solutions, see https://dart.dev/go/unsound-null-safety""",
87248723
withArguments: _withArgumentsStrongModeNNBDPackageOptOut);
87258724

87268725
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
@@ -8737,13 +8736,12 @@ Message _withArgumentsStrongModeNNBDPackageOptOut(List<String> _names) {
87378736
String names = itemizeNames(_names);
87388737
return new Message(codeStrongModeNNBDPackageOptOut,
87398738
message:
8740-
"""This project cannot run with sound null safety, because one or more project dependencies do not
8741-
support null safety:
8739+
"""Cannot run with sound null safety, because the following dependencies
8740+
don't support null safety:
87428741
87438742
${names}
87448743
8745-
Run 'pub outdated --mode=null-safety' to determine if versions of your
8746-
dependencies supporting null safety are available.""",
8744+
For solutions, see https://dart.dev/go/unsound-null-safety""",
87478745
arguments: {'names': _names});
87488746
}
87498747

pkg/analysis_server/lib/src/context_manager.dart

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -887,9 +887,9 @@ class ContextManagerImpl implements ContextManager {
887887
}
888888

889889
void _checkForPackagespecUpdate(String path, ContextInfo info) {
890-
// Check to see if this is the .packages file for this context and if so,
891-
// update the context's source factory.
892-
if (pathContext.basename(path) == PACKAGE_SPEC_NAME) {
890+
// Check to see if this is `.dart_tool/package_config.json` or `.packages`
891+
// file for this context and if so, update the context's source factory.
892+
if (_isPackageConfigJsonFilePath(path) || _isDotPackagesFilePath(path)) {
893893
var driver = info.analysisDriver;
894894
if (driver == null) {
895895
// I suspect that this happens as a result of a race condition: server
@@ -1249,6 +1249,9 @@ class ContextManagerImpl implements ContextManager {
12491249
if (info.hasDependency(path)) {
12501250
_recomputeFolderDisposition(info);
12511251
}
1252+
1253+
_checkForPackagespecUpdate(path, info);
1254+
12521255
// maybe excluded globally
12531256
if (_isExcluded(path) ||
12541257
_isContainedInDotFolder(info.folder.path, path) ||
@@ -1283,7 +1286,7 @@ class ContextManagerImpl implements ContextManager {
12831286
return;
12841287
}
12851288
}
1286-
if (_isPackagespec(path)) {
1289+
if (_isDotPackagesFilePath(path)) {
12871290
// Check for a sibling pubspec.yaml file.
12881291
if (!resourceProvider
12891292
.getFile(pathContext.join(directoryPath, PUBSPEC_NAME))
@@ -1323,7 +1326,7 @@ class ContextManagerImpl implements ContextManager {
13231326
return;
13241327
}
13251328
}
1326-
if (_isPackagespec(path)) {
1329+
if (_isDotPackagesFilePath(path)) {
13271330
// Check for a sibling pubspec.yaml file.
13281331
if (!resourceProvider
13291332
.getFile(pathContext.join(directoryPath, PUBSPEC_NAME))
@@ -1352,7 +1355,6 @@ class ContextManagerImpl implements ContextManager {
13521355
}
13531356
}
13541357
}
1355-
_checkForPackagespecUpdate(path, info);
13561358
_checkForAnalysisOptionsUpdate(path, info);
13571359
_checkForDataFileUpdate(path, info);
13581360
_checkForPubspecUpdate(path, info);
@@ -1388,6 +1390,10 @@ class ContextManagerImpl implements ContextManager {
13881390
/// to specify data-driven fixes.
13891391
bool _isDataFile(String path) => pathContext.basename(path) == dataFileName;
13901392

1393+
bool _isDotPackagesFilePath(String path) {
1394+
return pathContext.basename(path) == PACKAGE_SPEC_NAME;
1395+
}
1396+
13911397
/// Returns `true` if the given [path] is excluded by [excludedPaths].
13921398
bool _isExcluded(String path) => _isExcludedBy(excludedPaths, path);
13931399

@@ -1415,8 +1421,12 @@ class ContextManagerImpl implements ContextManager {
14151421

14161422
bool _isManifest(String path) => pathContext.basename(path) == MANIFEST_NAME;
14171423

1418-
bool _isPackagespec(String path) =>
1419-
pathContext.basename(path) == PACKAGE_SPEC_NAME;
1424+
bool _isPackageConfigJsonFilePath(String path) {
1425+
var components = pathContext.split(path);
1426+
return components.length > 2 &&
1427+
components[components.length - 1] == 'package_config.json' &&
1428+
components[components.length - 2] == '.dart_tool';
1429+
}
14201430

14211431
bool _isPubspec(String path) => pathContext.basename(path) == PUBSPEC_NAME;
14221432

@@ -1477,8 +1487,13 @@ class ContextManagerImpl implements ContextManager {
14771487
var builder = callbacks.createContextBuilder(info.folder);
14781488
var options = builder.getAnalysisOptions(contextRoot,
14791489
contextRoot: driver.contextRoot);
1490+
var packages = builder.createPackageMap(contextRoot);
14801491
var factory = builder.createSourceFactory(contextRoot);
1481-
driver.configure(analysisOptions: options, sourceFactory: factory);
1492+
driver.configure(
1493+
analysisOptions: options,
1494+
packages: packages,
1495+
sourceFactory: factory,
1496+
);
14821497
callbacks.analysisOptionsUpdated(driver);
14831498
}
14841499

pkg/analysis_server/test/context_manager_test.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import 'package:analyzer/src/generated/source.dart';
2323
import 'package:analyzer/src/generated/source_io.dart';
2424
import 'package:analyzer/src/services/lint.dart';
2525
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
26+
import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
2627
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
2728
import 'package:analyzer/src/util/glob.dart';
2829
import 'package:linter/src/rules.dart';
@@ -1490,6 +1491,34 @@ sky_engine:lib/''');
14901491
});
14911492
}
14921493

1494+
Future<void> test_watch_modifyPackageConfigJson() {
1495+
var packageConfigPath = '$projPath/.dart_tool/package_config.json';
1496+
var filePath = convertPath('$projPath/bin/main.dart');
1497+
1498+
resourceProvider.newFile(packageConfigPath, '');
1499+
resourceProvider.newFile(filePath, 'library main;');
1500+
1501+
manager.setRoots(<String>[projPath], <String>[]);
1502+
1503+
var filePaths = callbacks.currentFilePaths;
1504+
expect(filePaths, hasLength(1));
1505+
expect(filePaths, contains(filePath));
1506+
expect(_currentPackageMap, isEmpty);
1507+
1508+
// update .dart_tool/package_config.json
1509+
callbacks.now++;
1510+
resourceProvider.modifyFile(
1511+
packageConfigPath,
1512+
(PackageConfigFileBuilder()..add(name: 'my', rootPath: '../'))
1513+
.toContent(toUriStr: toUriStr),
1514+
);
1515+
1516+
return pumpEventQueue().then((_) {
1517+
// verify new package info
1518+
expect(_currentPackageMap.keys, unorderedEquals(['my']));
1519+
});
1520+
}
1521+
14931522
Future<void> test_watch_modifyPackagespec() {
14941523
var packagesPath = convertPath('$projPath/.packages');
14951524
var filePath = convertPath('$projPath/bin/main.dart');

pkg/analysis_server/test/integration/analysis/get_errors_non_standard_sdk_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AnalysisDomainGetErrorsTest
2828
Directory(path.join(sdkPath, 'lib', 'async')).createSync(recursive: true);
2929
Directory(path.join(sdkPath, 'lib', 'fake')).createSync(recursive: true);
3030

31-
File(path.join(sdkPath, 'version')).writeAsStringSync('2.10.0');
31+
File(path.join(sdkPath, 'version')).writeAsStringSync('2.12.0');
3232

3333
File(path.join(sdkPath, 'lib', 'core', 'core.dart')).writeAsStringSync(r'''
3434
library dart.core;

pkg/analysis_server/test/src/services/correction/fix/add_missing_required_argument_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'package:analysis_server/src/services/correction/fix.dart';
6+
import 'package:analyzer/src/error/codes.dart';
67
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
78
import 'package:test_reflective_loader/test_reflective_loader.dart';
89

@@ -517,7 +518,9 @@ main() {
517518
A a = new A(callback: (int a) { });
518519
print(a);
519520
}
520-
''');
521+
''',
522+
errorFilter: (error) =>
523+
error.errorCode == HintCode.MISSING_REQUIRED_PARAM);
521524
}
522525

523526
Future<void> test_constructor_single_closure_nnbd_into_legacy() async {

pkg/analyzer/lib/error/error.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ const List<ErrorCode> errorCodeValues = [
489489
HintCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE,
490490
HintCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE,
491491
HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION,
492+
HintCode.IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE,
492493
HintCode.INFERENCE_FAILURE_ON_COLLECTION_LITERAL,
493494
HintCode.INFERENCE_FAILURE_ON_FUNCTION_RETURN_TYPE,
494495
HintCode.INFERENCE_FAILURE_ON_INSTANCE_CREATION,

pkg/analyzer/lib/src/dart/error/hint_codes.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,16 @@ class HintCode extends AnalyzerErrorCode {
571571
correction: "Try changing the import to not be deferred, or "
572572
"rename the function in the imported library.");
573573

574+
/**
575+
* https://github.com/dart-lang/sdk/issues/44063
576+
*/
577+
static const HintCode IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE = HintCode(
578+
'IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE',
579+
"The library '{0}' is legacy, and should not be imported into "
580+
"a null safe library.",
581+
correction: "Try migrating the imported library.",
582+
);
583+
574584
/**
575585
* When "strict-inference" is enabled, collection literal types must be
576586
* inferred via the context type, or have type arguments.

pkg/analyzer/lib/src/error/best_practices_verifier.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
504504
_checkForLoadLibraryFunction(node, importElement);
505505
}
506506
_invalidAccessVerifier.verifyImport(node);
507+
_checkForImportOfLegacyLibraryIntoNullSafe(node);
507508
super.visitImportDirective(node);
508509
}
509510

@@ -922,6 +923,24 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
922923
}
923924
}
924925

926+
void _checkForImportOfLegacyLibraryIntoNullSafe(ImportDirective node) {
927+
if (!_isNonNullableByDefault) {
928+
return;
929+
}
930+
931+
var importElement = node.element as ImportElement;
932+
var importedLibrary = importElement.importedLibrary;
933+
if (importedLibrary == null || importedLibrary.isNonNullableByDefault) {
934+
return;
935+
}
936+
937+
_errorReporter.reportErrorForNode(
938+
HintCode.IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE,
939+
node.uri,
940+
[importedLibrary.source.uri],
941+
);
942+
}
943+
925944
/// Check that the namespace exported by [node] does not include any elements
926945
/// annotated with `@internal`.
927946
void _checkForInternalExport(ExportDirective node) {

0 commit comments

Comments
 (0)