Version 2.12.0-77.0.dev
Merge commit '4fc797d6b1540129954528629d2803e1a90f5a78' into 'dev'
diff --git a/DEPS b/DEPS
index 511d449..70e73aa 100644
--- a/DEPS
+++ b/DEPS
@@ -44,7 +44,7 @@
# co19 is a cipd package. Use update.sh in tests/co19[_2] to update these
# hashes. It requires access to the dart-build-access group, which EngProd
# has.
- "co19_rev": "1653a8f5242599b7b8d40b9f1466f717556626d0",
+ "co19_rev": "7a43aa19fb31db657b8b2dac2ed8a8af28889be3",
"co19_2_rev": "e48b3090826cf40b8037648f19d211e8eab1b4b6",
# The internal benchmarks to use. See go/dart-benchmarks-internal
diff --git a/pkg/analysis_server/tool/lsp_spec/README.md b/pkg/analysis_server/tool/lsp_spec/README.md
index 20b35d8..961b2c5 100644
--- a/pkg/analysis_server/tool/lsp_spec/README.md
+++ b/pkg/analysis_server/tool/lsp_spec/README.md
@@ -29,6 +29,7 @@
Client workspace settings are requested with `workspace/configuration` during initialization and re-requested whenever the client notifies the server with `workspace/didChangeConfiguration`. This allows the settings to take effect without restarting the server.
+- `dart.analysisExcludedFolders`: An array of paths (absolute or relative to each workspace folder) that should be excluded from analysis.
- `dart.enableSdkFormatter`: When set to `false`, prevents registration (or unregisters) the SDK formatter. When set to `true` or not supplied, will register/reregister the SDK formatter.
- `dart.lineLength`: The number of characters the formatter should wrap code at. If unspecified, code will be wrapped at `80` characters.
- `dart.completeFunctionCalls`: Completes functions/methods with their required parameters.
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index feb9a23..2aebe9f 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -4392,7 +4392,7 @@
String get identifier {
String identifier = super.identifier;
Element enclosing = enclosingElement;
- if (enclosing is ExecutableElement) {
+ if (enclosing is ExecutableElement || enclosing is VariableElement) {
identifier += "@$nameOffset";
}
return identifier;
diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart
index 5b35e23..7b8015c 100644
--- a/pkg/analyzer/test/src/dart/element/element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/element_test.dart
@@ -36,6 +36,7 @@
defineReflectiveTests(ElementImplTest);
defineReflectiveTests(LibraryElementImplTest);
defineReflectiveTests(TopLevelVariableElementImplTest);
+ defineReflectiveTests(UniqueLocationTest);
});
}
@@ -2289,6 +2290,50 @@
}
@reflectiveTest
+class UniqueLocationTest extends PubPackageResolutionTest {
+ test_ambiguous_closure_in_executable() async {
+ await resolveTestCode('''
+void f() => [() => 0, () => 1];
+''');
+ expect(findNode.functionExpression('() => 0').declaredElement.location,
+ isNot(findNode.functionExpression('() => 1').declaredElement.location));
+ }
+
+ test_ambiguous_closure_in_local_variable() async {
+ await resolveTestCode('''
+void f() {
+ var x = [() => 0, () => 1];
+}
+''');
+ expect(findNode.functionExpression('() => 0').declaredElement.location,
+ isNot(findNode.functionExpression('() => 1').declaredElement.location));
+ }
+
+ test_ambiguous_closure_in_top_level_variable() async {
+ await resolveTestCode('''
+var x = [() => 0, () => 1];
+''');
+ expect(findNode.functionExpression('() => 0').declaredElement.location,
+ isNot(findNode.functionExpression('() => 1').declaredElement.location));
+ }
+
+ test_ambiguous_local_variable_in_executable() async {
+ await resolveTestCode('''
+f() {
+ {
+ int x = 0;
+ }
+ {
+ int x = 1;
+ }
+}
+''');
+ expect(findNode.variableDeclaration('x = 0').declaredElement.location,
+ isNot(findNode.variableDeclaration('x = 1').declaredElement.location));
+ }
+}
+
+@reflectiveTest
class VoidTypeImplTest extends AbstractTypeTest {
/// Reference {code VoidTypeImpl.getInstance()}.
final DartType _voidType = VoidTypeImpl.instance;
diff --git a/pkg/front_end/testcases/nnbd/issue42546.dart.outline.expect b/pkg/front_end/testcases/nnbd/issue42546.dart.outline.expect
index de61651..8826a30 100644
--- a/pkg/front_end/testcases/nnbd/issue42546.dart.outline.expect
+++ b/pkg/front_end/testcases/nnbd/issue42546.dart.outline.expect
@@ -28,19 +28,19 @@
Extra constant evaluation status:
-Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:661:13 -> SymbolConstant(#catchError)
-Evaluated: ListLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:661:13 -> ListConstant(const <Type*>[])
-Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:661:13 -> SymbolConstant(#test)
-Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:698:13 -> SymbolConstant(#whenComplete)
-Evaluated: ListLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:698:13 -> ListConstant(const <Type*>[])
-Evaluated: MapLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:698:13 -> InstanceConstant(const _ImmutableMap<Symbol*, dynamic>{_ImmutableMap._kvPairs: const <dynamic>[]})
-Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:725:13 -> SymbolConstant(#timeout)
-Evaluated: ListLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:725:13 -> ListConstant(const <Type*>[])
-Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:725:13 -> SymbolConstant(#onTimeout)
-Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:622:13 -> SymbolConstant(#then)
-Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:622:13 -> SymbolConstant(#onError)
-Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:709:13 -> SymbolConstant(#asStream)
-Evaluated: ListLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:709:13 -> ListConstant(const <Type*>[])
-Evaluated: ListLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:709:13 -> ListConstant(const <dynamic>[])
-Evaluated: MapLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:709:13 -> InstanceConstant(const _ImmutableMap<Symbol*, dynamic>{_ImmutableMap._kvPairs: const <dynamic>[]})
+Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:664:13 -> SymbolConstant(#catchError)
+Evaluated: ListLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:664:13 -> ListConstant(const <Type*>[])
+Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:664:13 -> SymbolConstant(#test)
+Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:701:13 -> SymbolConstant(#whenComplete)
+Evaluated: ListLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:701:13 -> ListConstant(const <Type*>[])
+Evaluated: MapLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:701:13 -> InstanceConstant(const _ImmutableMap<Symbol*, dynamic>{_ImmutableMap._kvPairs: const <dynamic>[]})
+Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:728:13 -> SymbolConstant(#timeout)
+Evaluated: ListLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:728:13 -> ListConstant(const <Type*>[])
+Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:728:13 -> SymbolConstant(#onTimeout)
+Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:625:13 -> SymbolConstant(#then)
+Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:625:13 -> SymbolConstant(#onError)
+Evaluated: SymbolLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:712:13 -> SymbolConstant(#asStream)
+Evaluated: ListLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:712:13 -> ListConstant(const <Type*>[])
+Evaluated: ListLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:712:13 -> ListConstant(const <dynamic>[])
+Evaluated: MapLiteral @ org-dartlang-sdk:///sdk/lib/async/future.dart:712:13 -> InstanceConstant(const _ImmutableMap<Symbol*, dynamic>{_ImmutableMap._kvPairs: const <dynamic>[]})
Extra constant evaluation: evaluated: 61, effectively constant: 15
diff --git a/pkg/nnbd_migration/test/api_test.dart b/pkg/nnbd_migration/test/api_test.dart
index 34871b0..f36f2b2 100644
--- a/pkg/nnbd_migration/test/api_test.dart
+++ b/pkg/nnbd_migration/test/api_test.dart
@@ -247,6 +247,28 @@
await _checkSingleFileChanges(content, expected);
}
+ Future<void> test_ambiguous_closure_parameter_in_local_variable() async {
+ var content = '''
+Object f<T>(Object Function(T) callback, Object obj) => 0;
+g() {
+ var y = f<Map<String, int>>(
+ (x) => x.keys,
+ f<List<bool>>(
+ (x) => x.last, 0));
+}
+''';
+ var expected = '''
+Object f<T>(Object Function(T) callback, Object obj) => 0;
+g() {
+ var y = f<Map<String, int>>(
+ (x) => x.keys,
+ f<List<bool>>(
+ (x) => x.last, 0));
+}
+''';
+ await _checkSingleFileChanges(content, expected);
+ }
+
Future<void> test_argumentError_checkNotNull_implies_non_null_intent() async {
var content = '''
void f(int i) {
diff --git a/sdk/lib/_internal/vm/lib/growable_array.dart b/sdk/lib/_internal/vm/lib/growable_array.dart
index 62b8196..416e7bd 100644
--- a/sdk/lib/_internal/vm/lib/growable_array.dart
+++ b/sdk/lib/_internal/vm/lib/growable_array.dart
@@ -211,6 +211,9 @@
var cap = _capacity;
// Pregrow if we know iterable.length.
var iterLen = iterable.length;
+ if (iterLen == 0) {
+ return;
+ }
var newLen = len + iterLen;
if (newLen > cap) {
do {
diff --git a/sdk/lib/async/async.dart b/sdk/lib/async/async.dart
index 223af14..43e3c1c 100644
--- a/sdk/lib/async/async.dart
+++ b/sdk/lib/async/async.dart
@@ -101,6 +101,7 @@
checkNotNullable,
EmptyIterator,
IterableElementError,
+ nullFuture,
printToZone,
printToConsole,
Since,
diff --git a/sdk/lib/async/future.dart b/sdk/lib/async/future.dart
index ed9a850..0473bc3 100644
--- a/sdk/lib/async/future.dart
+++ b/sdk/lib/async/future.dart
@@ -147,8 +147,11 @@
*/
abstract class Future<T> {
/// A `Future<Null>` completed with `null`.
- static final _Future<Null> _nullFuture =
- new _Future<Null>.zoneValue(null, _rootZone);
+ ///
+ /// Currently shared with `dart:internal`.
+ /// If that future can be removed, then change this back to
+ /// `_Future<Null>.zoneValue(null, _rootZone);`
+ static final _Future<Null> _nullFuture = nullFuture as _Future<Null>;
/// A `Future<bool>` completed with `false`.
static final _Future<bool> _falseFuture =
diff --git a/sdk/lib/internal/internal.dart b/sdk/lib/internal/internal.dart
index 401777d..858f1f5 100644
--- a/sdk/lib/internal/internal.dart
+++ b/sdk/lib/internal/internal.dart
@@ -119,6 +119,28 @@
return digit1 * 16 + digit2 - (digit2 & 256);
}
+/// A resusable `null`-valued future used by `dart:async`.
+///
+/// **DO NOT USE.**
+///
+/// This future is used in situations where a future is expected,
+/// but no asynchronous computation actually happens,
+/// like cancelling a stream from a controller with no `onCancel` callback.
+/// *Some code depends on recognizing this future in order to react
+/// synchronously.*
+/// It does so to avoid changing event interleaving during the null safety
+/// migration where, for example, the [StreamSubscription.cancel] method
+/// stopped being able to return `null`.
+/// The code that would be broken by such a timing change is fragile,
+/// but we are not able to simply change it.
+/// For better or worse, code depends on the precise timing that our libraries
+/// have so far exhibited.
+///
+/// This future will be removed again if we can ever do so.
+/// Do not use it for anything other than preserving timing
+/// during the null safety migration.
+final Future<Null> nullFuture = Zone.root.run(() => Future<Null>.value(null));
+
/// A default hash function used by the platform in various places.
///
/// This is currently the [Jenkins hash function][1] but using masking to keep
diff --git a/tests/corelib/regress_42011_test.dart b/tests/corelib/regress_42011_test.dart
new file mode 100644
index 0000000..45a9e81
--- /dev/null
+++ b/tests/corelib/regress_42011_test.dart
@@ -0,0 +1,10 @@
+// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for https://github.com/dart-lang/sdk/issues/42011
+main() {
+ var a = [];
+ // No elements are added, so should not get a ConcurrentModificationError.
+ a.addAll(a);
+}
diff --git a/tests/corelib_2/regress_42011_test.dart b/tests/corelib_2/regress_42011_test.dart
new file mode 100644
index 0000000..45a9e81
--- /dev/null
+++ b/tests/corelib_2/regress_42011_test.dart
@@ -0,0 +1,10 @@
+// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for https://github.com/dart-lang/sdk/issues/42011
+main() {
+ var a = [];
+ // No elements are added, so should not get a ConcurrentModificationError.
+ a.addAll(a);
+}
diff --git a/tools/VERSION b/tools/VERSION
index 7de062b..e8cbc46 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 12
PATCH 0
-PRERELEASE 76
+PRERELEASE 77
PRERELEASE_PATCH 0
\ No newline at end of file