Version 3.6.0-149.0.dev
Merge 365985eab729984a63699cfe072d8dd6a9bdba86 into dev
diff --git a/DEPS b/DEPS
index 2e09989..4ac3073 100644
--- a/DEPS
+++ b/DEPS
@@ -145,13 +145,13 @@
# For more details, see https://github.com/dart-lang/sdk/issues/30164.
"dart_style_rev": "f7bd4c42ad6015143f08931540631448048f692d", # disable tools/rev_sdk_deps.dart
"dartdoc_rev": "ce098154b16255bbc9ddfa89e3f6141262645513",
- "ecosystem_rev": "f977423b1d9faa2afb34b805e9f28de0b2a657f1",
+ "ecosystem_rev": "2719d0c077d76da6fb996820393f3cd96bec6591",
"file_rev": "855831c242a17c2dee163828d52710d9043c7c8d",
"fixnum_rev": "6c19e60366ce3d5edfaed51a7c12c98e7977977e",
"flute_rev": "a531c96a8b43d015c6bfbbfe3ab54867b0763b8b",
"glob_rev": "8b05be87f84f74d90dc0c15956f3ff95805322e5",
"html_rev": "0da420ca1e196cda54ede476d0d8d3ecf55375ef",
- "http_rev": "73fce7763a40920c1ce6cb5d2258d8662813ac9d",
+ "http_rev": "76512c4cbf987361421030349fd1946e63e33359",
"http_multi_server_rev": "8348be1bf8fd17881e2643086e68c9d2b28dd9ce",
"http_parser_rev": "ce528cf82f3d26ac761e29b2494a9e0c270d4939",
"intl_rev": "5d65e3808ce40e6282e40881492607df4e35669f",
@@ -165,7 +165,7 @@
"mime_rev": "11fec7d6df509a4efd554051cc27e3bf82df9c96",
"mockito_rev": "eb4d1daa20c105c94ac29689c1975f0850fa18f2",
"native_rev": "b01a3f3ef5e3a219fefb182d4cfc41d2895f32ca", # mosum@ and dacoharkes@ are rolling breaking changes manually while the assets features are in experimental.
- "package_config_rev": "f0b72567d85b827aa0f53991fe8a4a8bf36eb479",
+ "package_config_rev": "76934c2ca25922ec72909bbff7dfbddaf0d02bd9",
"path_rev": "e969f42ed112dd702a9453beb9df6c12ae2d3805",
"pool_rev": "924fb04353cec915d927f9f1aed88e2eda92b98a",
"protobuf_rev": "ccf104dbc36929c0f8708285d5f3a8fae206343e",
@@ -179,18 +179,18 @@
"stack_trace_rev": "090d3d186c085fdb913fe5350c666f8d0bd0f60f",
"stream_channel_rev": "c0c5a978b225d2e02be858e98e24455b7f79b1a0",
"string_scanner_rev": "a40bbbd83f1176bcc0021b336f5841310f91d8cb",
- "sync_http_rev": "ab8377eba79baff3d77e8c75d502efc2b85a9342",
+ "sync_http_rev": "91c0dd5ef9a008f0277aadcfd83036f82e572d09",
"tar_rev": "32ceb55e673141abff4e84b99483fe5eb881c291",
"term_glyph_rev": "38a158f55006cf30942c928171ea601ee5e0308f",
- "test_rev": "9fbbfdbee18a686e3f84a386a01960ea0543ba01",
+ "test_rev": "8be3c948950c2c30e8f9c49d15ef6c04beb47238",
"test_descriptor_rev": "90743bc16bc00526a1b9a64f813614be9b2479d9",
"test_process_rev": "6223572ca16d7585d5f08d9281de6a5734e45150",
"test_reflective_loader_rev": "6e648863b39aab8d0204e769d25805eea9db0ac4",
- "tools_rev": "55dbd6e09042bc1b935c019d8e70b3f41e6b90ea",
+ "tools_rev": "d563c38c7cfb03bbf5d1f9360b49c36ba45b97ef",
"typed_data_rev": "365468a74251c930a463daf5b8f13227e269111a",
"vector_math_rev": "2cfbe2c115a57b368ccbc3c89ebd38a06764d3d1",
"watcher_rev": "0484625589d8512b36a7ad898a6cc6351d24c556",
- "web_rev": "e89fe49d8a86845e49686b4578c56b67bdd7ba49",
+ "web_rev": "4996dc2acd30ff06f7e500ec76fde8a66db82c0c",
"web_socket_channel_rev": "0e1d6e2eb5a0bfd62e45b772ac7107d796176cf6",
"webdev_rev": "75417c09181c97786d9539a662834bed9d2f1e77",
"webdriver_rev": "b181c9e5eca657ea4a12621332f47d9579106fda",
diff --git a/pkg/dev_compiler/test/expression_compiler/runtime_debugger_api_test.dart b/pkg/dev_compiler/test/expression_compiler/runtime_debugger_api_test.dart
index 5017f33..b733ffd 100644
--- a/pkg/dev_compiler/test/expression_compiler/runtime_debugger_api_test.dart
+++ b/pkg/dev_compiler/test/expression_compiler/runtime_debugger_api_test.dart
@@ -120,6 +120,7 @@
var set = <String>{ 'a', 'b', 'c' };
var list = <int>[1, 2, 3];
var map = <String, int>{'a': 1, 'b': 2};
+ var stream = Stream.fromIterable([1, 2, 3]);
var record = (0, 2, name: 'cat');
var object = Object();
@@ -312,6 +313,7 @@
'className': 'Object',
'libraryId': 'dart:core',
'runtimeKind': 'object',
+ 'length': 0,
});
});
@@ -323,6 +325,7 @@
'className': 'BaseClass',
'libraryId': 'package:eval_test/test.dart',
'runtimeKind': 'object',
+ 'length': 9,
});
});
@@ -362,6 +365,18 @@
});
});
+ test('getObjectMetadata (Stream)', () async {
+ await driver.checkRuntimeInFrame(
+ breakpointId: 'BP',
+ expression: 'dart.getObjectMetadata(stream)',
+ expectedResult: {
+ 'className': '_MultiStream<int>',
+ 'libraryId': 'dart:async',
+ 'runtimeKind': 'object',
+ 'length': 2,
+ });
+ });
+
test('getObjectMetadata (Record)', () async {
await driver.checkRuntimeInFrame(
breakpointId: 'BP',
@@ -604,6 +619,7 @@
'className': typeName,
'libraryId': 'dart:_rti',
'runtimeKind': 'object',
+ 'length': 13,
});
});
diff --git a/pkg/linter/test/rules/avoid_shadowing_type_parameters_test.dart b/pkg/linter/test/rules/avoid_shadowing_type_parameters_test.dart
index 55b36ee..dcddc7a 100644
--- a/pkg/linter/test/rules/avoid_shadowing_type_parameters_test.dart
+++ b/pkg/linter/test/rules/avoid_shadowing_type_parameters_test.dart
@@ -2,6 +2,7 @@
// 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.
+import 'package:analyzer/src/error/analyzer_error_code.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../rule_test_support.dart';
@@ -15,9 +16,134 @@
@reflectiveTest
class AvoidShadowingTypeParametersTest extends LintRuleTest {
@override
+ List<AnalyzerErrorCode> get ignoredErrorCodes => [
+ WarningCode.UNUSED_ELEMENT,
+ WarningCode.UNUSED_LOCAL_VARIABLE,
+ ];
+
+ @override
String get lintRule => 'avoid_shadowing_type_parameters';
- test_enum() async {
+ test_enclosingElementsWithoutTypeParameters() async {
+ // Make sure we don't hit any null pointers when none of a function or
+ // method's ancestors have type parameters.
+ await assertNoDiagnostics(r'''
+class C {
+ void f() {
+ void g() {
+ void h<T>() {}
+ }
+ }
+ void i<T>() {}
+}
+''');
+ }
+
+ test_functionType_enclosingElementWithoutTypeParameters() async {
+ await assertNoDiagnostics(r'''
+typedef Fn5 = void Function<T>(T);
+''');
+ }
+
+ test_functionType_noShadowing() async {
+ await assertNoDiagnostics(r'''
+typedef Fn2<T> = void Function<U>(T);
+''');
+ }
+
+ test_functionType_shadowingTypedef() async {
+ await assertDiagnostics(r'''
+typedef Fn1<T> = void Function<T>(T);
+''', [
+ lint(31, 1),
+ ]);
+ }
+
+ @FailingTest(reason: '')
+ test_functionTypedParameter_shadowingFunction() async {
+ // TODO(srawlins): Report lint here.
+ await assertDiagnostics(r'''
+void fn2<T>(void Function<T>()) {}
+''', [
+ lint(26, 1),
+ ]);
+ }
+
+ test_localFunction_noShadowing() async {
+ await assertNoDiagnostics(r'''
+void f<T>() {
+ void g<U>() {}
+}
+''');
+ }
+
+ test_localFunction_shadowingClass() async {
+ await assertDiagnostics(r'''
+class C<T> {
+ void f() {
+ void g<T>() {}
+ }
+}
+''', [
+ lint(37, 1),
+ ]);
+ }
+
+ test_localFunction_shadowingFunction() async {
+ await assertDiagnostics(r'''
+void f<T>() {
+ void g<T>() {}
+}
+''', [
+ lint(23, 1),
+ ]);
+ }
+
+ test_localFunction_shadowingLocalFunction() async {
+ await assertDiagnostics(r'''
+class C {
+ void f() {
+ void g<T>() {
+ void h<T>() {}
+ }
+ }
+}
+''', [
+ lint(54, 1),
+ ]);
+ }
+
+ test_localFunction_shadowingMethod() async {
+ await assertDiagnostics(r'''
+class C<T> {
+ void fn1<U>() {
+ void fn3<U>() {}
+ }
+}
+''', [
+ lint(44, 1),
+ ]);
+ }
+
+ test_method_noShadowing() async {
+ await assertNoDiagnostics(r'''
+class C<T> {
+ void f<U>() {}
+}
+''');
+ }
+
+ test_method_shadowingClass() async {
+ await assertDiagnostics(r'''
+class C<T> {
+ void f<T>() {}
+}
+''', [
+ lint(22, 1),
+ ]);
+ }
+
+ test_method_shadowingEnum() async {
await assertDiagnostics(r'''
enum E<T> {
a, b, c;
@@ -28,7 +154,17 @@
]);
}
- test_extensionType() async {
+ test_method_shadowingExtension() async {
+ await assertDiagnostics(r'''
+extension E<T> on List<T> {
+ void f<T>() {}
+}
+''', [
+ lint(37, 1),
+ ]);
+ }
+
+ test_method_shadowingExtensionType() async {
await assertDiagnostics(r'''
extension type E<T>(int i) {
void m<T>() {}
@@ -38,6 +174,24 @@
]);
}
+ test_method_shadowingMixin() async {
+ await assertDiagnostics(r'''
+mixin M<T> {
+ void f<T>() {}
+}
+''', [
+ lint(22, 1),
+ ]);
+ }
+
+ test_staticMethod_shadowingClass() async {
+ await assertNoDiagnostics(r'''
+class A<T> {
+ static void f<T>() {}
+}
+''');
+ }
+
test_wildcards() async {
await assertNoDiagnostics(r'''
class A<_> {
diff --git a/pkg/linter/test/rules/avoid_type_to_string_test.dart b/pkg/linter/test/rules/avoid_type_to_string_test.dart
index fc481f7b..4700387 100644
--- a/pkg/linter/test/rules/avoid_type_to_string_test.dart
+++ b/pkg/linter/test/rules/avoid_type_to_string_test.dart
@@ -17,6 +17,18 @@
@override
String get lintRule => 'avoid_type_to_string';
+ test_extensionOnType_implicitThis() async {
+ await assertDiagnostics(r'''
+extension E on Type {
+ void f() {
+ toString();
+ }
+}
+''', [
+ lint(39, 8),
+ ]);
+ }
+
test_extensionType_implicitThis() async {
await assertDiagnostics(r'''
extension type E(int i) {
@@ -40,4 +52,142 @@
lint(55, 8),
]);
}
+
+ test_mixinOnType_explicitThis() async {
+ await assertDiagnostics(r'''
+mixin M on Type {
+ late var x = this.toString();
+}
+''', [
+ lint(38, 8),
+ ]);
+ }
+
+ test_mixinOnType_implicitThis() async {
+ await assertDiagnostics(r'''
+mixin M on Type {
+ late var x = toString();
+}
+''', [
+ lint(33, 8),
+ ]);
+ }
+
+ test_runtimeType() async {
+ await assertDiagnostics(r'''
+var x = 7.runtimeType.toString();
+''', [
+ lint(22, 8),
+ ]);
+ }
+
+ test_type_tearoff() async {
+ await assertDiagnostics(r'''
+void f() {
+ foo(7.runtimeType.toString);
+}
+void foo(String Function() p) {}
+''', [
+ lint(31, 8),
+ ]);
+ }
+
+ test_typeExtendingType_withToStringOverride() async {
+ await assertNoDiagnostics(r'''
+mixin M {
+ @override
+ String toString() => '';
+}
+class Type2 extends Type with M {
+ String get x => toString();
+}
+''');
+ }
+
+ test_typeThatExtendsType() async {
+ await assertDiagnostics(r'''
+var x = Type2().toString();
+class Type2 extends Type {}
+''', [
+ lint(16, 8),
+ ]);
+ }
+
+ test_typeThatExtendsType_explicitThis() async {
+ await assertDiagnostics(r'''
+class Type2 extends Type {
+ late var x = this.toString();
+}
+''', [
+ lint(47, 8),
+ ]);
+ }
+
+ test_typeThatExtendsType_implicitThis() async {
+ await assertDiagnostics(r'''
+class Type2 extends Type {
+ late var x = toString();
+}
+''', [
+ lint(42, 8),
+ ]);
+ }
+
+ test_typeThatExtendsType_super() async {
+ await assertDiagnostics(r'''
+class Type2 extends Type {
+ late var x = super.toString();
+}
+''', [
+ lint(48, 8),
+ ]);
+ }
+
+ test_typeThatExtendsType_tearoff() async {
+ await assertDiagnostics(r'''
+class Type2 extends Type {}
+void f(Type2 t) {
+ foo(t.toString);
+}
+void foo(String Function() p) {}
+''', [
+ lint(54, 8),
+ ]);
+ }
+
+ test_typeThatExtendsType_tearoff_explicitThis() async {
+ await assertDiagnostics(r'''
+class Type2 extends Type {
+ void f() {
+ foo(this.toString);
+ }
+ void foo(String Function() p) {}
+}
+''', [
+ lint(53, 8),
+ ]);
+ }
+
+ test_typeThatExtendsType_tearoff_implicitThis() async {
+ await assertDiagnostics(r'''
+class Type2 extends Type {
+ void f() {
+ foo(toString);
+ }
+ void foo(String Function() p) {}
+}
+''', [
+ lint(48, 8),
+ ]);
+ }
+
+ test_typeThatExtendsTypeThatExtendsType() async {
+ await assertDiagnostics(r'''
+var x = Type3().toString();
+class Type2 extends Type {}
+class Type3 extends Type2 {}
+''', [
+ lint(16, 8),
+ ]);
+ }
}
diff --git a/pkg/linter/test/rules/avoid_types_as_parameter_names_test.dart b/pkg/linter/test/rules/avoid_types_as_parameter_names_test.dart
index 2a602dd..82ec82b 100644
--- a/pkg/linter/test/rules/avoid_types_as_parameter_names_test.dart
+++ b/pkg/linter/test/rules/avoid_types_as_parameter_names_test.dart
@@ -17,6 +17,18 @@
@override
String get lintRule => 'avoid_types_as_parameter_names';
+ test_catchClauseParameter() async {
+ await assertDiagnostics(r'''
+class C {}
+
+void f() {
+ try {} catch (C) {}
+}
+''', [
+ lint(39, 1),
+ ]);
+ }
+
test_extensionType() async {
await assertDiagnostics(r'''
extension type E(int i) { }
@@ -27,6 +39,100 @@
]);
}
+ test_factoryParameter_shadowingTypeParameter() async {
+ await assertDiagnostics(r'''
+class C<X> {
+ factory C(X) => C.name();
+ C.name();
+}
+''', [
+ lint(25, 1),
+ ]);
+ }
+
+ test_fieldFormalParameter_missingType() async {
+ await assertNoDiagnostics(r'''
+class C {
+ final int num;
+ C(this.num);
+}
+''');
+ }
+
+ test_functionTypedParameter_missingName() async {
+ await assertDiagnostics(r'''
+void f(void g(int)) {}
+''', [
+ lint(14, 3),
+ ]);
+ }
+
+ test_functionTypedParameter_missingType_named() async {
+ await assertDiagnostics(r'''
+void f(void g({int})) {}
+''', [
+ lint(15, 3),
+ ]);
+ }
+
+ test_functionTypedParameter_missingType_optionalPositional() async {
+ await assertDiagnostics(r'''
+void f(void g([int])) {}
+''', [
+ lint(15, 3),
+ ]);
+ }
+
+ test_functionTypedParameter_noShadowing() async {
+ await assertNoDiagnostics(r'''
+void f(void g(int a)) {}
+''');
+ }
+
+ test_functionTypeParameter_missingName() async {
+ await assertNoDiagnostics(r'''
+void f(int Function(int) g) {}
+''');
+ }
+
+ test_functionTypeParameter_withParameter_noShadowing() async {
+ await assertNoDiagnostics(r'''
+class C<X> {
+ void m(void Function(X) g) {}
+}
+''');
+ }
+
+ test_functionTypeParameter_withParameter_shadowingTypeParameter() async {
+ await assertNoDiagnostics(r'''
+void f(int Function<T>(T) g) {}
+''');
+ }
+
+ test_parameter_shadowingTypeParameter() async {
+ await assertDiagnostics(r'''
+void f<X>(X) {}
+''', [
+ lint(10, 1),
+ ]);
+ }
+
+ test_parameterIsFunctionName() async {
+ await assertNoDiagnostics(r'''
+void f(g) {}
+void g() {}
+''');
+ }
+
+ test_parameterIsTypedefName() async {
+ await assertDiagnostics(r'''
+void f(T) {}
+typedef T = int;
+''', [
+ lint(7, 1),
+ ]);
+ }
+
test_super() async {
await assertDiagnostics(r'''
class A {
@@ -41,6 +147,48 @@
]);
}
+ test_typedefParameter_legacy_missingType() async {
+ await assertDiagnostics(r'''
+typedef void T(int);
+''', [
+ lint(15, 3),
+ ]);
+ }
+
+ test_typedefParameter_legacy_missingType_named() async {
+ await assertDiagnostics(r'''
+typedef void T({int});
+''', [
+ lint(16, 3),
+ ]);
+ }
+
+ test_typedefParameter_legacy_missingType_optionalPositional() async {
+ await assertDiagnostics(r'''
+typedef void f([int]);
+''', [
+ lint(16, 3),
+ ]);
+ }
+
+ test_typedefParameter_legacy_noShadowing() async {
+ await assertNoDiagnostics(r'''
+typedef void T(int a);
+''');
+ }
+
+ test_typedefParameter_legacy_undefinedName() async {
+ await assertNoDiagnostics(r'''
+typedef void f(Undefined);
+''');
+ }
+
+ test_typedefParameter_missingName() async {
+ await assertNoDiagnostics(r'''
+typedef T = int Function(int);
+''');
+ }
+
test_typeParameter_wildcard() async {
await assertDiagnostics(r'''
class C<_> {
diff --git a/pkg/linter/test_data/rules/avoid_shadowing_type_parameters.dart b/pkg/linter/test_data/rules/avoid_shadowing_type_parameters.dart
deleted file mode 100644
index 46f3cbab..0000000
--- a/pkg/linter/test_data/rules/avoid_shadowing_type_parameters.dart
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2018, 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.
-
-void fn1<T>() {
- void fn2<T>() {} // LINT
- void fn3<U>() {} // OK
- void fn4() {} // OK
-}
-
-// TODO(srawlins): Lint on this stuff as well when the analyzer/language(?)
-// support it. Right now analyzer spits out a compile time error: "Analysis of
-// generic function typed parameters is not yet supported."
-// void fn2<T>(void Function<T>()) {} // NOT OK
-
-class A<T> {
- static void fn1<T>() {} // OK
-}
-
-extension Ext<T> on A<T> {
- void fn2<T>() {} // LINT
- void fn3<U>() {} // OK
- void fn4<V>() {} // OK
-}
-
-mixin M<T> {
- void fn1<T>() {} // LINT
- void fn2<U>() {} // OK
- void fn3<V>() {} // OK
-}
-
-class B<T> {
- void fn1<T>() {} // LINT
- void fn2<U>() {} // OK
- void fn3<V>() {} // OK
-}
-
-class C<T> {
- void fn1<U>() {
- void fn2<T>() {} // LINT
- void fn3<U>() {} // LINT
- void fn4<V>() {} // OK
- void fn5() {} // OK
- }
-}
-
-class D<T> {
- void fn1<U>() {
- void fn2<V>() {
- void fn3<T>() {} // LINT
- void fn4<U>() {} // LINT
- void fn5<V>() {} // LINT
- void fn6<W>() {} // OK
- void fn7() {} // OK
- }
- }
-}
-
-// Make sure we don't hit any null pointers when none of a function or method's
-// ancestors have type parameters.
-class E {
- void fn1() {
- void fn2() {
- void fn3<T>() {} // OK
- }
- }
-
- void fn4<T>() {} // OK
-}
-
-typedef Fn1<T> = void Function<T>(T); // LINT
-typedef Fn2<T> = void Function<U>(T); // OK
-typedef Fn3<T> = void Function<U>(U); // OK
-typedef Fn4<T> = void Function(T); // OK
-typedef Fn5 = void Function<T>(T); // OK
-
diff --git a/pkg/linter/test_data/rules/avoid_type_to_string.dart b/pkg/linter/test_data/rules/avoid_type_to_string.dart
deleted file mode 100644
index 9dbc9f2..0000000
--- a/pkg/linter/test_data/rules/avoid_type_to_string.dart
+++ /dev/null
@@ -1,151 +0,0 @@
-// 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.
-
-// SHARED
-
-class A {
- String toString() => '';
-}
-
-String takesFunction(Function f) => '';
-
-class TypeChildWithOverride extends Type {
- @override
- String toString() => '';
-}
-
-class TypeGrandChildWithOverride extends TypeChildWithOverride {}
-
-class TypeChildNoOverride extends Type {}
-
-class TypeGrandChildNoOverride extends TypeChildNoOverride {}
-
-mixin ToStringMixin {
- String toString() => '';
-}
-
-// BAD
-
-class Bad {
- void doBad(Function f) {
- A().runtimeType.toString(); // LINT
- TypeChildNoOverride().toString(); // LINT
- TypeGrandChildNoOverride().toString(); // LINT
- }
-}
-
-class BadWithType extends Type {
- Function passedFunction = (){};
-
- BadWithType(Function func) : this.withFunc(func);
- BadWithType.withoutFunc() {}
- BadWithType.withFunc(this.passedFunction) {}
- BadWithType.withSelf(BadWithType badWithType)
- : this.withFunc(badWithType.toString); // LINT
-
- void doBad() {
- toString(); // LINT
- this.toString(); // LINT
-
- print('${toString()}'); // LINT
- print('${this.toString()}'); // LINT
- print('${takesFunction(toString)}'); // LINT
- print('${takesFunction(this.toString)}'); // LINT
-
- takesFunction(toString); // LINT
- takesFunction(this.toString); // LINT
- takesFunction(BadWithType.withoutFunc().toString); // LINT
- Bad().doBad(toString); // LINT
- Bad().doBad(this.toString); // LINT
- Bad().doBad(BadWithType.withoutFunc().toString); // LINT
-
- BadWithType(toString); // LINT
- BadWithType.withFunc(this.toString); // LINT
-
- ((Function internal) => internal())(toString); // LINT
- }
-}
-
-class BadWithTypeChild extends BadWithType {
- BadWithTypeChild(BadWithType badWithType)
- : super(badWithType.toString); // LINT
- BadWithTypeChild.redirect(BadWithType badWithType)
- : super.withFunc(badWithType.toString); // LINT
-}
-
-mixin callToStringOnBadWithType on BadWithType {
- void mixedBad() {
- toString(); // LINT
- this.toString(); // LINT
- }
-}
-
-extension ExtensionOnBadWithType on BadWithType {
- void extendedBad() {
- toString(); // LINT
- this.toString(); // LINT
- }
-}
-
-// GOOD
-
-class Good {
- void doGood() {
- toString(); // OK
- A().toString(); // OK
- TypeChildWithOverride().toString(); // OK
- TypeGrandChildWithOverride().toString(); // OK
-
- final refToString = toString;
- refToString(); // OK?
- takesFunction(refToString); // OK
- }
-}
-
-class GoodWithType extends Type {
- Function passedFunction;
-
- GoodWithType.withFunc(this.passedFunction) {}
- GoodWithType.withSelf(GoodWithTypeAndMixin goodWithTypeAndMixin)
- : this.withFunc(goodWithTypeAndMixin.toString); // OK
- GoodWithType.withOther(Good good) : this.withFunc(good.toString); // OK
-
- void good() {
- String toString() => '';
- toString(); // OK
- }
-}
-
-class GoodWithTypeAndMixin extends Type with ToStringMixin {
- void doGood() {
- toString(); // OK
- this.toString(); // OK
-
- takesFunction(toString); // OK
- takesFunction(this.toString); // OK
- takesFunction(GoodWithTypeAndMixin().toString); // OK
- }
-}
-
-mixin CallToStringOnGoodWithType on GoodWithTypeAndMixin {
- void mixedGood() {
- toString(); // OK
- this.toString(); // OK
- }
-}
-
-extension ExtensionOnGoodWithTypeAndMixin on GoodWithTypeAndMixin {
- void extendedGood() {
- toString(); // OK
- this.toString(); // OK
- }
-}
-
-extension on int Function(int) {
- // ignore: unused_element
- void extendedGood() {
- toString(); // OK
- this.toString(); // OK
- }
-}
diff --git a/pkg/linter/test_data/rules/avoid_types_as_parameter_names.dart b/pkg/linter/test_data/rules/avoid_types_as_parameter_names.dart
deleted file mode 100644
index 3a89bec..0000000
--- a/pkg/linter/test_data/rules/avoid_types_as_parameter_names.dart
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2018, 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.
-
-class SomeType {}
-
-void f() {
- try {
- // ignore: avoid_catches_without_on_clauses
- } catch(SomeType) { //LINT
- // ...
- }
-}
-
-typedef void f1(); // OK
-typedef void f2(int a); // OK
-typedef void f3(int); // LINT
-typedef void f4(
- num a, // OK
- {
- int, // LINT
-});
-typedef void f5(
- double a, // OK
- [
- bool, // LINT
-]);
-typedef f6 = int Function(int); // OK
-typedef void f7(Undefined); // OK
-
-m1(f()) => null; // OK
-m2(f(int a)) => null; // OK
-m3(f(int)) => null; // LINT
-m4(f(num a, {int})) => null; // LINT
-m5(f(double a, [bool])) => null; // LINT
-m6(int Function(int) f)=> null; // OK
-m7(f(Undefined)) => null; // OK
-m8(f6) => null; // LINT
-m9(f7) => null; // LINT
-m10(m1) => null; // OK
-
-/// Naming the field `num` is significant - should be the name of a class.
-class FieldFormalParameter {
- final int num;
- FieldFormalParameter(this.num); // OK
-}
-
-void m11<X>(X) {} // LINT
-
-void m12(int Function<T>(T) g) {} // OK
-
-class C<X> {
- C.name();
- factory C(X) => C.name(); // LINT
- void m(void Function(X) h) {} // OK
-}
diff --git a/runtime/vm/heap/page.cc b/runtime/vm/heap/page.cc
index fda047e..9044d17 100644
--- a/runtime/vm/heap/page.cc
+++ b/runtime/vm/heap/page.cc
@@ -23,7 +23,7 @@
// This cache needs to be at least as big as FLAG_new_gen_semi_max_size or
// munmap will noticeably impact performance.
-static constexpr intptr_t kPageCacheCapacity = 8 * kWordSize;
+static constexpr intptr_t kPageCacheCapacity = 128 * kWordSize;
static Mutex* page_cache_mutex = nullptr;
static VirtualMemory* page_cache[kPageCacheCapacity] = {nullptr};
static intptr_t page_cache_size = 0;
@@ -150,10 +150,23 @@
if (CanUseCache(flags_)) {
ASSERT(memory->size() == kPageSize);
+
+ // Allow caching up to one new-space worth of pages to avoid the cost unmap
+ // when freeing from-space. Using ThresholdInWords both accounts for
+ // new-space scaling with the number of mutators, and prevents the cache
+ // from staying big after new-space shrinks.
+ intptr_t limit = 0;
+ IsolateGroup* group = IsolateGroup::Current();
+ if ((group != nullptr) && ((flags_ & kNew) != 0)) {
+ limit = group->heap()->new_space()->ThresholdInWords() / kPageSizeInWords;
+ }
+ limit = Utils::Maximum(limit, FLAG_new_gen_semi_max_size * MB / kPageSize);
+ limit = Utils::Minimum(limit, kPageCacheCapacity);
+
MutexLocker ml(page_cache_mutex);
ASSERT(page_cache_size >= 0);
ASSERT(page_cache_size <= kPageCacheCapacity);
- if (page_cache_size < kPageCacheCapacity) {
+ if (page_cache_size < limit) {
intptr_t size = memory->size();
#if defined(DEBUG)
if ((flags_ & kNew) != 0) {
diff --git a/runtime/vm/heap/scavenger.cc b/runtime/vm/heap/scavenger.cc
index 15ac5c7..3f58a38 100644
--- a/runtime/vm/heap/scavenger.cc
+++ b/runtime/vm/heap/scavenger.cc
@@ -850,9 +850,9 @@
intptr_t Scavenger::NewSizeInWords(intptr_t old_size_in_words,
GCReason reason) const {
+ intptr_t num_mutators = heap_->isolate_group()->MutatorCount();
bool grow = false;
- if (2 * heap_->isolate_group()->MutatorCount() >
- (old_size_in_words / kPageSizeInWords)) {
+ if (2 * num_mutators > (old_size_in_words / kPageSizeInWords)) {
// Not enough TLABs to give two to each mutator.
grow = true;
}
@@ -873,11 +873,18 @@
}
}
- if (grow) {
- return Utils::Minimum(max_semi_capacity_in_words_,
- old_size_in_words * FLAG_new_gen_growth_factor);
- }
- return old_size_in_words;
+ // Let new-space scale up with the number of active mutators.
+ intptr_t limit = max_semi_capacity_in_words_ *
+ Utils::Minimum(num_mutators, static_cast<intptr_t>(8));
+ // But only when old-space is big enough.
+ limit = Utils::Minimum(limit, heap_->old_space()->UsedInWords() / 8);
+ // Preserve old behavior when heap size is small.
+ limit = Utils::Maximum(limit, max_semi_capacity_in_words_);
+ // Align to TLAB size.
+ limit = Utils::RoundDown(limit, kPageSizeInWords);
+
+ intptr_t growth_factor = grow ? FLAG_new_gen_growth_factor : 1;
+ return Utils::Minimum(old_size_in_words * growth_factor, limit);
}
class CollectStoreBufferScavengeVisitor : public ObjectPointerVisitor {
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/debugger.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/debugger.dart
index bd3ca45..d5682a0 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/debugger.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/debugger.dart
@@ -291,20 +291,23 @@
if (cls != null) {
libraryId = getLibraryUri(cls);
}
- var length = _get(object, 'length');
var result = _createJsObject({
'className': className,
'libraryId': libraryId,
'runtimeKind': RuntimeObjectKind.object,
- if (length != null) 'length': length,
});
- if (object is List) {
+ if (object is String) {
+ _set(result, 'length', _get(object, 'length'));
+ } else if (object is List) {
_set(result, 'runtimeKind', RuntimeObjectKind.list);
+ _set(result, 'length', _get(object, 'length'));
} else if (object is Map) {
_set(result, 'runtimeKind', RuntimeObjectKind.map);
+ _set(result, 'length', _get(object, 'length'));
} else if (object is Set) {
_set(result, 'runtimeKind', RuntimeObjectKind.set);
+ _set(result, 'length', _get(object, 'length'));
} else if (object is Function) {
_set(result, 'runtimeKind', RuntimeObjectKind.function);
} else if (object is RecordImpl) {
@@ -347,6 +350,10 @@
// Plain object with no constructor on the object.
// Return empty metadata so the object is not displayed in the debugger.
return _createEmptyJsObject();
+ } else {
+ // The debug spec specifies that plain objects should have a 'length' field
+ // which is the number of non-static fields on the object.
+ _set(result, 'length', getObjectFieldNames(object).length);
}
return result;
}
diff --git a/tools/VERSION b/tools/VERSION
index ad02d2c..f83e995 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 3
MINOR 6
PATCH 0
-PRERELEASE 148
+PRERELEASE 149
PRERELEASE_PATCH 0
diff --git a/tools/analysis_options.yaml b/tools/analysis_options.yaml
index d7f57b2..9fbde89 100644
--- a/tools/analysis_options.yaml
+++ b/tools/analysis_options.yaml
@@ -13,7 +13,6 @@
linter:
rules:
- - avoid_dynamic_calls
- comment_references
- depend_on_referenced_packages
- directives_ordering
diff --git a/tools/bots/find_base_commit.dart b/tools/bots/find_base_commit.dart
index 2765baf..73dcfda 100755
--- a/tools/bots/find_base_commit.dart
+++ b/tools/bots/find_base_commit.dart
@@ -100,7 +100,7 @@
// can, the first time we see a commit, we know it's newer than all commits
// we haven't seen yet. The insertion order into the buildersForCommits map
// will then sorted with the newest commit first.
- final builds = searchResult["builds"] as List<Map>?;
+ final builds = searchResult["builds"] as List?;
if (builds == null) {
print("No builds found");
exit(1);