Version 2.15.0-93.0.dev
Merge commit '6d5de3d19c7dab8b341fb92b56d3d023ef766608' into 'dev'
diff --git a/pkg/analysis_server/README.md b/pkg/analysis_server/README.md
index c6a1813..12af60f 100644
--- a/pkg/analysis_server/README.md
+++ b/pkg/analysis_server/README.md
@@ -21,5 +21,5 @@
Please file feature requests and bugs at the [issue tracker][tracker].
[tracker]: https://github.com/dart-lang/sdk/issues
-[api]: https://htmlpreview.github.io/?https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/doc/api.html
+[api]: https://htmlpreview.github.io/?https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/doc/api.html
[lsp_spec]: https://microsoft.github.io/language-server-protocol/
diff --git a/pkg/analysis_server/doc/tutorial/quick_fix.md b/pkg/analysis_server/doc/tutorial/quick_fix.md
index dcb1bc6..8f1596b 100644
--- a/pkg/analysis_server/doc/tutorial/quick_fix.md
+++ b/pkg/analysis_server/doc/tutorial/quick_fix.md
@@ -319,7 +319,7 @@
We're now ready to create the actual fix. To do that we're going to use the
`ChangeBuilder` passed to the `compute` method. In the example below we'll
introduce a couple of the methods on `ChangeBuilder`, but for more information
-you can read [Creating `SourceChange`s](https://github.com/dart-lang/sdk/blob/master/pkg/analyzer_plugin/doc/tutorial/creating_edits.md).
+you can read [Creating `SourceChange`s](https://github.com/dart-lang/sdk/blob/main/pkg/analyzer_plugin/doc/tutorial/creating_edits.md).
Fields can be declared with either `final`, `const`, `var`, or a type
annotation, and the change that needs to be made depends on how the field was
diff --git a/pkg/analysis_server/lib/src/services/refactoring/move_file.dart b/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
index 6e97072..456dc38 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/move_file.dart
@@ -8,8 +8,10 @@
import 'package:analysis_server/src/services/refactoring/refactoring_internal.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
+import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
import 'package:analyzer_plugin/utilities/range_factory.dart';
@@ -177,8 +179,11 @@
}
bool _isPackageReference(SourceReference reference) {
- var source = reference.element.source!;
- var quotedImportUri = source.contents.data.substring(reference.range.offset,
+ var unitSourceContent = reference.element.unitSourceContent;
+ if (unitSourceContent == null) {
+ return false;
+ }
+ var quotedImportUri = unitSourceContent.substring(reference.range.offset,
reference.range.offset + reference.range.length);
return packagePrefixedStringPattern.hasMatch(quotedImportUri);
}
@@ -215,3 +220,10 @@
}
}
}
+
+extension on Element {
+ String? get unitSourceContent {
+ var unitElement = thisOrAncestorOfType<CompilationUnitElementImpl>();
+ return unitElement?.sourceContent;
+ }
+}
diff --git a/pkg/analysis_server/lib/src/status/diagnostics.dart b/pkg/analysis_server/lib/src/status/diagnostics.dart
index 999bc4d..a6d6d84 100644
--- a/pkg/analysis_server/lib/src/status/diagnostics.dart
+++ b/pkg/analysis_server/lib/src/status/diagnostics.dart
@@ -667,7 +667,7 @@
<a href="/status" ${isNavPage ? ' class="active"' : ''}>Diagnostics</a>
<a href="/feedback" ${isCurrentPage('/feedback') ? ' class="active"' : ''}>Feedback</a>
<a href="https://dart.dev/tools/dart-analyze" target="_blank">Docs</a>
- <a href="https://htmlpreview.github.io/?https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/doc/api.html" target="_blank">Spec</a>
+ <a href="https://htmlpreview.github.io/?https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/doc/api.html" target="_blank">Spec</a>
</nav>
</div>
</header>
diff --git a/pkg/analyzer/README.md b/pkg/analyzer/README.md
index 590e1ac..f574d8c 100644
--- a/pkg/analyzer/README.md
+++ b/pkg/analyzer/README.md
@@ -96,13 +96,13 @@
See the [LICENSE] file.
-[serverapi]: https://htmlpreview.github.io/?https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/doc/api.html
-[dartanalyzer]: https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli#dartanalyzer
+[serverapi]: https://htmlpreview.github.io/?https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/doc/api.html
+[dartanalyzer]: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer_cli#dartanalyzer
[list]: https://groups.google.com/a/dartlang.org/forum/#!forum/analyzer-discuss
[lintrules]: https://dart-lang.github.io/linter/lints/
[glob]: https://pub.dev/packages/glob
-[LICENSE]: https://github.com/dart-lang/sdk/blob/master/pkg/analyzer/LICENSE
+[LICENSE]: https://github.com/dart-lang/sdk/blob/main/pkg/analyzer/LICENSE
[dartfmt]: https://github.com/dart-lang/dart_style
[dartdoc]: https://github.com/dart-lang/dartdoc
-[analysis_sever]: https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server
+[analysis_sever]: https://github.com/dart-lang/sdk/tree/main/pkg/analysis_server
[custom_analysis]: https://dart.dev/guides/language/analysis-options
diff --git a/pkg/analyzer/lib/src/error/correct_override.dart b/pkg/analyzer/lib/src/error/correct_override.dart
index e16cad4..4c821b5 100644
--- a/pkg/analyzer/lib/src/error/correct_override.dart
+++ b/pkg/analyzer/lib/src/error/correct_override.dart
@@ -69,7 +69,8 @@
/// Fill [_thisTypeForSubtype]. If [_thisMember] has covariant formal
/// parameters, replace their types with `Object?` or `Object`.
void _computeThisTypeForSubtype() {
- var parameters = _thisMember.parameters;
+ var type = _thisMember.type;
+ var parameters = type.parameters;
List<ParameterElement>? newParameters;
for (var i = 0; i < parameters.length; i++) {
@@ -84,7 +85,6 @@
}
}
- var type = _thisMember.type;
if (newParameters != null) {
_thisTypeForSubtype = FunctionTypeImpl(
typeFormals: type.typeFormals,
diff --git a/pkg/analyzer/pubspec.yaml b/pkg/analyzer/pubspec.yaml
index 5f6cc0f..17b5859 100644
--- a/pkg/analyzer/pubspec.yaml
+++ b/pkg/analyzer/pubspec.yaml
@@ -1,7 +1,7 @@
name: analyzer
version: 2.2.0
description: This package provides a library that performs static analysis of Dart code.
-homepage: https://github.com/dart-lang/sdk/tree/master/pkg/analyzer
+homepage: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer
environment:
sdk: '>=2.12.0 <3.0.0'
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_implementation_override_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_implementation_override_test.dart
index a9578f5..d8c60f6 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_implementation_override_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_implementation_override_test.dart
@@ -19,6 +19,15 @@
with InvalidImplementationOverrideTestCases {}
mixin InvalidImplementationOverrideTestCases on PubPackageResolutionTest {
+ test_class_generic_method_generic_hasCovariantParameter() async {
+ await assertNoErrorsInCode('''
+class A<T> {
+ void foo<U>(covariant Object a, U b) {}
+}
+class B extends A<int> {}
+''');
+ }
+
test_getter_abstractOverridesConcrete() async {
await assertErrorsInCode('''
class A {
diff --git a/pkg/dartdev/README.md b/pkg/dartdev/README.md
index 6679562..7ad5057 100644
--- a/pkg/dartdev/README.md
+++ b/pkg/dartdev/README.md
@@ -36,6 +36,6 @@
Please file feature requests and bugs in the Dart SDK [issue tracker][tracker]
with label `area-dart-cli`.
-[contributing]: https://github.com/dart-lang/sdk/blob/master/CONTRIBUTING.md
-[design] https://github.com/dart-lang/sdk/blob/master/pkg/dartdev/doc/design.md
+[contributing]: https://github.com/dart-lang/sdk/blob/main/CONTRIBUTING.md
+[design] https://github.com/dart-lang/sdk/blob/main/pkg/dartdev/doc/design.md
[tracker]: https://github.com/dart-lang/sdk/labels/area-dart-cli
diff --git a/pkg/dartdev/lib/src/commands/language_server.dart b/pkg/dartdev/lib/src/commands/language_server.dart
index 2821682..6de3df3 100644
--- a/pkg/dartdev/lib/src/commands/language_server.dart
+++ b/pkg/dartdev/lib/src/commands/language_server.dart
@@ -22,7 +22,7 @@
For more information about the server's capabilities and configuration, see:
- https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server''';
+ https://github.com/dart-lang/sdk/tree/main/pkg/analysis_server''';
LanguageServerCommand({bool verbose = false})
: super(commandName, commandDescription, verbose, hidden: !verbose);
diff --git a/pkg/dartdev/test/smoke/smoke_test.dart b/pkg/dartdev/test/smoke/smoke_test.dart
index 17abdc3..7b1c688 100644
--- a/pkg/dartdev/test/smoke/smoke_test.dart
+++ b/pkg/dartdev/test/smoke/smoke_test.dart
@@ -54,7 +54,7 @@
// This test verifies that an error isn't thrown when a valid experiment
// is passed.
// Experiments are lists here:
- // https://github.com/dart-lang/sdk/blob/master/tools/experimental_features.yaml
+ // https://github.com/dart-lang/sdk/blob/main/tools/experimental_features.yaml
test(
'dart --enable-experiment=variance '
'run smoke.dart', () async {
diff --git a/pkg/meta/README.md b/pkg/meta/README.md
index 9df903f..81fae76 100644
--- a/pkg/meta/README.md
+++ b/pkg/meta/README.md
@@ -30,5 +30,5 @@
See the [LICENSE][license] file.
[issues]: https://github.com/dart-lang/sdk/issues
-[license]: https://github.com/dart-lang/sdk/blob/master/pkg/analyzer/LICENSE
+[license]: https://github.com/dart-lang/sdk/blob/main/pkg/analyzer/LICENSE
[list]: https://groups.google.com/a/dartlang.org/forum/#!forum/analyzer-discuss
diff --git a/pkg/meta/pubspec.yaml b/pkg/meta/pubspec.yaml
index d4d36da..2e3c238 100644
--- a/pkg/meta/pubspec.yaml
+++ b/pkg/meta/pubspec.yaml
@@ -1,7 +1,7 @@
name: meta
# Note, because version `2.0.0` was mistakenly released, the next major version must be `3.x.y`.
version: 1.7.1-dev
-homepage: https://github.com/dart-lang/sdk/tree/master/pkg/meta
+homepage: https://github.com/dart-lang/sdk/tree/main/pkg/meta
description: >-
Annotations that developers can use to express the intentions that otherwise
can't be deduced by statically analyzing the source code. These annotations
diff --git a/pkg/test_runner/lib/src/test_suite.dart b/pkg/test_runner/lib/src/test_suite.dart
index 9a2dd15..f926645 100644
--- a/pkg/test_runner/lib/src/test_suite.dart
+++ b/pkg/test_runner/lib/src/test_suite.dart
@@ -336,6 +336,7 @@
if (expectations.contains(Expectation.crash)) '--suppress-core-dump',
if (configuration.experiments.isNotEmpty)
'--enable-experiment=${configuration.experiments.join(",")}',
+ if (configuration.nnbdMode == NnbdMode.strong) '--sound-null-safety',
...configuration.standardOptions,
...configuration.vmOptions,
test.name
diff --git a/pkg/vm_service/test/cpu_samples_stream_test.dart b/pkg/vm_service/test/cpu_samples_stream_test.dart
index 8ef6ff6..27e0d5d 100644
--- a/pkg/vm_service/test/cpu_samples_stream_test.dart
+++ b/pkg/vm_service/test/cpu_samples_stream_test.dart
@@ -8,7 +8,6 @@
// import 'package:test/test.dart';
import 'package:vm_service/vm_service.dart';
-import 'common/service_test_common.dart';
import 'common/test_helper.dart';
fib(int n) {
diff --git a/runtime/vm/compiler/backend/il_test.cc b/runtime/vm/compiler/backend/il_test.cc
index d373a1a..30502a4 100644
--- a/runtime/vm/compiler/backend/il_test.cc
+++ b/runtime/vm/compiler/backend/il_test.cc
@@ -469,7 +469,10 @@
GrowableArray<intptr_t> expected_abstract_cids;
for (intptr_t cid = kInstanceCid; cid < num_cids; cid++) {
if (!class_table->HasValidClassAt(cid)) continue;
- if (cid == kNullCid && is_nullable) continue;
+ if (cid == kNullCid) continue;
+ if (cid == kNeverCid) continue;
+ if (cid == kDynamicCid && !is_nullable) continue;
+ if (cid == kVoidCid && !is_nullable) continue;
to_check = class_table->At(cid);
// Only add concrete classes.
if (to_check.is_abstract()) {
diff --git a/runtime/vm/compiler/backend/redundancy_elimination.cc b/runtime/vm/compiler/backend/redundancy_elimination.cc
index d85727d..a704ac9 100644
--- a/runtime/vm/compiler/backend/redundancy_elimination.cc
+++ b/runtime/vm/compiler/backend/redundancy_elimination.cc
@@ -3914,7 +3914,7 @@
for (auto phi : *join->phis()) {
phi->mark_dead();
- if (HasNonPhiUse(phi)) {
+ if (HasActualUse(phi)) {
MarkLive(phi);
}
}
@@ -3922,7 +3922,7 @@
}
for (auto info : parameter_info_) {
- if (HasNonPhiUse(info->instr)) {
+ if (HasActualUse(info->instr)) {
MarkLive(info->instr);
}
}
@@ -3962,6 +3962,8 @@
worklist_.Add(param);
}
}
+ } else if (UnboxInstr* unbox = defn->AsUnbox()) {
+ MarkLive(unbox->value()->definition());
}
}
@@ -4003,10 +4005,16 @@
}
// Returns true if definition has a use in an instruction which is not a phi.
- static bool HasNonPhiUse(Definition* defn) {
+ // Skip over Unbox instructions which may be inserted for unused phis.
+ static bool HasActualUse(Definition* defn) {
for (Value* use = defn->input_use_list(); use != nullptr;
use = use->next_use()) {
- if (!use->instruction()->IsPhi()) {
+ Instruction* use_instruction = use->instruction();
+ if (UnboxInstr* unbox = use_instruction->AsUnbox()) {
+ if (HasActualUse(unbox)) {
+ return true;
+ }
+ } else if (!use_instruction->IsPhi()) {
return true;
}
}
diff --git a/runtime/vm/compiler/backend/type_propagator.cc b/runtime/vm/compiler/backend/type_propagator.cc
index 7adbe17..2faa89c 100644
--- a/runtime/vm/compiler/backend/type_propagator.cc
+++ b/runtime/vm/compiler/backend/type_propagator.cc
@@ -1353,6 +1353,30 @@
return *inferred_type;
}
+ // Include special cases of type inference for int operations.
+ // This helps if both type feedback and results of TFA
+ // are not available (e.g. in AOT unit tests).
+ switch (token_kind()) {
+ case Token::kADD:
+ case Token::kSUB:
+ case Token::kMUL:
+ case Token::kMOD:
+ if ((ArgumentCount() == 2) &&
+ ArgumentValueAt(0)->Type()->IsNullableInt() &&
+ ArgumentValueAt(1)->Type()->IsNullableInt()) {
+ return CompileType::Int();
+ }
+ break;
+ case Token::kNEGATE:
+ if ((ArgumentCount() == 1) &&
+ ArgumentValueAt(0)->Type()->IsNullableInt()) {
+ return CompileType::Int();
+ }
+ break;
+ default:
+ break;
+ }
+
const Function& target = interface_target();
if (!target.IsNull()) {
const AbstractType& result_type =
@@ -1507,31 +1531,41 @@
CompileType LoadStaticFieldInstr::ComputeType() const {
const Field& field = this->field();
- bool is_nullable = CompileType::kCanBeNull;
+ ASSERT(field.is_static());
+ bool is_nullable = true;
intptr_t cid = kIllegalCid; // Abstract type is known, calculate cid lazily.
+
AbstractType* abstract_type = &AbstractType::ZoneHandle(field.type());
TraceStrongModeType(this, *abstract_type);
- ASSERT(field.is_static());
+ if (abstract_type->IsStrictlyNonNullable()) {
+ is_nullable = false;
+ }
+
auto& obj = Object::Handle();
const bool is_initialized = IsFieldInitialized(&obj);
if (field.is_final() && is_initialized) {
if (!obj.IsNull()) {
- is_nullable = CompileType::kCannotBeNull;
+ is_nullable = false;
cid = obj.GetClassId();
abstract_type = nullptr; // Cid is known, calculate abstract type lazily.
}
}
+
if ((field.guarded_cid() != kIllegalCid) &&
(field.guarded_cid() != kDynamicCid)) {
cid = field.guarded_cid();
- is_nullable = field.is_nullable();
+ if (!field.is_nullable()) {
+ is_nullable = false;
+ }
abstract_type = nullptr; // Cid is known, calculate abstract type lazily.
}
+
if (field.needs_load_guard()) {
// Should be kept in sync with Slot::Get.
DEBUG_ASSERT(IsolateGroup::Current()->HasAttemptedReload());
return CompileType::Dynamic();
}
+
const bool can_be_sentinel = !calls_initializer() && field.is_late() &&
field.is_final() && !field.has_initializer();
return CompileType(is_nullable, can_be_sentinel, cid, abstract_type);
diff --git a/runtime/vm/compiler/backend/type_propagator_test.cc b/runtime/vm/compiler/backend/type_propagator_test.cc
index 87d459a..cadb164 100644
--- a/runtime/vm/compiler/backend/type_propagator_test.cc
+++ b/runtime/vm/compiler/backend/type_propagator_test.cc
@@ -541,4 +541,51 @@
FlowGraphTypePropagator::Propagate(H.flow_graph()); // Should not crash.
}
+// This test verifies that LoadStaticField for non-nullable field
+// is non-nullable with sound null safety.
+// Regression test for https://github.com/dart-lang/sdk/issues/47119.
+ISOLATE_UNIT_TEST_CASE(TypePropagator_NonNullableLoadStaticField) {
+ if (!IsolateGroup::Current()->null_safety()) {
+ // This test requires sound null safety.
+ return;
+ }
+
+ const char* kScript = R"(
+ const y = 0xDEADBEEF;
+ final int x = 0xFEEDFEED;
+
+ void main(List<String> args) {
+ print(x);
+ print(x + y);
+ }
+ )";
+
+ const auto& root_library = Library::Handle(LoadTestScript(kScript));
+ const auto& function = Function::Handle(GetFunction(root_library, "main"));
+
+ TestPipeline pipeline(function, CompilerPass::kAOT);
+ FlowGraph* flow_graph = pipeline.RunPasses({});
+
+ auto entry = flow_graph->graph_entry()->normal_entry();
+ ILMatcher cursor(flow_graph, entry, /*trace=*/true,
+ ParallelMovesHandling::kSkip);
+
+ Instruction* load = nullptr;
+
+ RELEASE_ASSERT(cursor.TryMatch({
+ kMoveGlob,
+ {kMatchAndMoveLoadStaticField, &load},
+ kMatchAndMovePushArgument,
+ kMatchAndMoveStaticCall,
+ kMatchAndMoveUnboxInt64,
+ kMatchAndMoveBinaryInt64Op,
+ kMatchAndMoveBoxInt64,
+ kMatchAndMovePushArgument,
+ kMatchAndMoveStaticCall,
+ kMatchReturn,
+ }));
+
+ EXPECT_PROPERTY(load->AsLoadStaticField()->Type(), !it.is_nullable());
+}
+
} // namespace dart
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index a0b2dd3..2849c6b 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -6233,7 +6233,7 @@
const char* kScriptChars =
"class ZXHandle {}\n"
"class ChannelReadResult {\n"
- " final List<ZXHandle> handles;\n"
+ " final List<ZXHandle?> handles;\n"
" ChannelReadResult(this.handles);\n"
"}\n"
"void expectListOfString(List<String> _) {}\n"
diff --git a/runtime/vm/type_testing_stubs_test.cc b/runtime/vm/type_testing_stubs_test.cc
index 480c1d0..34e24d9 100644
--- a/runtime/vm/type_testing_stubs_test.cc
+++ b/runtime/vm/type_testing_stubs_test.cc
@@ -194,7 +194,7 @@
}
struct TTSTestCase {
- const Instance& instance;
+ const Object& instance;
const TypeArguments& instantiator_tav;
const TypeArguments& function_tav;
// Whether the result of the test should be a type error.
@@ -217,7 +217,7 @@
bool should_fail = false,
bool should_be_false_negative = false,
bool should_respecialize = false)
- : instance(Instance::Cast(obj)),
+ : instance(obj),
instantiator_tav(i_tav),
function_tav(f_tav),
should_fail(should_fail),
@@ -264,7 +264,8 @@
if (cls.NumTypeArguments() == 0) {
return true;
}
- return instance.GetTypeArguments() == other.instance.GetTypeArguments();
+ return Instance::Cast(instance).GetTypeArguments() ==
+ Instance::Cast(other.instance).GetTypeArguments();
}
bool HasSTCEntry(const SubtypeTestCache& cache,
@@ -293,7 +294,7 @@
const auto& cls = Class::Handle(instance.clazz());
auto& instance_type_arguments = TypeArguments::Handle();
if (cls.NumTypeArguments() > 0) {
- instance_type_arguments = instance.GetTypeArguments();
+ instance_type_arguments = Instance::Cast(instance).GetTypeArguments();
}
return cache.HasCheck(id_smi, dst_type, instance_type_arguments,
instantiator_tav, function_tav,
diff --git a/sdk/lib/core/object.dart b/sdk/lib/core/object.dart
index 8d02d06..4e01a55 100644
--- a/sdk/lib/core/object.dart
+++ b/sdk/lib/core/object.dart
@@ -158,7 +158,7 @@
/// class SomeObject {
/// final Object a, b, c;
/// SomeObject(this.a, this.b, this.c);
- /// bool operator=(Object other) =>
+ /// bool operator ==(Object other) =>
/// other is SomeObject && a == other.a && b == other.b && c == other.c;
/// int get hashCode => Object.hash(a, b, c);
/// }
@@ -482,7 +482,7 @@
/// class SomeObject {
/// final List<String> path;
/// SomeObject(this.path);
- /// bool operator=(Object other) {
+ /// bool operator ==(Object other) {
/// if (other is SomeObject) {
/// if (path.length != other.path.length) return false;
/// for (int i = 0; i < path.length; i++) {
diff --git a/tools/VERSION b/tools/VERSION
index e755c01..b80682d 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 15
PATCH 0
-PRERELEASE 92
+PRERELEASE 93
PRERELEASE_PATCH 0
\ No newline at end of file