Version 2.16.0-61.0.dev
Merge commit '8159c38d6533eb525ba4b86f87db91a36c571b64' into 'dev'
diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart
index 56a23d3..cc621a7 100644
--- a/pkg/analyzer/lib/error/error.dart
+++ b/pkg/analyzer/lib/error/error.dart
@@ -1135,8 +1135,7 @@
return errors.toList();
}
- static List<Object?>? _translateNamedArguments(
- Map<String, dynamic> arguments) {
+ static Null _translateNamedArguments(Map<String, dynamic> arguments) {
// All analyzer errors now use positional arguments, so if this method is
// being called, either no arguments were provided to the
// AnalysisError.withNamedArguments constructor, or the client was
diff --git a/pkg/analyzer/lib/src/analysis_options/analysis_options_provider.dart b/pkg/analyzer/lib/src/analysis_options/analysis_options_provider.dart
index efb2263..4269e6b 100644
--- a/pkg/analyzer/lib/src/analysis_options/analysis_options_provider.dart
+++ b/pkg/analyzer/lib/src/analysis_options/analysis_options_provider.dart
@@ -35,7 +35,7 @@
/// Return the analysis options file from which options should be read, or
/// `null` if there is no analysis options file for code in the given [root].
///
- /// The given [root] directory will be searched first. If no file is found ,
+ /// The given [root] directory will be searched first. If no file is found,
/// then enclosing directories will be searched.
File? getOptionsFile(Folder root) {
for (var current in root.withAncestors) {
@@ -44,6 +44,7 @@
return file;
}
}
+ return null;
}
/// Provide the options found in [file].
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
index d8131da..db6b26d 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
@@ -198,6 +198,7 @@
return file;
}
}
+ return null;
}
/// Return the analysis options that should be used to analyze code in the
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_locator.dart b/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
index 38d0316..245db3d 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_locator.dart
@@ -420,6 +420,7 @@
return file;
}
}
+ return null;
}
/// Return the analysis options file to be used to analyze files in the given
@@ -432,6 +433,7 @@
return file;
}
}
+ return null;
}
/// Return the packages file to be used to analyze files in the given
@@ -444,6 +446,7 @@
return _PackagesFile(current, file);
}
}
+ return null;
}
/// Return a list containing the glob patterns used to exclude files from the
diff --git a/pkg/analyzer/lib/src/dart/element/inheritance_manager3.dart b/pkg/analyzer/lib/src/dart/element/inheritance_manager3.dart
index cf52a23..168cc9a 100644
--- a/pkg/analyzer/lib/src/dart/element/inheritance_manager3.dart
+++ b/pkg/analyzer/lib/src/dart/element/inheritance_manager3.dart
@@ -401,7 +401,9 @@
}
}
- if (getter != null && method != null) {
+ if (getter == null || method == null) {
+ return null;
+ } else {
return GetterMethodConflict(name: name, getter: getter, method: method);
}
}
diff --git a/pkg/analyzer/lib/src/dart/element/type_algebra.dart b/pkg/analyzer/lib/src/dart/element/type_algebra.dart
index 1ffe3d4..5e1389e 100644
--- a/pkg/analyzer/lib/src/dart/element/type_algebra.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_algebra.dart
@@ -567,12 +567,13 @@
InstantiatedTypeAliasElementImpl? _mapAlias(
InstantiatedTypeAliasElement? alias,
) {
- if (alias != null) {
- return InstantiatedTypeAliasElementImpl(
- element: alias.element,
- typeArguments: _mapList(alias.typeArguments),
- );
+ if (alias == null) {
+ return null;
}
+ return InstantiatedTypeAliasElementImpl(
+ element: alias.element,
+ typeArguments: _mapList(alias.typeArguments),
+ );
}
List<DartType> _mapList(List<DartType> types) {
diff --git a/pkg/analyzer/lib/src/dart/micro/library_graph.dart b/pkg/analyzer/lib/src/dart/micro/library_graph.dart
index d18f5bae..80357fb 100644
--- a/pkg/analyzer/lib/src/dart/micro/library_graph.dart
+++ b/pkg/analyzer/lib/src/dart/micro/library_graph.dart
@@ -749,6 +749,7 @@
}
}
}
+ return null;
}
_ContentWithDigest _getContent() {
@@ -879,13 +880,14 @@
}
var libraryUri = unlinked.unit.partOfUri;
- if (libraryUri != null) {
- location._fsState.testView.partsDiscoveredLibraries.add(location.path);
- return _partOfLibrary = location._fileForRelativeUri(
- relativeUri: libraryUri,
- performance: performance,
- );
+ if (libraryUri == null) {
+ return null;
}
+ location._fsState.testView.partsDiscoveredLibraries.add(location.path);
+ return _partOfLibrary = location._fileForRelativeUri(
+ relativeUri: libraryUri,
+ performance: performance,
+ );
}
void _prefetchDirectReferences() {
diff --git a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
index 4fd04f6..e9eec90 100644
--- a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
+++ b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
@@ -653,6 +653,7 @@
return file;
}
}
+ return null;
}
/// Return the analysis options.
diff --git a/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart b/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart
index 36357aa..d7a8fd2 100644
--- a/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart
@@ -129,10 +129,11 @@
}
}
- if (typeParameters != null && rawElement != null) {
- rawElement = _resolver.toLegacyElement(rawElement);
- return ConstructorElementToInfer(typeParameters, rawElement);
+ if (typeParameters == null || rawElement == null) {
+ return null;
}
+ rawElement = _resolver.toLegacyElement(rawElement);
+ return ConstructorElementToInfer(typeParameters, rawElement);
}
FunctionType? inferArgumentTypesForGeneric(AstNode inferenceNode,
diff --git a/pkg/analyzer/lib/src/summary2/bundle_reader.dart b/pkg/analyzer/lib/src/summary2/bundle_reader.dart
index 056696d..e331093 100644
--- a/pkg/analyzer/lib/src/summary2/bundle_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/bundle_reader.dart
@@ -1406,6 +1406,8 @@
List<DartType>? readOptionalTypeList() {
if (_reader.readBool()) {
return _readTypeList();
+ } else {
+ return null;
}
}
@@ -1695,6 +1697,8 @@
ExpressionImpl? _readOptionalExpression() {
if (_reader.readBool()) {
return _readRequiredNode() as ExpressionImpl;
+ } else {
+ return null;
}
}
diff --git a/pkg/analyzer/lib/src/summary2/data_reader.dart b/pkg/analyzer/lib/src/summary2/data_reader.dart
index ff6e1b8..e72e947 100644
--- a/pkg/analyzer/lib/src/summary2/data_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/data_reader.dart
@@ -57,18 +57,24 @@
String? readOptionalStringReference() {
if (readBool()) {
return readStringReference();
+ } else {
+ return null;
}
}
String? readOptionalStringUtf8() {
if (readBool()) {
return readStringUtf8();
+ } else {
+ return null;
}
}
int? readOptionalUInt30() {
if (readBool()) {
return readUInt30();
+ } else {
+ return null;
}
}
diff --git a/pkg/analyzer/lib/src/summary2/element_builder.dart b/pkg/analyzer/lib/src/summary2/element_builder.dart
index 794ef17..8d6599b 100644
--- a/pkg/analyzer/lib/src/summary2/element_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/element_builder.dart
@@ -1014,7 +1014,9 @@
LibraryElement? _selectLibrary(NamespaceDirective node) {
var uri = _selectAbsoluteUri(node);
- if (uri != null) {
+ if (uri == null) {
+ return null;
+ } else {
return _linker.elementFactory.libraryOfUri('$uri');
}
}
@@ -1270,7 +1272,9 @@
Reference? addParameter(String? name, ParameterElementImpl element) {
parameters.add(element);
- if (name != null) {
+ if (name == null) {
+ return null;
+ } else {
return _bindReference('@parameter', name, element);
}
}
diff --git a/pkg/analyzer/lib/src/workspace/bazel.dart b/pkg/analyzer/lib/src/workspace/bazel.dart
index c8d032c..13f0edb 100644
--- a/pkg/analyzer/lib/src/workspace/bazel.dart
+++ b/pkg/analyzer/lib/src/workspace/bazel.dart
@@ -358,6 +358,8 @@
return packageRootedAt(folder);
}
}
+
+ return null;
}
/// In some distributed build environments, BUILD files are not preserved.
@@ -497,10 +499,9 @@
context.join(root, '$symlinkPrefix-genfiles'),
lookForBuildFileSubstitutes: lookForBuildFileSubstitutes);
}
-
- // // Go up the folder.
- // folder = parent;
}
+
+ return null;
}
/// Find the "bin" folder path, by searching for it.
@@ -587,6 +588,8 @@
for (var match in pattern.allMatches(content)) {
return Version.parse('${match.group(1)}.0');
}
+
+ return null;
}
}
diff --git a/pkg/analyzer/lib/src/workspace/bazel_watcher.dart b/pkg/analyzer/lib/src/workspace/bazel_watcher.dart
index b3f09ec..54b96a0 100644
--- a/pkg/analyzer/lib/src/workspace/bazel_watcher.dart
+++ b/pkg/analyzer/lib/src/workspace/bazel_watcher.dart
@@ -123,6 +123,8 @@
// folder, so we use a dummy value here. But this shouldn't really
// matter, since the `symlinkTarget` should detect any modifications.
return _ModifiedInfo(0, 0, symlinkTarget);
+ } else {
+ return null;
}
} on FileSystemException catch (_) {
// File doesn't exist, so return null.
diff --git a/pkg/analyzer/lib/src/workspace/gn.dart b/pkg/analyzer/lib/src/workspace/gn.dart
index e22ce32..8ebed62 100644
--- a/pkg/analyzer/lib/src/workspace/gn.dart
+++ b/pkg/analyzer/lib/src/workspace/gn.dart
@@ -88,6 +88,7 @@
return GnWorkspacePackage(folder.path, this);
}
}
+ return null;
}
/// Find the GN workspace that contains the given [filePath].
@@ -123,6 +124,7 @@
return GnWorkspace._(provider, root, packageMap);
}
}
+ return null;
}
/// For a source at `$root/foo/bar`, the packages files are generated in
diff --git a/pkg/analyzer/lib/src/workspace/package_build.dart b/pkg/analyzer/lib/src/workspace/package_build.dart
index 53a293f..4e06f04 100644
--- a/pkg/analyzer/lib/src/workspace/package_build.dart
+++ b/pkg/analyzer/lib/src/workspace/package_build.dart
@@ -328,13 +328,16 @@
return null;
}
}
+ return null;
}
/// Return the content of the [file], `null` if cannot be read.
static String? _fileContentOrNull(File file) {
try {
return file.readAsStringSync();
- } catch (_) {}
+ } catch (_) {
+ return null;
+ }
}
}
diff --git a/pkg/analyzer/lib/src/workspace/pub.dart b/pkg/analyzer/lib/src/workspace/pub.dart
index e5059d7..1d83253 100644
--- a/pkg/analyzer/lib/src/workspace/pub.dart
+++ b/pkg/analyzer/lib/src/workspace/pub.dart
@@ -74,13 +74,16 @@
return PubWorkspace._(provider, packageMap, root, pubspec);
}
}
+ return null;
}
/// Return the content of the [file], `null` if cannot be read.
static String? _fileContentOrNull(File file) {
try {
return file.readAsStringSync();
- } catch (_) {}
+ } catch (_) {
+ return null;
+ }
}
}
diff --git a/runtime/vm/compiler/jit/jit_call_specializer.cc b/runtime/vm/compiler/jit/jit_call_specializer.cc
index 191e6bb..3afc611 100644
--- a/runtime/vm/compiler/jit/jit_call_specializer.cc
+++ b/runtime/vm/compiler/jit/jit_call_specializer.cc
@@ -162,57 +162,6 @@
}
}
-void JitCallSpecializer::VisitStoreInstanceField(
- StoreInstanceFieldInstr* instr) {
- if (instr->IsUnboxedDartFieldStore()) {
- // Determine if this field should be unboxed based on the usage of getter
- // and setter functions: The heuristic requires that the setter has a
- // usage count of at least 1/kGetterSetterRatio of the getter usage count.
- // This is to avoid unboxing fields where the setter is never or rarely
- // executed.
- const Field& field = instr->slot().field();
- const String& field_name = String::Handle(Z, field.name());
- const Class& owner = Class::Handle(Z, field.Owner());
- const Function& getter =
- Function::Handle(Z, owner.LookupGetterFunction(field_name));
- const Function& setter =
- Function::Handle(Z, owner.LookupSetterFunction(field_name));
- bool unboxed_field = false;
- if (!getter.IsNull() && !setter.IsNull()) {
- if (field.is_double_initialized()) {
- unboxed_field = true;
- } else if ((setter.usage_counter() > 0) &&
- ((FLAG_getter_setter_ratio * setter.usage_counter()) >=
- getter.usage_counter())) {
- unboxed_field = true;
- }
- }
- if (!unboxed_field) {
- if (FLAG_trace_optimization || FLAG_trace_field_guards) {
- THR_Print("Disabling unboxing of %s\n", field.ToCString());
- if (!setter.IsNull()) {
- THR_Print(" setter usage count: %" Pd "\n", setter.usage_counter());
- }
- if (!getter.IsNull()) {
- THR_Print(" getter usage count: %" Pd "\n", getter.usage_counter());
- }
- }
- // We determined it's not beneficial for performance to unbox the
- // field, therefore we mark it as boxed here.
- //
- // Calling `DisableFieldUnboxing` will cause transition the field to
- // boxed and deoptimize dependent code.
- //
- // NOTE: It will also, as a side-effect, change our field clone's
- // `is_unboxing_candidate()` bit. So we assume the compiler has so far
- // not relied on this bit.
- field.DisableFieldUnboxing();
- } else {
- flow_graph()->parsed_function().AddToGuardedFields(&field);
- }
- }
-}
-
// Replace generic context allocation or cloning with a sequence of inlined
// allocation and explicit initializing stores.
// If context_value is not NULL then newly allocated context is a populated
diff --git a/runtime/vm/compiler/jit/jit_call_specializer.h b/runtime/vm/compiler/jit/jit_call_specializer.h
index 8c743ed..ecbee73 100644
--- a/runtime/vm/compiler/jit/jit_call_specializer.h
+++ b/runtime/vm/compiler/jit/jit_call_specializer.h
@@ -27,7 +27,6 @@
// Find a better place for them.
virtual void VisitAllocateContext(AllocateContextInstr* instr);
virtual void VisitCloneContext(CloneContextInstr* instr);
- virtual void VisitStoreInstanceField(StoreInstanceFieldInstr* instr);
private:
virtual bool IsAllowedForInlining(intptr_t deopt_id) const;
diff --git a/runtime/vm/flag_list.h b/runtime/vm/flag_list.h
index 679bf26..edf42f7 100644
--- a/runtime/vm/flag_list.h
+++ b/runtime/vm/flag_list.h
@@ -125,8 +125,6 @@
P(enable_ffi, bool, true, "Disable to make importing dart:ffi an error.") \
P(force_clone_compiler_objects, bool, false, \
"Force cloning of objects needed in compiler (ICData and Field).") \
- P(getter_setter_ratio, int, 13, \
- "Ratio of getter/setter usage used for double field unboxing heuristics") \
P(guess_icdata_cid, bool, true, \
"Artificially create type feedback for arithmetic etc. operations") \
P(huge_method_cutoff_in_tokens, int, 20000, \
diff --git a/tests/lib/js/external_extension_members_test.dart b/tests/lib/js/external_extension_members_test.dart
index 823861c..7f98c7d 100644
--- a/tests/lib/js/external_extension_members_test.dart
+++ b/tests/lib/js/external_extension_members_test.dart
@@ -35,6 +35,7 @@
external set annotatedSetter(_);
external num getField();
+ external void setField10([optionalArgument = 10]);
@JS('toString')
external String extToString();
external dynamic getFirstEl(list);
@@ -72,6 +73,10 @@
return this.field;
}
+ Foo.prototype.setField10 = function(optionalArgument) {
+ this.field = optionalArgument;
+ }
+
Foo.prototype.getFirstEl = function(list) {
return list[0];
}
@@ -128,6 +133,24 @@
expect(foo.otherSumFn(10, 5), equals(15));
});
+ // TODO(41375): Remove if JS interop default value arguments are disallowed.
+ test('optional arguments', () {
+ var foo = Foo(42);
+ expect(foo.field, equals(42));
+
+ foo.setField10();
+ expect(foo.field, equals(10));
+ foo.setField10(6);
+ expect(foo.field, equals(6));
+
+ // Test using tearoffs
+ var setF = foo.setField10;
+ setF();
+ expect(foo.field, equals(10));
+ setF(6);
+ expect(foo.field, equals(6));
+ });
+
test('module class', () {
var bar = Bar(5);
expect(js_util.getProperty(bar, 'fieldAnnotation'), equals(5));
diff --git a/tests/lib_2/js/external_extension_members_test.dart b/tests/lib_2/js/external_extension_members_test.dart
index b1b0cfe..34cc509 100644
--- a/tests/lib_2/js/external_extension_members_test.dart
+++ b/tests/lib_2/js/external_extension_members_test.dart
@@ -32,6 +32,7 @@
external set annotatedSetter(_);
external num getField();
+ external void setField10([optionalArgument = 10]);
@JS('toString')
external String extToString();
external dynamic getFirstEl(list);
@@ -71,6 +72,10 @@
return this.field;
}
+ Foo.prototype.setField10 = function(optionalArgument) {
+ this.field = optionalArgument;
+ }
+
Foo.prototype.getFirstEl = function(list) {
return list[0];
}
@@ -110,6 +115,24 @@
expect(foo.otherSumFn(10, 5), equals(15));
});
+ // TODO(41375): Remove if JS interop default value arguments are disallowed.
+ test('optional arguments', () {
+ var foo = Foo(42);
+ expect(foo.getField(), equals(42));
+
+ foo.setField10();
+ expect(foo.getField(), equals(10));
+ foo.setField10(6);
+ expect(foo.getField(), equals(6));
+
+ // Test using tearoffs
+ var setF = foo.setField10;
+ setF();
+ expect(foo.getField(), equals(10));
+ setF(6);
+ expect(foo.getField(), equals(6));
+ });
+
test('module class', () {
var bar = Bar(5);
expect(js_util.getProperty(bar, 'fieldAnnotation'), equals(5));
diff --git a/tools/VERSION b/tools/VERSION
index 30279d0..7b40e22 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 16
PATCH 0
-PRERELEASE 60
+PRERELEASE 61
PRERELEASE_PATCH 0
\ No newline at end of file