Version 2.15.0-57.0.dev
Merge commit '7731eea46896f1ac980801677bd0c7365fbdda38' into 'dev'
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/nullability/data/local_boolean.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/nullability/data/local_boolean.dart
index 4c7b408..7fd0b63 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/nullability/data/local_boolean.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/nullability/data/local_boolean.dart
@@ -11,6 +11,16 @@
}
}
+finalLocalBool_untyped(int? x) {
+ final b = x == null;
+ if (!b) {
+ // No promotion due to https://github.com/dart-lang/language/issues/1785
+ x;
+ } else {
+ x;
+ }
+}
+
localBool(int? x) {
bool b = x == null;
if (!b) {
@@ -20,6 +30,16 @@
}
}
+localBool_untyped(int? x) {
+ var b = x == null;
+ if (!b) {
+ // No promotion due to https://github.com/dart-lang/language/issues/1785
+ x;
+ } else {
+ x;
+ }
+}
+
localBool_assigned(int? x, bool b1) {
bool b2 = b1;
b2 = x == null;
@@ -30,6 +50,16 @@
}
}
+localBool_assigned_untyped(int? x, bool b1) {
+ var b2 = b1;
+ b2 = x == null;
+ if (!b2) {
+ /*nonNullable*/ x;
+ } else {
+ x;
+ }
+}
+
localBool_assignedDynamic(int? x, bool b1) {
dynamic b2 = b1;
b2 = x == null;
@@ -49,6 +79,15 @@
}
}
+parameter_assigned_untyped(int? x, b) {
+ b = x == null;
+ if (!b) {
+ /*nonNullable*/ x;
+ } else {
+ x;
+ }
+}
+
parameter_assignedDynamic(int? x, dynamic b) {
b = x == null;
if (!b) {
@@ -69,6 +108,17 @@
}
}
+lateFinalLocalBool_untyped(int? x) {
+ late final b = x == null;
+ if (!b) {
+ // We don't promote based on the initializers of late locals because we
+ // don't know when they execute.
+ x;
+ } else {
+ x;
+ }
+}
+
lateLocalBool(int? x) {
late bool b = x == null;
if (!b) {
@@ -80,6 +130,17 @@
}
}
+lateLocalBool_untyped(int? x) {
+ late var b = x == null;
+ if (!b) {
+ // We don't promote based on the initializers of late locals because we
+ // don't know when they execute.
+ x;
+ } else {
+ x;
+ }
+}
+
lateLocalBool_assignedAndInitialized(int? x, bool b1) {
late bool b2 = b1;
b2 = x == null;
@@ -90,6 +151,16 @@
}
}
+lateLocalBool_assignedAndInitialized_untyped(int? x, bool b1) {
+ late var b2 = b1;
+ b2 = x == null;
+ if (!b2) {
+ /*nonNullable*/ x;
+ } else {
+ x;
+ }
+}
+
lateLocalBool_assignedButNotInitialized(int? x) {
late bool b;
b = x == null;
@@ -100,6 +171,16 @@
}
}
+lateLocalBool_assignedButNotInitialized_untyped(int? x) {
+ late var b;
+ b = x == null;
+ if (!b) {
+ /*nonNullable*/ x;
+ } else {
+ x;
+ }
+}
+
rebaseWithDemotion(int? x, int? y, int? z, int? a) {
x;
y;
diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/initialization.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/initialization.dart
index 35f2d63..799b884 100644
--- a/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/initialization.dart
+++ b/pkg/_fe_analyzer_shared/test/flow_analysis/type_promotion/data/initialization.dart
@@ -13,6 +13,11 @@
x;
}
+localVariable_null() {
+ var x = null;
+ x;
+}
+
localVariable_hasInitializer(num a) {
var x = a;
x = 1;
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 8acd4ac..2ef5319 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -282,13 +282,6 @@
/// always safe to use `.last` to examine the top of the stack.
final List<Expression?> _unfinishedNullShorts = [null];
- /// During resolution we clone annotation ASTs into the element model.
- /// But we should not do this during linking element models, moreover
- /// currently by doing this we will lose elements for parameters of
- /// generic function types.
- /// TODO(scheglov) Stop cloning altogether.
- bool shouldCloneAnnotations = true;
-
late final FunctionReferenceResolver _functionReferenceResolver;
late final InstanceCreationExpressionResolver
diff --git a/pkg/analyzer/lib/src/summary2/ast_resolver.dart b/pkg/analyzer/lib/src/summary2/ast_resolver.dart
index 3f7a44a..96f8760 100644
--- a/pkg/analyzer/lib/src/summary2/ast_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_resolver.dart
@@ -55,7 +55,6 @@
: _featureSet = node.thisOrAncestorOfType<CompilationUnit>()!.featureSet;
void resolveAnnotation(AnnotationImpl node) {
- _resolverVisitor.shouldCloneAnnotations = false;
node.accept(_resolutionVisitor);
node.accept(_scopeResolverVisitor);
_prepareEnclosingDeclarations();
diff --git a/pkg/compiler/test/deferred_loading/data/instantiation2/main.dart b/pkg/compiler/test/deferred_loading/data/instantiation2/main.dart
index bf10d09..509c0ef 100644
--- a/pkg/compiler/test/deferred_loading/data/instantiation2/main.dart
+++ b/pkg/compiler/test/deferred_loading/data/instantiation2/main.dart
@@ -16,7 +16,19 @@
c=(f3, f2)]
*/
-/*two-frag|three-frag.library:
+/*two-frag.library:
+ a_pre_fragments=[
+ p1: {units: [3{c}, 1{b}], usedBy: [p2], needs: []},
+ p2: {units: [2{b, c}], usedBy: [], needs: [p1]}],
+ b_finalized_fragments=[
+ f1: [3{c}, 1{b}],
+ f2: [2{b, c}]],
+ c_steps=[
+ b=(f2, f1),
+ c=(f2, f1)]
+*/
+
+/*three-frag.library:
a_pre_fragments=[
p1: {units: [1{b}], usedBy: [p3], needs: []},
p2: {units: [3{c}], usedBy: [p3], needs: []},
diff --git a/pkg/compiler/test/deferred_loading/data/instantiation5/main.dart b/pkg/compiler/test/deferred_loading/data/instantiation5/main.dart
index 0ba4442..2d808b3 100644
--- a/pkg/compiler/test/deferred_loading/data/instantiation5/main.dart
+++ b/pkg/compiler/test/deferred_loading/data/instantiation5/main.dart
@@ -16,7 +16,19 @@
c=(f3, f2)]
*/
-/*two-frag|three-frag.library:
+/*two-frag.library:
+ a_pre_fragments=[
+ p1: {units: [3{c}, 1{b}], usedBy: [p2], needs: []},
+ p2: {units: [2{b, c}], usedBy: [], needs: [p1]}],
+ b_finalized_fragments=[
+ f1: [3{c}, 1{b}],
+ f2: [2{b, c}]],
+ c_steps=[
+ b=(f2, f1),
+ c=(f2, f1)]
+*/
+
+/*three-frag.library:
a_pre_fragments=[
p1: {units: [1{b}], usedBy: [p3], needs: []},
p2: {units: [3{c}], usedBy: [p3], needs: []},
diff --git a/sdk/lib/_internal/js_runtime/lib/instantiation.dart b/sdk/lib/_internal/js_runtime/lib/instantiation.dart
index da3fcbd..38c403d 100644
--- a/sdk/lib/_internal/js_runtime/lib/instantiation.dart
+++ b/sdk/lib/_internal/js_runtime/lib/instantiation.dart
@@ -22,6 +22,13 @@
}
}
+ bool operator ==(Object other) =>
+ other is Instantiation &&
+ this._genericClosure == other._genericClosure &&
+ this.runtimeType == other.runtimeType;
+
+ int get hashCode => Object.hash(_genericClosure, runtimeType);
+
/// Returns a list of the bound types.
List get _types;
diff --git a/tests/language/nnbd/flow_analysis/local_boolean_implicitly_typed_test.dart b/tests/language/nnbd/flow_analysis/local_boolean_implicitly_typed_test.dart
new file mode 100644
index 0000000..4038020
--- /dev/null
+++ b/tests/language/nnbd/flow_analysis/local_boolean_implicitly_typed_test.dart
@@ -0,0 +1,205 @@
+// Copyright (c) 2021, 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.
+
+// @dart=2.13
+
+import '../../static_type_helper.dart';
+
+// This test checks whether a local boolean variable can be used to perform type
+// promotion, if that variable is implicitly typed.
+//
+// Due to https://github.com/dart-lang/language/issues/1785, initializer
+// expressions on implicitly typed variables are ignored for the purposes of
+// type promotion (however, later assignments to those variables still do
+// influence promotion). To avoid introducing breaking language changes, we
+// intend to preserve this behavior until a specific Dart language version.
+// This test verifies that for code that is not opted in to the newer behavior,
+// the old (buggy) behavior persists.
+
+parameterUnmodified(int? x) {
+ {
+ late final b = x != null;
+ // We wouldn't promote based on the initializers of late locals anyhow,
+ // because we don't know when they execute.
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ late final b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+ {
+ late var b = x != null;
+ // We wouldn't promote based on the initializers of late locals anyhow,
+ // because we don't know when they execute.
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ late var b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+ {
+ final b = x != null;
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ final b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+ {
+ var b = x != null;
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ var b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+}
+
+parameterModifiedLater(int? x, int? y) {
+ x = y;
+ {
+ late final b = x != null;
+ // We wouldn't promote based on the initializers of late locals anyhow,
+ // because we don't know when they execute.
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ late final b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+ {
+ late var b = x != null;
+ // We wouldn't promote based on the initializers of late locals anyhow,
+ // because we don't know when they execute.
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ late var b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+ {
+ final b = x != null;
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ final b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+ {
+ var b = x != null;
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ var b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+}
+
+localVariableInitialized(int? y) {
+ int? x = y;
+ {
+ late final b = x != null;
+ // We wouldn't promote based on the initializers of late locals anyhow,
+ // because we don't know when they execute.
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ late final b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+ {
+ late var b = x != null;
+ // We wouldn't promote based on the initializers of late locals anyhow,
+ // because we don't know when they execute.
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ late var b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+ {
+ final b = x != null;
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ final b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+ {
+ var b = x != null;
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ var b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+}
+
+localVariableModifiedLater(int? y) {
+ int? x;
+ x = y;
+ {
+ late final b = x != null;
+ // We wouldn't promote based on the initializers of late locals anyhow,
+ // because we don't know when they execute.
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ late final b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+ {
+ late var b = x != null;
+ // We wouldn't promote based on the initializers of late locals anyhow,
+ // because we don't know when they execute.
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ late var b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+ {
+ final b = x != null;
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ final b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+ {
+ var b = x != null;
+ if (b) x.expectStaticType<Exactly<int?>>();
+ }
+ {
+ var b;
+ b = x != null;
+ if (b) x.expectStaticType<Exactly<int>>();
+ }
+}
+
+main() {
+ parameterUnmodified(null);
+ parameterUnmodified(0);
+ parameterModifiedLater(null, null);
+ parameterModifiedLater(null, 0);
+ localVariableInitialized(null);
+ localVariableInitialized(0);
+ localVariableModifiedLater(null);
+ localVariableModifiedLater(0);
+}
diff --git a/tools/VERSION b/tools/VERSION
index 39cb874..4109408 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 15
PATCH 0
-PRERELEASE 56
+PRERELEASE 57
PRERELEASE_PATCH 0
\ No newline at end of file