From 711e50389fb39ac94397814139d8c68ec2ad2915 Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" Date: Fri, 10 Apr 2026 09:09:39 -0700 Subject: [PATCH] Remove `var` and `final` from parameters in `pkg/`. Doesn't change anything in `front_end/*testcases/primary_constructors/`. (Would have skipped any other file with `test` in its path and an explicit language version marker, but there weren't any outside of those `front_end` directories). Almost no files used as test input were affected, and none testing the actual syntax changed. The `.../nnbd/required_2.dart` test case was split into a legacy version retaining the `var`/`final` with a language marker, and a new version without the `var`/`final` cases. The `pkg/analyzer/` tests, and any other tests that have source code in strings, are not migrated by this CL. Tested: No change to behavior. One test split into legacy and new. Change-Id: I7f5aa4cc98001a9adecacd106c0b3be14f96be1c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480542 Reviewed-by: Johnni Winther Reviewed-by: Nate Bosch Reviewed-by: Ryan Macnak Commit-Queue: Lasse Nielsen Reviewed-by: Nicholas Shahan --- .../lib/src/parser/parser_impl.dart | 15 +-- .../lib/src/parser/type_info.dart | 2 +- .../lib/src/parser/type_info_impl.dart | 5 +- .../lib/src/testing/features.dart | 4 +- .../lib/src/type_inference/type_analyzer.dart | 2 +- pkg/compiler/lib/src/constants/values.dart | 24 ++-- .../inferrer/typemasks/flat_type_mask.dart | 2 +- .../lib/src/source_file_provider.dart | 2 +- .../test/codesize/swarm/SwarmViews.dart | 2 +- pkg/compiler/test/codesize/swarm/Views.dart | 2 +- .../swarm_ui_lib/observable/EventBatch.dart | 2 +- .../swarm/swarm_ui_lib/touch/Geometry.dart | 2 +- .../test/equivalence/check_helpers.dart | 12 +- .../lib.dart | 4 +- .../test/optimization/data/index.dart | 2 +- .../test/optimization/data/index_assign.dart | 2 +- .../test/optimization/data/remove_last.dart | 2 +- .../test/rti/data/generic_class_is2.dart | 2 +- .../test/rti/data/subtype_named_args.dart | 12 +- .../test/rti/data/subtype_named_args1.dart | 16 +-- .../test/rti/emission/subtype_named_args.dart | 12 +- .../testcases/bootstrapping.dart | 6 +- pkg/dart2native/lib/macho.dart | 4 +- .../lib/src/resident_frontend_utils.dart | 8 +- .../src/builder/function_type_builder.dart | 2 +- .../lib/src/builder/named_type_builder.dart | 2 +- .../lib/src/builder/record_type_builder.dart | 2 +- .../lib/src/builder/type_builder.dart | 2 +- pkg/front_end/lib/src/kernel/benchmarker.dart | 2 +- pkg/front_end/presubmit_helper.dart | 2 +- pkg/front_end/test/binary_md_dill_reader.dart | 2 +- pkg/front_end/test/coverage_helper.dart | 4 +- .../crashing_test_case_minimizer_impl.dart | 4 +- pkg/front_end/test/incremental_suite.dart | 4 +- pkg/front_end/test/isolates_v_processes.dart | 4 +- .../test/outline_extractor_tester.dart | 4 +- pkg/front_end/test/parser_test_parser.dart | 15 +-- pkg/front_end/testcases/nnbd/required_2.dart | 8 +- .../nnbd/required_2.dart.strong.expect | 39 ++----- .../required_2.dart.strong.modular.expect | 39 ++----- .../required_2.dart.strong.outline.expect | 21 +--- .../required_2.dart.strong.transformed.expect | 39 ++----- .../required_2.dart.textual_outline.expect | 4 +- ...red_2.dart.textual_outline_modelled.expect | 4 +- .../testcases/nnbd/required_2_legacy.dart | 59 ++++++++++ .../nnbd/required_2_legacy.dart.strong.expect | 105 ++++++++++++++++++ ...quired_2_legacy.dart.strong.modular.expect | 105 ++++++++++++++++++ ...quired_2_legacy.dart.strong.outline.expect | 46 ++++++++ ...ed_2_legacy.dart.strong.transformed.expect | 105 ++++++++++++++++++ ...uired_2_legacy.dart.textual_outline.expect | 31 ++++++ ...egacy.dart.textual_outline_modelled.expect | 36 ++++++ pkg/front_end/tool/coverage_merger.dart | 8 +- pkg/front_end/tool/coverage_runner.dart | 2 +- .../lib/resident_frontend_server_utils.dart | 2 +- .../lib/src/resident_frontend_server.dart | 6 +- pkg/js_ast/lib/src/builder.dart | 4 +- pkg/kernel/bin/size_breakdown.dart | 2 +- pkg/kernel/bin/switch_order.dart | 2 +- pkg/observatory/lib/object_graph.dart | 2 +- pkg/observatory/lib/src/app/view_model.dart | 4 +- .../lib/src/elements/nav/reload.dart | 2 +- .../lib/src/elements/script_inset.dart | 2 +- pkg/observatory/lib/src/service/object.dart | 6 +- pkg/test_runner/lib/src/testing_servers.dart | 5 +- .../type_flow/transformer/bench_is_prime.dart | 2 +- .../type_flow/transformer/extension_type.dart | 4 +- .../transformer/extension_type.dart.expect | 4 +- .../invalidation_while_processing.dart | 2 +- pkg/vm_service/test/get_stack_test.dart | 8 +- 69 files changed, 661 insertions(+), 242 deletions(-) create mode 100644 pkg/front_end/testcases/nnbd/required_2_legacy.dart create mode 100644 pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.expect create mode 100644 pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.modular.expect create mode 100644 pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.outline.expect create mode 100644 pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.transformed.expect create mode 100644 pkg/front_end/testcases/nnbd/required_2_legacy.dart.textual_outline.expect create mode 100644 pkg/front_end/testcases/nnbd/required_2_legacy.dart.textual_outline_modelled.expect diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart b/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart index f3bcb8ff667..b0a28432494 100644 --- a/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart +++ b/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart @@ -1741,7 +1741,7 @@ class Parser { /// ( ',' recordTypeNamedField )* ','? '}' /// recordTypeNamedField ::= metadata type identifier Token parseRecordType( - final Token start, + Token start, Token token, bool isQuestionMarkPartOfType, ) { @@ -2840,7 +2840,7 @@ class Parser { /// and the last skipped token is returned. /// Otherwise null is returned. Token? recoverySmallLookAheadSkipTokens( - final Token token, + Token token, List lookFor, ) { // Recovery: Allow a small lookahead for '{'. E.g. the user might be in @@ -4751,7 +4751,7 @@ class Parser { /// ``` /// 'super' ('.' identifier)? arguments ; /// ``` - Token parseSuperInitializerExpression(final Token start) { + Token parseSuperInitializerExpression(Token start) { Token token = start.next!; assert(token.isA(Keyword.SUPER)); Token next = token.next!; @@ -8519,10 +8519,7 @@ class Parser { /// genericFunctionLiteral ::= /// typeParameters formalParameterList functionBody /// Provide token for [constKeyword] if preceded by 'const', null if not. - Token parseLiteralListSetMapOrFunction( - final Token start, - Token? constKeyword, - ) { + Token parseLiteralListSetMapOrFunction(Token start, Token? constKeyword) { assert(start.next!.isA(TokenType.LT)); TypeParamOrArgInfo typeParamOrArg = computeTypeParamOrArg( start, @@ -9547,7 +9544,7 @@ class Parser { token.isA(Keyword.SYNC); } - Token parseExpressionStatementOrConstDeclaration(final Token start) { + Token parseExpressionStatementOrConstDeclaration(Token start) { Token constToken = start.next!; assert(constToken.isA(Keyword.CONST)); if (!isModifier(constToken.next!)) { @@ -9596,7 +9593,7 @@ class Parser { /// local variable declaration nor a pattern variable declaration is found, /// then this method will return [start]. Token parseExpressionStatementOrDeclaration( - final Token start, [ + Token start, [ ForPartsContext? forPartsContext, ]) { Token token = start; diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/type_info.dart b/pkg/_fe_analyzer_shared/lib/src/parser/type_info.dart index 363e71a80bd..1e7c107b3bd 100644 --- a/pkg/_fe_analyzer_shared/lib/src/parser/type_info.dart +++ b/pkg/_fe_analyzer_shared/lib/src/parser/type_info.dart @@ -156,7 +156,7 @@ bool isValidNonRecordTypeReference(Token token) { /// If [inDeclaration] is `true`, then this will more aggressively recover /// given unbalanced `<` `>` and invalid parameters or arguments. TypeInfo computeType( - final Token token, + Token token, bool required, [ bool inDeclaration = false, bool acceptKeywordForSimpleType = false, diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/type_info_impl.dart b/pkg/_fe_analyzer_shared/lib/src/parser/type_info_impl.dart index 56b5ed21da0..1ede258519c 100644 --- a/pkg/_fe_analyzer_shared/lib/src/parser/type_info_impl.dart +++ b/pkg/_fe_analyzer_shared/lib/src/parser/type_info_impl.dart @@ -879,10 +879,7 @@ class ComplexTypeInfo implements TypeInfo { /// Check if the presumed record type has correct syntax between its /// parenthesis. If not [recovered] will be set to true. /// Keep in sync with [Parser.parseRecordType] et al. - void _checkIfRecordTypeParenthesisAreRecovered( - Token token, - final Token endGroup, - ) { + void _checkIfRecordTypeParenthesisAreRecovered(Token token, Token endGroup) { int parameterCount = 0; bool hasNamedFields = false; bool hasComma = false; diff --git a/pkg/_fe_analyzer_shared/lib/src/testing/features.dart b/pkg/_fe_analyzer_shared/lib/src/testing/features.dart index 1708c5d3f20..4c1306a76d6 100644 --- a/pkg/_fe_analyzer_shared/lib/src/testing/features.dart +++ b/pkg/_fe_analyzer_shared/lib/src/testing/features.dart @@ -30,12 +30,12 @@ class Features { /// Mark the feature [key] as existing. If [value] is provided, the feature /// [key] is set to have this value. - void add(String key, {var value = ''}) { + void add(String key, {value = ''}) { _features[key] = value.toString(); } /// Add [value] as an element of the list values of feature [key]. - void addElement(String key, [var value]) { + void addElement(String key, [value]) { List list = _features.putIfAbsent(key, () => []) as List; if (value != null) { diff --git a/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart b/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart index 203a27a3343..25d44301a67 100644 --- a/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart +++ b/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart @@ -2172,7 +2172,7 @@ mixin TypeAnalyzer< SwitchStatementTypeAnalysisResult analyzeSwitchStatement( Statement node, Expression scrutinee, - final int numCases, + int numCases, ) { // Stack: () ExpressionTypeAnalysisResult scrutineeAnalysisResult = analyzeExpression( diff --git a/pkg/compiler/lib/src/constants/values.dart b/pkg/compiler/lib/src/constants/values.dart index cb8d36538bf..e785f6908f2 100644 --- a/pkg/compiler/lib/src/constants/values.dart +++ b/pkg/compiler/lib/src/constants/values.dart @@ -147,7 +147,7 @@ class FunctionConstantValue extends ConstantValue { FunctionConstantValue(this.element, this.type); @override - bool operator ==(var other) { + bool operator ==(other) { if (other is! FunctionConstantValue) return false; return identical(other.element, element); } @@ -187,7 +187,7 @@ abstract class PrimitiveConstantValue extends ConstantValue { const PrimitiveConstantValue(); @override - bool operator ==(var other) { + bool operator ==(other) { // Making this method abstract does not give us an error. throw UnsupportedError('PrimitiveConstant.=='); } @@ -277,7 +277,7 @@ class IntConstantValue extends NumConstantValue { DartType getType(CommonElements types) => types.intType; @override - bool operator ==(var other) { + bool operator ==(other) { // Ints and doubles are treated as separate constants. if (other is! IntConstantValue) return false; IntConstantValue otherInt = other; @@ -347,7 +347,7 @@ class DoubleConstantValue extends NumConstantValue { DartType getType(CommonElements types) => types.doubleType; @override - bool operator ==(var other) { + bool operator ==(other) { if (other is! DoubleConstantValue) return false; DoubleConstantValue otherDouble = other; double otherValue = otherDouble.doubleValue; @@ -416,7 +416,7 @@ class TrueConstantValue extends BoolConstantValue { FalseConstantValue negate() => FalseConstantValue(); @override - bool operator ==(var other) => identical(this, other); + bool operator ==(other) => identical(this, other); // The magic constant is just a random value. It does not have any // significance. @@ -439,7 +439,7 @@ class FalseConstantValue extends BoolConstantValue { TrueConstantValue negate() => TrueConstantValue(); @override - bool operator ==(var other) => identical(this, other); + bool operator ==(other) => identical(this, other); // The magic constant is just a random value. It does not have any // significance. @@ -465,7 +465,7 @@ class StringConstantValue extends PrimitiveConstantValue { DartType getType(CommonElements types) => types.stringType; @override - bool operator ==(var other) { + bool operator ==(other) { if (identical(this, other)) return true; if (other is! StringConstantValue) return false; StringConstantValue otherString = other; @@ -552,7 +552,7 @@ class ListConstantValue extends ObjectConstantValue { : hashCode = Hashing.listHash(entries, Hashing.objectHash(type)); @override - bool operator ==(var other) { + bool operator ==(other) { if (identical(this, other)) return true; if (other is! ListConstantValue) return false; ListConstantValue otherList = other; @@ -614,7 +614,7 @@ abstract class SetConstantValue extends ObjectConstantValue { : hashCode = Hashing.listHash(values, Hashing.objectHash(type)); @override - bool operator ==(var other) { + bool operator ==(other) { if (identical(this, other)) return true; if (other is! SetConstantValue) return false; SetConstantValue otherSet = other; @@ -677,7 +677,7 @@ abstract class MapConstantValue extends ObjectConstantValue { } @override - bool operator ==(var other) { + bool operator ==(other) { if (identical(this, other)) return true; if (other is! MapConstantValue) return false; MapConstantValue otherMap = other; @@ -927,7 +927,7 @@ class ConstructedConstantValue extends ObjectConstantValue { : hashCode = Hashing.unorderedMapHash(fields, Hashing.objectHash(type)); @override - bool operator ==(var other) { + bool operator ==(other) { if (identical(this, other)) return true; if (other is! ConstructedConstantValue) return false; if (hashCode != other.hashCode) return false; @@ -1123,7 +1123,7 @@ class JavaScriptObjectConstantValue extends ConstantValue { } @override - bool operator ==(var other) { + bool operator ==(other) { return identical(this, other) || other is JavaScriptObjectConstantValue && _equals(this, other); } diff --git a/pkg/compiler/lib/src/inferrer/typemasks/flat_type_mask.dart b/pkg/compiler/lib/src/inferrer/typemasks/flat_type_mask.dart index ce821561742..ec69f6f5bf0 100644 --- a/pkg/compiler/lib/src/inferrer/typemasks/flat_type_mask.dart +++ b/pkg/compiler/lib/src/inferrer/typemasks/flat_type_mask.dart @@ -841,7 +841,7 @@ class FlatTypeMask extends TypeMask { } @override - bool operator ==(var other) { + bool operator ==(other) { if (identical(this, other)) return true; if (other is! FlatTypeMask) return false; return (_flags == other._flags) && (base == other.base); diff --git a/pkg/compiler/lib/src/source_file_provider.dart b/pkg/compiler/lib/src/source_file_provider.dart index 324acf659d9..836acc39805 100644 --- a/pkg/compiler/lib/src/source_file_provider.dart +++ b/pkg/compiler/lib/src/source_file_provider.dart @@ -245,7 +245,7 @@ class FormattingDiagnosticHandler implements api.CompilerDiagnostics { @override void report( - var code, + code, Uri? uri, int? begin, int? end, diff --git a/pkg/compiler/test/codesize/swarm/SwarmViews.dart b/pkg/compiler/test/codesize/swarm/SwarmViews.dart index 3e675674a94..f2bdceb8519 100644 --- a/pkg/compiler/test/codesize/swarm/SwarmViews.dart +++ b/pkg/compiler/test/codesize/swarm/SwarmViews.dart @@ -818,7 +818,7 @@ class ArticleView extends View { } } - String getDataUriForImage(final img) { + String getDataUriForImage(img) { // TODO(hiltonc,jimhug) eval perf of this vs. reusing one canvas element final CanvasElement canvas = CanvasElement( height: img.height, diff --git a/pkg/compiler/test/codesize/swarm/Views.dart b/pkg/compiler/test/codesize/swarm/Views.dart index 960f8bbb2e7..084f5f5656e 100644 --- a/pkg/compiler/test/codesize/swarm/Views.dart +++ b/pkg/compiler/test/codesize/swarm/Views.dart @@ -39,7 +39,7 @@ class EventListeners { listeners.add(listener); } - void fire(var event) { + void fire(event) { for (final listener in listeners) { listener(event); } diff --git a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/observable/EventBatch.dart b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/observable/EventBatch.dart index 3dbef2d726d..76bc5f726be 100644 --- a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/observable/EventBatch.dart +++ b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/observable/EventBatch.dart @@ -28,7 +28,7 @@ class EventBatch { /// Ensure there is an event batch where [userFunction] can accumulate events. /// When the batch is complete, fire all events at once. - static void Function(T) wrap(userFunction(var a)) { + static void Function(T) wrap(userFunction(a)) { return (e) { if (current == null) { // Not in a batch so create one. diff --git a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Geometry.dart b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Geometry.dart index 74e9f1d37ee..e59e1ff06ab 100644 --- a/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Geometry.dart +++ b/pkg/compiler/test/codesize/swarm/swarm_ui_lib/touch/Geometry.dart @@ -16,7 +16,7 @@ class Coordinate { /// Gets the coordinates of a touch's location relative to the window's /// viewport. [input] is either a touch object or an event object. - Coordinate.fromClient(var input) : this(input.client.x, input.client.y); + Coordinate.fromClient(input) : this(input.client.x, input.client.y); static Coordinate difference(Coordinate a, Coordinate b) { return Coordinate(a.x - b.x, a.y - b.y); diff --git a/pkg/compiler/test/equivalence/check_helpers.dart b/pkg/compiler/test/equivalence/check_helpers.dart index 37e3878e7b6..0e963be49e9 100644 --- a/pkg/compiler/test/equivalence/check_helpers.dart +++ b/pkg/compiler/test/equivalence/check_helpers.dart @@ -73,8 +73,8 @@ bool equality(a, b) => a == b; /// Check that the values [property] of [object1] and [object2], [value1] and /// [value2] respectively, are equal and throw otherwise. bool check( - var object1, - var object2, + object1, + object2, String property, T value1, T value2, [ @@ -186,8 +186,8 @@ Set computeSetDifference( /// /// Uses [object1], [object2] and [property] to provide context for failures. bool checkSetEquivalence( - var object1, - var object2, + object1, + object2, String property, Iterable set1, Iterable set2, @@ -221,8 +221,8 @@ bool checkSetEquivalence( /// /// Uses [object1], [object2] and [property] to provide context for failures. bool checkMapEquivalence( - var object1, - var object2, + object1, + object2, String property, Map map1, Map map2, diff --git a/pkg/compiler/test/inference/data/mixin_constructor_default_parameter_values/lib.dart b/pkg/compiler/test/inference/data/mixin_constructor_default_parameter_values/lib.dart index 64681966c07..8c621bca11e 100644 --- a/pkg/compiler/test/inference/data/mixin_constructor_default_parameter_values/lib.dart +++ b/pkg/compiler/test/inference/data/mixin_constructor_default_parameter_values/lib.dart @@ -19,7 +19,7 @@ class C { /*member: C.a:[empty|powerset=empty]*/ C.a( int /*[exact=JSUInt31|powerset={I}{O}{N}]*/ x, [ - var /*Union([exact=JSString|powerset={I}{O}{I}], [exact=_SECRET|powerset={N}{O}{N}], powerset: {IN}{O}{IN})*/ b = + /*Union([exact=JSString|powerset={I}{O}{I}], [exact=_SECRET|powerset={N}{O}{N}], powerset: {IN}{O}{IN})*/ b = const _SECRET(), ]) : this.x = x, this.y = b; @@ -27,7 +27,7 @@ class C { /*member: C.b:[empty|powerset=empty]*/ C.b( int /*[exact=JSUInt31|powerset={I}{O}{N}]*/ x, { - var /*Union([exact=JSString|powerset={I}{O}{I}], [exact=_SECRET|powerset={N}{O}{N}], powerset: {IN}{O}{IN})*/ b = + /*Union([exact=JSString|powerset={I}{O}{I}], [exact=_SECRET|powerset={N}{O}{N}], powerset: {IN}{O}{IN})*/ b = const _SECRET(), }) : this.x = x, this.y = b; diff --git a/pkg/compiler/test/optimization/data/index.dart b/pkg/compiler/test/optimization/data/index.dart index 3818599bacd..00c02148627 100644 --- a/pkg/compiler/test/optimization/data/index.dart +++ b/pkg/compiler/test/optimization/data/index.dart @@ -6,7 +6,7 @@ import 'dart:collection'; /*member: dynamicIndex:Specializer=[!Index]*/ @pragma('dart2js:noInline') -dynamicIndex(var list) { +dynamicIndex(list) { return list[0]; // This not known to be an indexable primitive. } diff --git a/pkg/compiler/test/optimization/data/index_assign.dart b/pkg/compiler/test/optimization/data/index_assign.dart index 3b7678821d4..425cc138b6f 100644 --- a/pkg/compiler/test/optimization/data/index_assign.dart +++ b/pkg/compiler/test/optimization/data/index_assign.dart @@ -4,7 +4,7 @@ /*member: dynamicIndexAssign:Specializer=[!IndexAssign]*/ @pragma('dart2js:noInline') -dynamicIndexAssign(var list) { +dynamicIndexAssign(list) { list[0] = 1; } diff --git a/pkg/compiler/test/optimization/data/remove_last.dart b/pkg/compiler/test/optimization/data/remove_last.dart index b10ca8a3493..f1ff3e78e22 100644 --- a/pkg/compiler/test/optimization/data/remove_last.dart +++ b/pkg/compiler/test/optimization/data/remove_last.dart @@ -7,7 +7,7 @@ import 'dart:typed_data'; /*member: dynamicIndex:Specializer=[!RemoveLast]*/ @pragma('dart2js:noInline') -dynamicIndex(var list) { +dynamicIndex(list) { return list.removeLast(); // This is not known to be an indexable primitive. } diff --git a/pkg/compiler/test/rti/data/generic_class_is2.dart b/pkg/compiler/test/rti/data/generic_class_is2.dart index e68ccfed407..50a647aa9a0 100644 --- a/pkg/compiler/test/rti/data/generic_class_is2.dart +++ b/pkg/compiler/test/rti/data/generic_class_is2.dart @@ -13,7 +13,7 @@ class A1 implements A {} /*class: B:explicit=[B.T],needsArgs,test*/ class B { @pragma('dart2js:noInline') - method(var t) => t is T; + method(t) => t is T; } /*class: C:implicit=[List>]*/ diff --git a/pkg/compiler/test/rti/data/subtype_named_args.dart b/pkg/compiler/test/rti/data/subtype_named_args.dart index bf500f05b48..bd6fec8b10c 100644 --- a/pkg/compiler/test/rti/data/subtype_named_args.dart +++ b/pkg/compiler/test/rti/data/subtype_named_args.dart @@ -34,9 +34,9 @@ class G {} typedef classesFunc({A? a, B? b, C? c, D? d}); typedef genericsFunc({Map? m, List>? l, G? g}); -typedef dynamicFunc({var x, var y, var z, var v}); +typedef dynamicFunc({x, y, z, v}); typedef funcFunc({classesFunc? f1, genericsFunc? f2, dynamicFunc? f3}); -typedef mixFunc({var x, B? b, G? g, funcFunc? f}); +typedef mixFunc({x, B? b, G? g, funcFunc? f}); typedef okWithClassesFunc_1({A? a, A1? b, A1? c, A1? d}); typedef okWithClassesFunc_2({D? a, D? b, D? c, D? d}); @@ -52,7 +52,7 @@ typedef okWithGenericsFunc_2({ G? g, }); -typedef okWithDynamicFunc_1({A? x, G? y, mixFunc? z, var v}); +typedef okWithDynamicFunc_1({A? x, G? y, mixFunc? z, v}); typedef okWithDynamicFunc_2({int? x, bool? y, List? z, classesFunc? v}); main() { @@ -78,7 +78,7 @@ main() { ); makeLive( /*needsSignature*/ - ({var a, var b, var c, var d}) {} is classesFunc, + ({a, b, c, d}) {} is classesFunc, ); makeLive( /*needsSignature*/ @@ -96,7 +96,7 @@ main() { ); makeLive( /*needsSignature*/ - ({var m, var l, var g}) {} is genericsFunc, + ({m, l, g}) {} is genericsFunc, ); makeLive( /*needsSignature*/ @@ -105,7 +105,7 @@ main() { makeLive( /*needsSignature*/ - ({A? x, G? y, mixFunc? z, var v}) {} is dynamicFunc, + ({A? x, G? y, mixFunc? z, v}) {} is dynamicFunc, ); makeLive( /*needsSignature*/ diff --git a/pkg/compiler/test/rti/data/subtype_named_args1.dart b/pkg/compiler/test/rti/data/subtype_named_args1.dart index a8e621ef17d..50d5d64f41a 100644 --- a/pkg/compiler/test/rti/data/subtype_named_args1.dart +++ b/pkg/compiler/test/rti/data/subtype_named_args1.dart @@ -23,7 +23,7 @@ class D implements C {} typedef t1({B? a}); typedef t2({C? c}); typedef t3({int? i}); -typedef t4({var v}); +typedef t4({v}); typedef t5({Map? m}); typedef t6({Map? m}); typedef t7({t1? f}); @@ -40,26 +40,26 @@ main() { makeLive(/*needsSignature*/ ({C? a}) {} is t1); makeLive(/*needsSignature*/ ({D? a}) {} is t1); makeLive(/*needsSignature*/ ({Object? a}) {} is t1); - makeLive(/*needsSignature*/ ({var a}) {} is t1); + makeLive(/*needsSignature*/ ({a}) {} is t1); makeLive(/*needsSignature*/ ({A? c}) {} is t2); makeLive(/*needsSignature*/ ({B? c}) {} is t2); makeLive(/*needsSignature*/ ({C? c}) {} is t2); makeLive(/*needsSignature*/ ({D? c}) {} is t2); makeLive(/*needsSignature*/ ({Object? c}) {} is t2); - makeLive(/*needsSignature*/ ({var c}) {} is t2); + makeLive(/*needsSignature*/ ({c}) {} is t2); makeLive(/*needsSignature*/ ({num? i}) {} is t3); makeLive(/*needsSignature*/ ({int? i}) {} is t3); makeLive(/*needsSignature*/ ({Object? i}) {} is t3); - makeLive(/*needsSignature*/ ({var i}) {} is t3); + makeLive(/*needsSignature*/ ({i}) {} is t3); makeLive(/*needsSignature*/ ({A? v}) {} is t4); makeLive(/*needsSignature*/ ({B? v}) {} is t4); makeLive(/*needsSignature*/ ({C? v}) {} is t4); makeLive(/*needsSignature*/ ({D? v}) {} is t4); makeLive(/*needsSignature*/ ({Object? v}) {} is t4); - makeLive(/*needsSignature*/ ({var v}) {} is t4); + makeLive(/*needsSignature*/ ({v}) {} is t4); makeLive(/*needsSignature*/ ({num? v}) {} is t4); makeLive(/*needsSignature*/ ({int? v}) {} is t4); makeLive(/*needsSignature*/ ({Map? v}) {} is t4); @@ -73,7 +73,7 @@ main() { makeLive(/*needsSignature*/ ({Map? m}) {} is t5); makeLive(/*needsSignature*/ ({Map? m}) {} is t5); makeLive(/*needsSignature*/ ({Object? m}) {} is t5); - makeLive(/*needsSignature*/ ({var m}) {} is t5); + makeLive(/*needsSignature*/ ({m}) {} is t5); makeLive(/*needsSignature*/ ({Map? m}) {} is t5); makeLive(/*needsSignature*/ ({Map? m}) {} is t5); @@ -81,7 +81,7 @@ main() { makeLive(/*needsSignature*/ ({Map? m}) {} is t6); makeLive(/*needsSignature*/ ({Map? m}) {} is t6); makeLive(/*needsSignature*/ ({Object? m}) {} is t6); - makeLive(/*needsSignature*/ ({var m}) {} is t6); + makeLive(/*needsSignature*/ ({m}) {} is t6); makeLive(/*needsSignature*/ ({okWithT1_1? f}) {} is t7); makeLive(/*needsSignature*/ ({okWithT1_2? f}) {} is t7); @@ -93,7 +93,7 @@ main() { makeLive(/*needsSignature*/ ({C? a}) {} is t8); makeLive(/*needsSignature*/ ({D? a}) {} is t8); makeLive(/*needsSignature*/ ({Object? a}) {} is t8); - makeLive(/*needsSignature*/ ({var a}) {} is t8); + makeLive(/*needsSignature*/ ({a}) {} is t8); makeLive(/*needsSignature*/ ({num? a}) {} is t8); makeLive(/*needsSignature*/ ({int? a}) {} is t8); makeLive(/*needsSignature*/ ({Map? a}) {} is t8); diff --git a/pkg/compiler/test/rti/emission/subtype_named_args.dart b/pkg/compiler/test/rti/emission/subtype_named_args.dart index 21e019fbd94..75990c08565 100644 --- a/pkg/compiler/test/rti/emission/subtype_named_args.dart +++ b/pkg/compiler/test/rti/emission/subtype_named_args.dart @@ -36,9 +36,9 @@ class G {} typedef classesFunc({A? a, B? b, C? c, D? d}); typedef genericsFunc({Map? m, List>? l, G? g}); -typedef dynamicFunc({var x, var y, var z, var v}); +typedef dynamicFunc({x, y, z, v}); typedef funcFunc({classesFunc? f1, genericsFunc? f2, dynamicFunc? f3}); -typedef mixFunc({var x, B? b, G? g, funcFunc? f}); +typedef mixFunc({x, B? b, G? g, funcFunc? f}); typedef okWithClassesFunc_1({A? a, A1? b, A1? c, A1? d}); typedef okWithClassesFunc_2({D? a, D? b, D? c, D? d}); @@ -54,7 +54,7 @@ typedef okWithGenericsFunc_2({ G? g, }); -typedef okWithDynamicFunc_1({A? x, G? y, mixFunc? z, var v}); +typedef okWithDynamicFunc_1({A? x, G? y, mixFunc? z, v}); typedef okWithDynamicFunc_2({int? x, bool? y, List? z, classesFunc? v}); main() { @@ -80,7 +80,7 @@ main() { ); makeLive( /*checks=[$signature],instance*/ - ({var a, var b, var c, var d}) {} is classesFunc, + ({a, b, c, d}) {} is classesFunc, ); makeLive( /*checks=[$signature],instance*/ @@ -98,7 +98,7 @@ main() { ); makeLive( /*checks=[$signature],instance*/ - ({var m, var l, var g}) {} is genericsFunc, + ({m, l, g}) {} is genericsFunc, ); makeLive( /*checks=[$signature],instance*/ @@ -107,7 +107,7 @@ main() { makeLive( /*checks=[$signature],instance*/ - ({A? x, G? y, mixFunc? z, var v}) {} is dynamicFunc, + ({A? x, G? y, mixFunc? z, v}) {} is dynamicFunc, ); makeLive( /*checks=[$signature],instance*/ diff --git a/pkg/dart2bytecode/testcases/bootstrapping.dart b/pkg/dart2bytecode/testcases/bootstrapping.dart index d91b651cc8d..a457fb3dc40 100644 --- a/pkg/dart2bytecode/testcases/bootstrapping.dart +++ b/pkg/dart2bytecode/testcases/bootstrapping.dart @@ -33,12 +33,12 @@ void _setScheduleImmediateClosure(_ScheduleImmediateClosure closure) { base class _NamespaceImpl implements _Namespace { _NamespaceImpl._(); - external static _NamespaceImpl _create(_NamespaceImpl namespace, var n); + external static _NamespaceImpl _create(_NamespaceImpl namespace, n); external static int _getPointer(_NamespaceImpl namespace); external static int _getDefault(); static _NamespaceImpl? _cachedNamespace = null; - static void _setupNamespace(var namespace) { + static void _setupNamespace(namespace) { _cachedNamespace = _create(new _NamespaceImpl._(), namespace); } @@ -53,7 +53,7 @@ base class _NamespaceImpl implements _Namespace { } class _Namespace { - static void _setupNamespace(var namespace) { + static void _setupNamespace(namespace) { _NamespaceImpl._setupNamespace(namespace); } diff --git a/pkg/dart2native/lib/macho.dart b/pkg/dart2native/lib/macho.dart index 0119b54f424..5b417034714 100644 --- a/pkg/dart2native/lib/macho.dart +++ b/pkg/dart2native/lib/macho.dart @@ -1066,7 +1066,7 @@ class MachOLinkeditDataCommand extends MachOLoadCommand { ); static MachOLinkeditDataCommand fromStream( - int code, final int size, MachOReader stream) { + int code, int size, MachOReader stream) { final dataFileOffset = stream.readUint32(); final dataSize = stream.readUint32(); @@ -1113,7 +1113,7 @@ class MachOEncryptionInfoCommand extends MachOLoadCommand { this.fileSize, this.encryptionSystem, this.padding); static MachOEncryptionInfoCommand fromStream( - int code, final int size, MachOReader stream) { + int code, int size, MachOReader stream) { final is64Bit = LoadCommandType.fromCode(code) == LoadCommandType.encryptionInfo64; diff --git a/pkg/dartdev/lib/src/resident_frontend_utils.dart b/pkg/dartdev/lib/src/resident_frontend_utils.dart index df05feee26a..96a866ce0c0 100644 --- a/pkg/dartdev/lib/src/resident_frontend_utils.dart +++ b/pkg/dartdev/lib/src/resident_frontend_utils.dart @@ -19,7 +19,7 @@ final residentServerShutdownCommand = jsonEncode({ commandString: shutdownString, }); -File? getResidentCompilerInfoFileConsideringArgs(final ArgResults args) => +File? getResidentCompilerInfoFileConsideringArgs(ArgResults args) => getResidentCompilerInfoFileConsideringArgsImpl( args[CompilationServerCommand.residentCompilerInfoFileFlag] ?? args[CompilationServerCommand.legacyResidentServerInfoFileFlag], @@ -56,7 +56,7 @@ Future shutDownOrForgetResidentFrontendCompiler(File infoFile) async { cleanupResidentServerInfo(infoFile); } -Future isFileKernelFile(final File file) async { +Future isFileKernelFile(File file) async { final bytes = await file.openRead(0, 4).expand((i) => i).toList(); if (bytes.length < 4) { return false; @@ -68,7 +68,7 @@ Future isFileKernelFile(final File file) async { bytes[3] == 0xef; } -Future isFileAppJitSnapshot(final File file) async { +Future isFileAppJitSnapshot(File file) async { final bytes = await file.openRead(0, 8).expand((i) => i).toList(); if (bytes.length < 8) { return false; @@ -84,7 +84,7 @@ Future isFileAppJitSnapshot(final File file) async { bytes[7] == 0; } -Future isFileAotSnapshot(final File file) async { +Future isFileAotSnapshot(File file) async { // Check for any of the magic numbers that can be found at the start of an // AOT snapshot. diff --git a/pkg/front_end/lib/src/builder/function_type_builder.dart b/pkg/front_end/lib/src/builder/function_type_builder.dart index 013f495e4ce..4cb0c30207f 100644 --- a/pkg/front_end/lib/src/builder/function_type_builder.dart +++ b/pkg/front_end/lib/src/builder/function_type_builder.dart @@ -341,7 +341,7 @@ abstract class FunctionTypeBuilderImpl extends FunctionTypeBuilder { Map upperSubstitution, Map lowerSubstitution, TypeParameterFactory typeParameterFactory, { - final Variance variance = Variance.covariant, + Variance variance = Variance.covariant, }) { List? typeParameters = this.typeParameters; List? formals = this.formals; diff --git a/pkg/front_end/lib/src/builder/named_type_builder.dart b/pkg/front_end/lib/src/builder/named_type_builder.dart index 4503b3c2277..505d58d96bc 100644 --- a/pkg/front_end/lib/src/builder/named_type_builder.dart +++ b/pkg/front_end/lib/src/builder/named_type_builder.dart @@ -1010,7 +1010,7 @@ abstract class NamedTypeBuilderImpl extends NamedTypeBuilder { Map upperSubstitution, Map lowerSubstitution, TypeParameterFactory typeParameterFactory, { - final Variance variance = Variance.covariant, + Variance variance = Variance.covariant, }) { TypeDeclarationBuilder declaration = this.declaration; List? arguments = this.typeArguments; diff --git a/pkg/front_end/lib/src/builder/record_type_builder.dart b/pkg/front_end/lib/src/builder/record_type_builder.dart index 8a841b162ea..4df28c56f17 100644 --- a/pkg/front_end/lib/src/builder/record_type_builder.dart +++ b/pkg/front_end/lib/src/builder/record_type_builder.dart @@ -425,7 +425,7 @@ abstract class RecordTypeBuilderImpl extends RecordTypeBuilder { Map upperSubstitution, Map lowerSubstitution, TypeParameterFactory typeParameterFactory, { - final Variance variance = Variance.covariant, + Variance variance = Variance.covariant, }) { List? positionalFields = this.positionalFields; List? namedFields = this.namedFields; diff --git a/pkg/front_end/lib/src/builder/type_builder.dart b/pkg/front_end/lib/src/builder/type_builder.dart index 9939eea779d..e1a0b047a17 100644 --- a/pkg/front_end/lib/src/builder/type_builder.dart +++ b/pkg/front_end/lib/src/builder/type_builder.dart @@ -497,7 +497,7 @@ sealed class TypeBuilder { Map upperSubstitution, Map lowerSubstitution, TypeParameterFactory typeParameterFactory, { - final Variance variance = Variance.covariant, + Variance variance = Variance.covariant, }); TypeBuilder? unaliasAndErase(); diff --git a/pkg/front_end/lib/src/kernel/benchmarker.dart b/pkg/front_end/lib/src/kernel/benchmarker.dart index d5e6ea8f68e..ddbb03baf7f 100644 --- a/pkg/front_end/lib/src/kernel/benchmarker.dart +++ b/pkg/front_end/lib/src/kernel/benchmarker.dart @@ -37,7 +37,7 @@ class Benchmarker { _currentPhase = BenchmarkPhases.implicitInitialization; } - void beginSubdivide(final BenchmarkSubdivides phase) { + void beginSubdivide(BenchmarkSubdivides phase) { _pauseLatestSubdivide(addAsCount: false); _subdivideStopwatch.reset(); _subdivides.add(phase); diff --git a/pkg/front_end/presubmit_helper.dart b/pkg/front_end/presubmit_helper.dart index 1b9a2ded350..52b6b435b0b 100644 --- a/pkg/front_end/presubmit_helper.dart +++ b/pkg/front_end/presubmit_helper.dart @@ -428,7 +428,7 @@ Future _run(String script, List scriptArguments) async { // but we only want to actually run it once. To that end we - from the changed // files figure out which would call this script, and only if the caller is // the top one (just alphabetically sorted) we actually run. -bool _shouldRun(final List changedFiles, final String callerPath) { +bool _shouldRun(List changedFiles, String callerPath) { Uri pkgDir = _repoDir.resolve("pkg/"); Uri callerUri = Uri.base.resolveUri(Uri.file(callerPath)); int? endPathIndex = _getPathSegmentIndexIfSubEntry(pkgDir, callerUri); diff --git a/pkg/front_end/test/binary_md_dill_reader.dart b/pkg/front_end/test/binary_md_dill_reader.dart index e275d5c3301..961d0e64a9f 100644 --- a/pkg/front_end/test/binary_md_dill_reader.dart +++ b/pkg/front_end/test/binary_md_dill_reader.dart @@ -235,7 +235,7 @@ class BinaryMdDillReader { /// * "Class extends Node {" into "Class" /// * "Byte tag = 97;" into "Byte" /// * "List {" into "List" - String _getType(final String inputString) { + String _getType(String inputString) { String? cached = _typeCache[inputString]; if (cached != null) return cached; int end = math.max( diff --git a/pkg/front_end/test/coverage_helper.dart b/pkg/front_end/test/coverage_helper.dart index 77f518176a2..03d28aac7dd 100644 --- a/pkg/front_end/test/coverage_helper.dart +++ b/pkg/front_end/test/coverage_helper.dart @@ -35,8 +35,8 @@ Future collectCoverage({ Future collectCoverageWithHelper({ required VMServiceHelper helper, - required final bool getKernelServiceCoverageToo, - required final String displayName, + required bool getKernelServiceCoverageToo, + required String displayName, bool forceCompile = false, }) async { VM vm = await helper.serviceClient.getVM(); diff --git a/pkg/front_end/test/crashing_test_case_minimizer_impl.dart b/pkg/front_end/test/crashing_test_case_minimizer_impl.dart index 647e7457547..8b3e1db2626 100644 --- a/pkg/front_end/test/crashing_test_case_minimizer_impl.dart +++ b/pkg/front_end/test/crashing_test_case_minimizer_impl.dart @@ -1326,7 +1326,7 @@ worlds: _fs.data[uri] = latestCrashData; } - Future _deleteBlocks(final Uri uri, Component initialComponent) async { + Future _deleteBlocks(Uri uri, Component initialComponent) async { if (uri.toString().endsWith(".json")) { // Try to find annoying // @@ -1747,7 +1747,7 @@ worlds: Future _deleteBlocksHelper( ClassOrMixinOrExtensionBodyEnd body, _CompilationHelperClass helper, - final Uri uri, + Uri uri, Component initialComponent, ) async { for (ParserAstNode child in body.children!) { diff --git a/pkg/front_end/test/incremental_suite.dart b/pkg/front_end/test/incremental_suite.dart index 06a3a75488e..95413dce305 100644 --- a/pkg/front_end/test/incremental_suite.dart +++ b/pkg/front_end/test/incremental_suite.dart @@ -817,7 +817,7 @@ Future basicTest( Future> createModules( Map> module, - final List sdkSummaryData, + List sdkSummaryData, Target target, Target originalTarget, String sdkSummary, { @@ -2769,7 +2769,7 @@ String nodeToString(TreeNode node) { String componentToStringSdkFiltered( Component component, { - required final Set? printErrors, + required Set? printErrors, }) { Component c = new Component(); List dartUris = []; diff --git a/pkg/front_end/test/isolates_v_processes.dart b/pkg/front_end/test/isolates_v_processes.dart index 1246f1b45d9..d3c5947fad6 100644 --- a/pkg/front_end/test/isolates_v_processes.dart +++ b/pkg/front_end/test/isolates_v_processes.dart @@ -65,7 +65,7 @@ Future useDirect(int shards, int shard) async { await Future.wait(futures); } -Future useIsolates(final int j) async { +Future useIsolates(int j) async { Stopwatch stopwatch = new Stopwatch()..start(); print("Using $j isolates..."); List futures = []; @@ -88,7 +88,7 @@ Future useIsolates(final int j) async { await Future.wait(futures); } -Future useProcesses(final int j) async { +Future useProcesses(int j) async { Stopwatch stopwatch = new Stopwatch()..start(); print("Using $j processes..."); String script = Platform.script.toFilePath(); diff --git a/pkg/front_end/test/outline_extractor_tester.dart b/pkg/front_end/test/outline_extractor_tester.dart index a1c0d87f88c..767384d0821 100644 --- a/pkg/front_end/test/outline_extractor_tester.dart +++ b/pkg/front_end/test/outline_extractor_tester.dart @@ -79,9 +79,9 @@ Future main(List args) async { } Future processUri( - final List inputs, + List inputs, Component? fullComponent, - final Uri packageUri, + Uri packageUri, ) async { TargetFlags targetFlags = new TargetFlags(trackWidgetCreation: false); Target? target = new Dart2jsTarget("dart2js", targetFlags); diff --git a/pkg/front_end/test/parser_test_parser.dart b/pkg/front_end/test/parser_test_parser.dart index 28785f45cac..85d6525c2ce 100644 --- a/pkg/front_end/test/parser_test_parser.dart +++ b/pkg/front_end/test/parser_test_parser.dart @@ -595,7 +595,7 @@ class TestParser extends Parser { @override Token parseRecordType( - final Token start, + Token start, Token token, bool isQuestionMarkPartOfType, ) { @@ -851,7 +851,7 @@ class TestParser extends Parser { @override Token? recoverySmallLookAheadSkipTokens( - final Token token, + Token token, List lookFor, ) { doPrint( @@ -1585,7 +1585,7 @@ class TestParser extends Parser { } @override - Token parseSuperInitializerExpression(final Token start) { + Token parseSuperInitializerExpression(Token start) { doPrint( 'parseSuperInitializerExpression(' '$start)', @@ -2553,10 +2553,7 @@ class TestParser extends Parser { } @override - Token parseLiteralListSetMapOrFunction( - final Token start, - Token? constKeyword, - ) { + Token parseLiteralListSetMapOrFunction(Token start, Token? constKeyword) { doPrint( 'parseLiteralListSetMapOrFunction(' '$start, ' @@ -2944,7 +2941,7 @@ class TestParser extends Parser { } @override - Token parseExpressionStatementOrConstDeclaration(final Token start) { + Token parseExpressionStatementOrConstDeclaration(Token start) { doPrint( 'parseExpressionStatementOrConstDeclaration(' '$start)', @@ -2957,7 +2954,7 @@ class TestParser extends Parser { @override Token parseExpressionStatementOrDeclaration( - final Token start, [ + Token start, [ ForPartsContext? forPartsContext, ]) { doPrint( diff --git a/pkg/front_end/testcases/nnbd/required_2.dart b/pkg/front_end/testcases/nnbd/required_2.dart index 7692a347d49..48eedf773bc 100644 --- a/pkg/front_end/testcases/nnbd/required_2.dart +++ b/pkg/front_end/testcases/nnbd/required_2.dart @@ -2,14 +2,16 @@ // 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. -method({int a = 42, required int b, required final int c}) {} +// Test intended for post-primary constructors language versions, where +// `final` cannot occur in non-primary parameters. + +method({int a = 42, required int b, required int c}) {} class Class { method( {int a = 42, required int b, - required final int c, - required covariant final int d}) {} + required covariant int c}) {} } // TODO(johnniwinther): Pass the required property to the function types. diff --git a/pkg/front_end/testcases/nnbd/required_2.dart.strong.expect b/pkg/front_end/testcases/nnbd/required_2.dart.strong.expect index 73b44ed1e25..9f2b5ea1f4d 100644 --- a/pkg/front_end/testcases/nnbd/required_2.dart.strong.expect +++ b/pkg/front_end/testcases/nnbd/required_2.dart.strong.expect @@ -2,65 +2,50 @@ library; // // Problems in library: // -// pkg/front_end/testcases/nnbd/required_2.dart:5:46: Error: Can't have modifier 'final' here. -// Try removing 'final'. -// method({int a = 42, required int b, required final int c}) {} -// ^^^^^ -// -// pkg/front_end/testcases/nnbd/required_2.dart:11:18: Error: Can't have modifier 'final' here. -// Try removing 'final'. -// required final int c, -// ^^^^^ -// -// pkg/front_end/testcases/nnbd/required_2.dart:12:28: Error: Can't have modifier 'final' here. -// Try removing 'final'. -// required covariant final int d}) {} -// ^^^^^ -// -// pkg/front_end/testcases/nnbd/required_2.dart:29:8: Error: The parameter 'x' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:31:8: Error: The parameter 'x' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // foo({x}) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:51:18: Error: Non-optional parameters can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:53:18: Error: Non-optional parameters can't have a default value. // Try removing the default value or making the parameter optional. // Function(int a = 42, [int b]) f2; // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:52:17: Error: Non-optional parameters can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:54:17: Error: Non-optional parameters can't have a default value. // Try removing the default value or making the parameter optional. // void g2(int a = 42, [int b]) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:53:15: Error: Non-optional parameters can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:55:15: Error: Non-optional parameters can't have a default value. // Try removing the default value or making the parameter optional. // f2 = (int a = 42, [int b]) {}; // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:48:15: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:50:15: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // void g({int a, required int b = 42}) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:48:31: Error: Named parameter 'b' is required and can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:50:31: Error: Named parameter 'b' is required and can't have a default value. // void g({int a, required int b = 42}) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:49:13: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:51:13: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // f = ({int a, required int b = 42}) {}; // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:49:29: Error: Named parameter 'b' is required and can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:51:29: Error: Named parameter 'b' is required and can't have a default value. // f = ({int a, required int b = 42}) {}; // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:52:28: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:54:28: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // void g2(int a = 42, [int b]) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:53:26: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:55:26: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // f2 = (int a = 42, [int b]) {}; // ^ @@ -74,7 +59,7 @@ class Class extends core::Object { synthetic constructor •() → self::Class : super core::Object::•() ; - method method({core::int a = #C1, required core::int b, required final core::int c, required covariant-by-declaration final core::int d}) → dynamic {} + method method({core::int a = #C1, required core::int b, required covariant-by-declaration core::int c}) → dynamic {} } abstract class A extends core::Object { synthetic constructor •() → self::A @@ -95,7 +80,7 @@ class C extends self::A { method foo({core::int x = #C1}) → dynamic {} } static field ({a: core::int, required b: core::int}) → dynamic field = ({core::int a = #C1, required core::int b}) → Null {}; -static method method({core::int a = #C1, required core::int b, required final core::int c}) → dynamic {} +static method method({core::int a = #C1, required core::int b, required core::int c}) → dynamic {} static method ok() → dynamic { ({a: core::int, required b: core::int}) → dynamic f; function g({core::int a = #C1, required core::int b}) → void {} diff --git a/pkg/front_end/testcases/nnbd/required_2.dart.strong.modular.expect b/pkg/front_end/testcases/nnbd/required_2.dart.strong.modular.expect index 73b44ed1e25..9f2b5ea1f4d 100644 --- a/pkg/front_end/testcases/nnbd/required_2.dart.strong.modular.expect +++ b/pkg/front_end/testcases/nnbd/required_2.dart.strong.modular.expect @@ -2,65 +2,50 @@ library; // // Problems in library: // -// pkg/front_end/testcases/nnbd/required_2.dart:5:46: Error: Can't have modifier 'final' here. -// Try removing 'final'. -// method({int a = 42, required int b, required final int c}) {} -// ^^^^^ -// -// pkg/front_end/testcases/nnbd/required_2.dart:11:18: Error: Can't have modifier 'final' here. -// Try removing 'final'. -// required final int c, -// ^^^^^ -// -// pkg/front_end/testcases/nnbd/required_2.dart:12:28: Error: Can't have modifier 'final' here. -// Try removing 'final'. -// required covariant final int d}) {} -// ^^^^^ -// -// pkg/front_end/testcases/nnbd/required_2.dart:29:8: Error: The parameter 'x' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:31:8: Error: The parameter 'x' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // foo({x}) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:51:18: Error: Non-optional parameters can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:53:18: Error: Non-optional parameters can't have a default value. // Try removing the default value or making the parameter optional. // Function(int a = 42, [int b]) f2; // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:52:17: Error: Non-optional parameters can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:54:17: Error: Non-optional parameters can't have a default value. // Try removing the default value or making the parameter optional. // void g2(int a = 42, [int b]) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:53:15: Error: Non-optional parameters can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:55:15: Error: Non-optional parameters can't have a default value. // Try removing the default value or making the parameter optional. // f2 = (int a = 42, [int b]) {}; // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:48:15: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:50:15: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // void g({int a, required int b = 42}) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:48:31: Error: Named parameter 'b' is required and can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:50:31: Error: Named parameter 'b' is required and can't have a default value. // void g({int a, required int b = 42}) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:49:13: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:51:13: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // f = ({int a, required int b = 42}) {}; // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:49:29: Error: Named parameter 'b' is required and can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:51:29: Error: Named parameter 'b' is required and can't have a default value. // f = ({int a, required int b = 42}) {}; // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:52:28: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:54:28: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // void g2(int a = 42, [int b]) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:53:26: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:55:26: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // f2 = (int a = 42, [int b]) {}; // ^ @@ -74,7 +59,7 @@ class Class extends core::Object { synthetic constructor •() → self::Class : super core::Object::•() ; - method method({core::int a = #C1, required core::int b, required final core::int c, required covariant-by-declaration final core::int d}) → dynamic {} + method method({core::int a = #C1, required core::int b, required covariant-by-declaration core::int c}) → dynamic {} } abstract class A extends core::Object { synthetic constructor •() → self::A @@ -95,7 +80,7 @@ class C extends self::A { method foo({core::int x = #C1}) → dynamic {} } static field ({a: core::int, required b: core::int}) → dynamic field = ({core::int a = #C1, required core::int b}) → Null {}; -static method method({core::int a = #C1, required core::int b, required final core::int c}) → dynamic {} +static method method({core::int a = #C1, required core::int b, required core::int c}) → dynamic {} static method ok() → dynamic { ({a: core::int, required b: core::int}) → dynamic f; function g({core::int a = #C1, required core::int b}) → void {} diff --git a/pkg/front_end/testcases/nnbd/required_2.dart.strong.outline.expect b/pkg/front_end/testcases/nnbd/required_2.dart.strong.outline.expect index ff0b8bfee65..f40b106cb2d 100644 --- a/pkg/front_end/testcases/nnbd/required_2.dart.strong.outline.expect +++ b/pkg/front_end/testcases/nnbd/required_2.dart.strong.outline.expect @@ -2,22 +2,7 @@ library; // // Problems in library: // -// pkg/front_end/testcases/nnbd/required_2.dart:5:46: Error: Can't have modifier 'final' here. -// Try removing 'final'. -// method({int a = 42, required int b, required final int c}) {} -// ^^^^^ -// -// pkg/front_end/testcases/nnbd/required_2.dart:11:18: Error: Can't have modifier 'final' here. -// Try removing 'final'. -// required final int c, -// ^^^^^ -// -// pkg/front_end/testcases/nnbd/required_2.dart:12:28: Error: Can't have modifier 'final' here. -// Try removing 'final'. -// required covariant final int d}) {} -// ^^^^^ -// -// pkg/front_end/testcases/nnbd/required_2.dart:29:8: Error: The parameter 'x' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:31:8: Error: The parameter 'x' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // foo({x}) {} // ^ @@ -30,7 +15,7 @@ typedef Typedef2 = ({a: core::int, required b: core::int}) → dynamic; class Class extends core::Object { synthetic constructor •() → self::Class ; - method method({core::int a = 42, required core::int b, required final core::int c, required covariant-by-declaration final core::int d}) → dynamic + method method({core::int a = 42, required core::int b, required covariant-by-declaration core::int c}) → dynamic ; } abstract class A extends core::Object { @@ -51,7 +36,7 @@ class C extends self::A { ; } static field ({a: core::int, required b: core::int}) → dynamic field; -static method method({has-declared-initializer core::int a, required core::int b, required final core::int c}) → dynamic +static method method({has-declared-initializer core::int a, required core::int b, required core::int c}) → dynamic ; static method ok() → dynamic ; diff --git a/pkg/front_end/testcases/nnbd/required_2.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/required_2.dart.strong.transformed.expect index 73b44ed1e25..9f2b5ea1f4d 100644 --- a/pkg/front_end/testcases/nnbd/required_2.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/nnbd/required_2.dart.strong.transformed.expect @@ -2,65 +2,50 @@ library; // // Problems in library: // -// pkg/front_end/testcases/nnbd/required_2.dart:5:46: Error: Can't have modifier 'final' here. -// Try removing 'final'. -// method({int a = 42, required int b, required final int c}) {} -// ^^^^^ -// -// pkg/front_end/testcases/nnbd/required_2.dart:11:18: Error: Can't have modifier 'final' here. -// Try removing 'final'. -// required final int c, -// ^^^^^ -// -// pkg/front_end/testcases/nnbd/required_2.dart:12:28: Error: Can't have modifier 'final' here. -// Try removing 'final'. -// required covariant final int d}) {} -// ^^^^^ -// -// pkg/front_end/testcases/nnbd/required_2.dart:29:8: Error: The parameter 'x' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:31:8: Error: The parameter 'x' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // foo({x}) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:51:18: Error: Non-optional parameters can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:53:18: Error: Non-optional parameters can't have a default value. // Try removing the default value or making the parameter optional. // Function(int a = 42, [int b]) f2; // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:52:17: Error: Non-optional parameters can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:54:17: Error: Non-optional parameters can't have a default value. // Try removing the default value or making the parameter optional. // void g2(int a = 42, [int b]) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:53:15: Error: Non-optional parameters can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:55:15: Error: Non-optional parameters can't have a default value. // Try removing the default value or making the parameter optional. // f2 = (int a = 42, [int b]) {}; // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:48:15: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:50:15: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // void g({int a, required int b = 42}) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:48:31: Error: Named parameter 'b' is required and can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:50:31: Error: Named parameter 'b' is required and can't have a default value. // void g({int a, required int b = 42}) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:49:13: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:51:13: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // f = ({int a, required int b = 42}) {}; // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:49:29: Error: Named parameter 'b' is required and can't have a default value. +// pkg/front_end/testcases/nnbd/required_2.dart:51:29: Error: Named parameter 'b' is required and can't have a default value. // f = ({int a, required int b = 42}) {}; // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:52:28: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:54:28: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // void g2(int a = 42, [int b]) {} // ^ // -// pkg/front_end/testcases/nnbd/required_2.dart:53:26: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// pkg/front_end/testcases/nnbd/required_2.dart:55:26: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. // Try adding either an explicit non-'null' default value or the 'required' modifier. // f2 = (int a = 42, [int b]) {}; // ^ @@ -74,7 +59,7 @@ class Class extends core::Object { synthetic constructor •() → self::Class : super core::Object::•() ; - method method({core::int a = #C1, required core::int b, required final core::int c, required covariant-by-declaration final core::int d}) → dynamic {} + method method({core::int a = #C1, required core::int b, required covariant-by-declaration core::int c}) → dynamic {} } abstract class A extends core::Object { synthetic constructor •() → self::A @@ -95,7 +80,7 @@ class C extends self::A { method foo({core::int x = #C1}) → dynamic {} } static field ({a: core::int, required b: core::int}) → dynamic field = ({core::int a = #C1, required core::int b}) → Null {}; -static method method({core::int a = #C1, required core::int b, required final core::int c}) → dynamic {} +static method method({core::int a = #C1, required core::int b, required core::int c}) → dynamic {} static method ok() → dynamic { ({a: core::int, required b: core::int}) → dynamic f; function g({core::int a = #C1, required core::int b}) → void {} diff --git a/pkg/front_end/testcases/nnbd/required_2.dart.textual_outline.expect b/pkg/front_end/testcases/nnbd/required_2.dart.textual_outline.expect index 91a53296053..8545ed4b727 100644 --- a/pkg/front_end/testcases/nnbd/required_2.dart.textual_outline.expect +++ b/pkg/front_end/testcases/nnbd/required_2.dart.textual_outline.expect @@ -1,7 +1,7 @@ -method({int a = 42, required int b, required final int c}) {} +method({int a = 42, required int b, required int c}) {} class Class { - method( {int a = 42, required int b, required final int c, required covariant final int d}) {} + method({int a = 42, required int b, required covariant int c}) {} } typedef Typedef1 = Function({int a, required int b}); diff --git a/pkg/front_end/testcases/nnbd/required_2.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/nnbd/required_2.dart.textual_outline_modelled.expect index 68e4b50c105..cab7ee45ac7 100644 --- a/pkg/front_end/testcases/nnbd/required_2.dart.textual_outline_modelled.expect +++ b/pkg/front_end/testcases/nnbd/required_2.dart.textual_outline_modelled.expect @@ -13,14 +13,14 @@ class C extends A { } class Class { - method( {int a = 42, required int b, required final int c, required covariant final int d}) {} + method({int a = 42, required int b, required covariant int c}) {} } error() {} main() {} -method({int a = 42, required int b, required final int c}) {} +method({int a = 42, required int b, required int c}) {} ok() {} diff --git a/pkg/front_end/testcases/nnbd/required_2_legacy.dart b/pkg/front_end/testcases/nnbd/required_2_legacy.dart new file mode 100644 index 00000000000..28d13f92b01 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/required_2_legacy.dart @@ -0,0 +1,59 @@ +// Copyright (c) 2026, 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. + +// Version prior to primary constructors, to allow `final` in parameters. +// @dart=3.11 + +method({int a = 42, required int b, required final int c}) {} + +class Class { + method( + {int a = 42, + required int b, + required final int c, + required covariant final int d}) {} +} + +// TODO(johnniwinther): Pass the required property to the function types. +typedef Typedef1 = Function({int a, required int b}); + +typedef Typedef2({int a, required int b}); + +Function({int a, required int b}) field = ({int a = 42, required int b}) {}; + +abstract class A { + // It's ok to omit the default values in abstract members. + foo({int x}); +} + +class B extends A { + // This is an implementation and it should have the default value. + foo({x}) {} +} + +class C extends A { + foo({x = 42}) {} +} + +ok() { + Function({int a, required int b}) f; + void g({int a = 42, required int b}) {} + f = ({int a = 42, required int b}) {}; + + Function(int a, [int b]) f2; + void g2(int a, [int b = 42]) {} + f2 = (int a, [int b = 42]) {}; +} + +error() { + Function({int a, required int b}) f; + void g({int a, required int b = 42}) {} + f = ({int a, required int b = 42}) {}; + + Function(int a = 42, [int b]) f2; + void g2(int a = 42, [int b]) {} + f2 = (int a = 42, [int b]) {}; +} + +main() {} diff --git a/pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.expect b/pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.expect new file mode 100644 index 00000000000..984a1ea5fb3 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.expect @@ -0,0 +1,105 @@ +library; +// +// Problems in library: +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:32:8: Error: The parameter 'x' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// foo({x}) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:54:18: Error: Non-optional parameters can't have a default value. +// Try removing the default value or making the parameter optional. +// Function(int a = 42, [int b]) f2; +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:55:17: Error: Non-optional parameters can't have a default value. +// Try removing the default value or making the parameter optional. +// void g2(int a = 42, [int b]) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:56:15: Error: Non-optional parameters can't have a default value. +// Try removing the default value or making the parameter optional. +// f2 = (int a = 42, [int b]) {}; +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:51:15: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// void g({int a, required int b = 42}) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:51:31: Error: Named parameter 'b' is required and can't have a default value. +// void g({int a, required int b = 42}) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:52:13: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// f = ({int a, required int b = 42}) {}; +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:52:29: Error: Named parameter 'b' is required and can't have a default value. +// f = ({int a, required int b = 42}) {}; +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:55:28: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// void g2(int a = 42, [int b]) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:56:26: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// f2 = (int a = 42, [int b]) {}; +// ^ +// +import self as self; +import "dart:core" as core; + +typedef Typedef1 = ({a: core::int, required b: core::int}) → dynamic; +typedef Typedef2 = ({a: core::int, required b: core::int}) → dynamic; +class Class extends core::Object { + synthetic constructor •() → self::Class + : super core::Object::•() + ; + method method({core::int a = #C1, required core::int b, required final core::int c, required covariant-by-declaration final core::int d}) → dynamic {} +} +abstract class A extends core::Object { + synthetic constructor •() → self::A + : super core::Object::•() + ; + abstract method foo({core::int x = #C2}) → dynamic; +} +class B extends self::A { + synthetic constructor •() → self::B + : super self::A::•() + ; + method foo({erroneously-initialized core::int x = #C2}) → dynamic {} +} +class C extends self::A { + synthetic constructor •() → self::C + : super self::A::•() + ; + method foo({core::int x = #C1}) → dynamic {} +} +static field ({a: core::int, required b: core::int}) → dynamic field = ({core::int a = #C1, required core::int b}) → Null {}; +static method method({core::int a = #C1, required core::int b, required final core::int c}) → dynamic {} +static method ok() → dynamic { + ({a: core::int, required b: core::int}) → dynamic f; + function g({core::int a = #C1, required core::int b}) → void {} + f = ({core::int a = #C1, required core::int b}) → Null {}; + (core::int, [core::int]) → dynamic f2; + function g2(core::int a, [core::int b = #C1]) → void {} + f2 = (core::int a, [core::int b = #C1]) → Null {}; +} +static method error() → dynamic { + ({a: core::int, required b: core::int}) → dynamic f; + function g({erroneously-initialized core::int a = #C2, required core::int b = #C1}) → void {} + f = ({erroneously-initialized core::int a = #C2, required core::int b = #C1}) → Null {}; + (core::int, [core::int]) → dynamic f2; + function g2(core::int a = #C1, [erroneously-initialized core::int b = #C2]) → void {} + f2 = (core::int a = #C1, [erroneously-initialized core::int b = #C2]) → Null {}; +} +static method main() → dynamic {} + +constants { + #C1 = 42 + #C2 = null +} diff --git a/pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.modular.expect b/pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.modular.expect new file mode 100644 index 00000000000..984a1ea5fb3 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.modular.expect @@ -0,0 +1,105 @@ +library; +// +// Problems in library: +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:32:8: Error: The parameter 'x' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// foo({x}) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:54:18: Error: Non-optional parameters can't have a default value. +// Try removing the default value or making the parameter optional. +// Function(int a = 42, [int b]) f2; +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:55:17: Error: Non-optional parameters can't have a default value. +// Try removing the default value or making the parameter optional. +// void g2(int a = 42, [int b]) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:56:15: Error: Non-optional parameters can't have a default value. +// Try removing the default value or making the parameter optional. +// f2 = (int a = 42, [int b]) {}; +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:51:15: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// void g({int a, required int b = 42}) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:51:31: Error: Named parameter 'b' is required and can't have a default value. +// void g({int a, required int b = 42}) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:52:13: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// f = ({int a, required int b = 42}) {}; +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:52:29: Error: Named parameter 'b' is required and can't have a default value. +// f = ({int a, required int b = 42}) {}; +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:55:28: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// void g2(int a = 42, [int b]) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:56:26: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// f2 = (int a = 42, [int b]) {}; +// ^ +// +import self as self; +import "dart:core" as core; + +typedef Typedef1 = ({a: core::int, required b: core::int}) → dynamic; +typedef Typedef2 = ({a: core::int, required b: core::int}) → dynamic; +class Class extends core::Object { + synthetic constructor •() → self::Class + : super core::Object::•() + ; + method method({core::int a = #C1, required core::int b, required final core::int c, required covariant-by-declaration final core::int d}) → dynamic {} +} +abstract class A extends core::Object { + synthetic constructor •() → self::A + : super core::Object::•() + ; + abstract method foo({core::int x = #C2}) → dynamic; +} +class B extends self::A { + synthetic constructor •() → self::B + : super self::A::•() + ; + method foo({erroneously-initialized core::int x = #C2}) → dynamic {} +} +class C extends self::A { + synthetic constructor •() → self::C + : super self::A::•() + ; + method foo({core::int x = #C1}) → dynamic {} +} +static field ({a: core::int, required b: core::int}) → dynamic field = ({core::int a = #C1, required core::int b}) → Null {}; +static method method({core::int a = #C1, required core::int b, required final core::int c}) → dynamic {} +static method ok() → dynamic { + ({a: core::int, required b: core::int}) → dynamic f; + function g({core::int a = #C1, required core::int b}) → void {} + f = ({core::int a = #C1, required core::int b}) → Null {}; + (core::int, [core::int]) → dynamic f2; + function g2(core::int a, [core::int b = #C1]) → void {} + f2 = (core::int a, [core::int b = #C1]) → Null {}; +} +static method error() → dynamic { + ({a: core::int, required b: core::int}) → dynamic f; + function g({erroneously-initialized core::int a = #C2, required core::int b = #C1}) → void {} + f = ({erroneously-initialized core::int a = #C2, required core::int b = #C1}) → Null {}; + (core::int, [core::int]) → dynamic f2; + function g2(core::int a = #C1, [erroneously-initialized core::int b = #C2]) → void {} + f2 = (core::int a = #C1, [erroneously-initialized core::int b = #C2]) → Null {}; +} +static method main() → dynamic {} + +constants { + #C1 = 42 + #C2 = null +} diff --git a/pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.outline.expect b/pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.outline.expect new file mode 100644 index 00000000000..a1d8b88fa99 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.outline.expect @@ -0,0 +1,46 @@ +library; +// +// Problems in library: +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:32:8: Error: The parameter 'x' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// foo({x}) {} +// ^ +// +import self as self; +import "dart:core" as core; + +typedef Typedef1 = ({a: core::int, required b: core::int}) → dynamic; +typedef Typedef2 = ({a: core::int, required b: core::int}) → dynamic; +class Class extends core::Object { + synthetic constructor •() → self::Class + ; + method method({core::int a = 42, required core::int b, required final core::int c, required covariant-by-declaration final core::int d}) → dynamic + ; +} +abstract class A extends core::Object { + synthetic constructor •() → self::A + ; + abstract method foo({core::int x = null}) → dynamic; +} +class B extends self::A { + synthetic constructor •() → self::B + ; + method foo({erroneously-initialized core::int x = null}) → dynamic + ; +} +class C extends self::A { + synthetic constructor •() → self::C + ; + method foo({core::int x = 42}) → dynamic + ; +} +static field ({a: core::int, required b: core::int}) → dynamic field; +static method method({has-declared-initializer core::int a, required core::int b, required final core::int c}) → dynamic + ; +static method ok() → dynamic + ; +static method error() → dynamic + ; +static method main() → dynamic + ; diff --git a/pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.transformed.expect b/pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.transformed.expect new file mode 100644 index 00000000000..984a1ea5fb3 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/required_2_legacy.dart.strong.transformed.expect @@ -0,0 +1,105 @@ +library; +// +// Problems in library: +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:32:8: Error: The parameter 'x' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// foo({x}) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:54:18: Error: Non-optional parameters can't have a default value. +// Try removing the default value or making the parameter optional. +// Function(int a = 42, [int b]) f2; +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:55:17: Error: Non-optional parameters can't have a default value. +// Try removing the default value or making the parameter optional. +// void g2(int a = 42, [int b]) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:56:15: Error: Non-optional parameters can't have a default value. +// Try removing the default value or making the parameter optional. +// f2 = (int a = 42, [int b]) {}; +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:51:15: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// void g({int a, required int b = 42}) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:51:31: Error: Named parameter 'b' is required and can't have a default value. +// void g({int a, required int b = 42}) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:52:13: Error: The parameter 'a' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// f = ({int a, required int b = 42}) {}; +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:52:29: Error: Named parameter 'b' is required and can't have a default value. +// f = ({int a, required int b = 42}) {}; +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:55:28: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// void g2(int a = 42, [int b]) {} +// ^ +// +// pkg/front_end/testcases/nnbd/required_2_legacy.dart:56:26: Error: The parameter 'b' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'. +// Try adding either an explicit non-'null' default value or the 'required' modifier. +// f2 = (int a = 42, [int b]) {}; +// ^ +// +import self as self; +import "dart:core" as core; + +typedef Typedef1 = ({a: core::int, required b: core::int}) → dynamic; +typedef Typedef2 = ({a: core::int, required b: core::int}) → dynamic; +class Class extends core::Object { + synthetic constructor •() → self::Class + : super core::Object::•() + ; + method method({core::int a = #C1, required core::int b, required final core::int c, required covariant-by-declaration final core::int d}) → dynamic {} +} +abstract class A extends core::Object { + synthetic constructor •() → self::A + : super core::Object::•() + ; + abstract method foo({core::int x = #C2}) → dynamic; +} +class B extends self::A { + synthetic constructor •() → self::B + : super self::A::•() + ; + method foo({erroneously-initialized core::int x = #C2}) → dynamic {} +} +class C extends self::A { + synthetic constructor •() → self::C + : super self::A::•() + ; + method foo({core::int x = #C1}) → dynamic {} +} +static field ({a: core::int, required b: core::int}) → dynamic field = ({core::int a = #C1, required core::int b}) → Null {}; +static method method({core::int a = #C1, required core::int b, required final core::int c}) → dynamic {} +static method ok() → dynamic { + ({a: core::int, required b: core::int}) → dynamic f; + function g({core::int a = #C1, required core::int b}) → void {} + f = ({core::int a = #C1, required core::int b}) → Null {}; + (core::int, [core::int]) → dynamic f2; + function g2(core::int a, [core::int b = #C1]) → void {} + f2 = (core::int a, [core::int b = #C1]) → Null {}; +} +static method error() → dynamic { + ({a: core::int, required b: core::int}) → dynamic f; + function g({erroneously-initialized core::int a = #C2, required core::int b = #C1}) → void {} + f = ({erroneously-initialized core::int a = #C2, required core::int b = #C1}) → Null {}; + (core::int, [core::int]) → dynamic f2; + function g2(core::int a = #C1, [erroneously-initialized core::int b = #C2]) → void {} + f2 = (core::int a = #C1, [erroneously-initialized core::int b = #C2]) → Null {}; +} +static method main() → dynamic {} + +constants { + #C1 = 42 + #C2 = null +} diff --git a/pkg/front_end/testcases/nnbd/required_2_legacy.dart.textual_outline.expect b/pkg/front_end/testcases/nnbd/required_2_legacy.dart.textual_outline.expect new file mode 100644 index 00000000000..024d0e7ec99 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/required_2_legacy.dart.textual_outline.expect @@ -0,0 +1,31 @@ +// @dart = 3.11 + +method({int a = 42, required int b, required final int c}) {} + +class Class { + method( {int a = 42, required int b, required final int c, required covariant final int d}) {} +} + +typedef Typedef1 = Function({int a, required int b}); + +typedef Typedef2({int a, required int b}); + +Function({int a, required int b}) field = ({int a = 42, required int b}) {}; + +abstract class A { + foo({int x}); +} + +class B extends A { + foo({x}) {} +} + +class C extends A { + foo({x = 42}) {} +} + +ok() {} + +error() {} + +main() {} diff --git a/pkg/front_end/testcases/nnbd/required_2_legacy.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/nnbd/required_2_legacy.dart.textual_outline_modelled.expect new file mode 100644 index 00000000000..30424319187 --- /dev/null +++ b/pkg/front_end/testcases/nnbd/required_2_legacy.dart.textual_outline_modelled.expect @@ -0,0 +1,36 @@ +// @dart = 3.11 + +Function({int a, required int b}) field = ({int a = 42, required int b}) {}; + +abstract class A { + foo({int x}); +} + +class B extends A { + foo({x}) {} +} + +class C extends A { + foo({x = 42}) {} +} + +class Class { + method({ + int a = 42, + required int b, + required final int c, + required covariant final int d, + }) {} +} + +error() {} + +main() {} + +method({int a = 42, required int b, required final int c}) {} + +ok() {} + +typedef Typedef1 = Function({int a, required int b}); + +typedef Typedef2({int a, required int b}); diff --git a/pkg/front_end/tool/coverage_merger.dart b/pkg/front_end/tool/coverage_merger.dart index 81dd693aa64..5b63702dd03 100644 --- a/pkg/front_end/tool/coverage_merger.dart +++ b/pkg/front_end/tool/coverage_merger.dart @@ -444,7 +444,7 @@ CoverageInfo _process( } } - void addChunk(int from, final int to) { + void addChunk(int from, int to) { if (addAndRemoveCommentsInFiles && removeFrom.isNotEmpty) { int fromIndex = binarySearch(removeFrom, from); if (removeFrom[fromIndex] < from && removeTo[fromIndex] < from) { @@ -970,9 +970,9 @@ class AstIndexerAndIgnoreCollector extends AstIndexer { /// If there is not it will add a note to add one if that makes sense (in that /// there is possible coverage but no actual coverage). bool _checkCommentAndIgnoreCoverageWithBeginAndEnd( - final Token tokenWithPossibleComment, - final Token beginToken, - final Token endToken, { + Token tokenWithPossibleComment, + Token beginToken, + Token endToken, { required bool allowReplace, bool isBlock = false, bool allowOnBraceStart = false, diff --git a/pkg/front_end/tool/coverage_runner.dart b/pkg/front_end/tool/coverage_runner.dart index f4e46d6a3b9..c669b7f4945 100644 --- a/pkg/front_end/tool/coverage_runner.dart +++ b/pkg/front_end/tool/coverage_runner.dart @@ -10,7 +10,7 @@ import '../test/vm_service_helper.dart'; Uri? coverageUri; -Future main(final List args) async { +Future main(List args) async { String? coverage = Platform.environment["CFE_COVERAGE"]; if (coverage != null) { coverageUri = Uri.base.resolveUri(Uri.file(coverage)); diff --git a/pkg/frontend_server/lib/resident_frontend_server_utils.dart b/pkg/frontend_server/lib/resident_frontend_server_utils.dart index 4e86563929b..3bafef87420 100644 --- a/pkg/frontend_server/lib/resident_frontend_server_utils.dart +++ b/pkg/frontend_server/lib/resident_frontend_server_utils.dart @@ -57,7 +57,7 @@ typedef CachedDillAndCompilerOptionsPaths = ({ /// Returns the absolute paths to the cached kernel file and the cached compiler /// options file associated with [canonicalizedLibraryPath]. CachedDillAndCompilerOptionsPaths computeCachedDillAndCompilerOptionsPaths( - final String canonicalizedLibraryPath, + String canonicalizedLibraryPath, ) { final String dirname = path.dirname(canonicalizedLibraryPath); final String basename = path.basename(canonicalizedLibraryPath); diff --git a/pkg/frontend_server/lib/src/resident_frontend_server.dart b/pkg/frontend_server/lib/src/resident_frontend_server.dart index 7638636b7ea..9b3fe96cb7d 100644 --- a/pkg/frontend_server/lib/src/resident_frontend_server.dart +++ b/pkg/frontend_server/lib/src/resident_frontend_server.dart @@ -368,9 +368,9 @@ class ResidentFrontendServer { /// entrypoint. This function also writes [compileOptions.arguments] to /// [cachedCompilerOptions] as a JSON list. static ResidentCompiler _getResidentCompilerForEntrypoint({ - required final String canonicalizedLibraryPath, - required final ArgResults compileOptions, - required final File cachedCompilerOptions, + required String canonicalizedLibraryPath, + required ArgResults compileOptions, + required File cachedCompilerOptions, }) { cachedCompilerOptions.createSync(); cachedCompilerOptions.writeAsStringSync( diff --git a/pkg/js_ast/lib/src/builder.dart b/pkg/js_ast/lib/src/builder.dart index db9aa882bad..ba0168b0ed8 100644 --- a/pkg/js_ast/lib/src/builder.dart +++ b/pkg/js_ast/lib/src/builder.dart @@ -196,7 +196,7 @@ class JsBuilder { /// [arguments] can be a single [Node] (e.g. an [Expression] or [Statement]) /// or a list of [Node]s, which will be interpolated into the source at the /// '#' signs. - Expression call(String source, [var arguments]) { + Expression call(String source, [arguments]) { Template template = _findExpressionTemplate(source); arguments ??= []; // We allow a single argument to be given directly. @@ -205,7 +205,7 @@ class JsBuilder { } /// Parses a JavaScript Statement, otherwise just like [call]. - Statement statement(String source, [var arguments]) { + Statement statement(String source, [arguments]) { Template template = _findStatementTemplate(source); arguments ??= []; // We allow a single argument to be given directly. diff --git a/pkg/kernel/bin/size_breakdown.dart b/pkg/kernel/bin/size_breakdown.dart index 759ec68bba4..31801f939a3 100755 --- a/pkg/kernel/bin/size_breakdown.dart +++ b/pkg/kernel/bin/size_breakdown.dart @@ -38,7 +38,7 @@ void main(args) { } class WrappedBinaryBuilder extends BinaryBuilder { - WrappedBinaryBuilder(var _bytes) : super(_bytes, disableLazyReading: true); + WrappedBinaryBuilder(_bytes) : super(_bytes, disableLazyReading: true); int offsetsSize = 0; int stringTableSize = 0; int linkTableSize = 0; diff --git a/pkg/kernel/bin/switch_order.dart b/pkg/kernel/bin/switch_order.dart index 171ca8ee5db..57b0809c9ec 100755 --- a/pkg/kernel/bin/switch_order.dart +++ b/pkg/kernel/bin/switch_order.dart @@ -157,7 +157,7 @@ class WrappedBinaryBuilder extends BinaryBuilder { List statementTypes = List.filled(255, 0); List typeTypes = List.filled(255, 0); - WrappedBinaryBuilder(var _bytes) + WrappedBinaryBuilder(_bytes) : super( _bytes, disableLazyReading: true, diff --git a/pkg/observatory/lib/object_graph.dart b/pkg/observatory/lib/object_graph.dart index d8a21448598..9492ece4bf0 100644 --- a/pkg/observatory/lib/object_graph.dart +++ b/pkg/observatory/lib/object_graph.dart @@ -1657,7 +1657,7 @@ class _SnapshotGraph implements SnapshotGraph { var workStack = _newUint32Array(N); var workStackTop = 0; - mergeChildrenAndSort(var parent1, var end) { + mergeChildrenAndSort(parent1, end) { assert(parent1 != _SENTINEL); if (next[parent1] == end) return; diff --git a/pkg/observatory/lib/src/app/view_model.dart b/pkg/observatory/lib/src/app/view_model.dart index f210e137d72..6c55e7d6614 100644 --- a/pkg/observatory/lib/src/app/view_model.dart +++ b/pkg/observatory/lib/src/app/view_model.dart @@ -30,7 +30,7 @@ class SortedTable { SortedTable(this.columns); int _sortColumnIndex = 0; - set sortColumnIndex(var index) { + set sortColumnIndex(index) { assert(index >= 0); assert(index < columns.length); _sortColumnIndex = index; @@ -39,7 +39,7 @@ class SortedTable { int get sortColumnIndex => _sortColumnIndex; bool _sortDescending = true; bool get sortDescending => _sortDescending; - set sortDescending(var descending) { + set sortDescending(descending) { _sortDescending = descending; } diff --git a/pkg/observatory/lib/src/elements/nav/reload.dart b/pkg/observatory/lib/src/elements/nav/reload.dart index a2deff672bb..2021146f4a2 100644 --- a/pkg/observatory/lib/src/elements/nav/reload.dart +++ b/pkg/observatory/lib/src/elements/nav/reload.dart @@ -91,7 +91,7 @@ class NavReloadElement extends CustomElement implements Renderable { } else { final List content = _isolates.reloadSourcesServices .map( - (final s) => + (s) => (new HTMLLIElement()..appendChild( new HTMLButtonElement() ..textContent = s.alias diff --git a/pkg/observatory/lib/src/elements/script_inset.dart b/pkg/observatory/lib/src/elements/script_inset.dart index 2db79e5f34e..022803c5057 100644 --- a/pkg/observatory/lib/src/elements/script_inset.dart +++ b/pkg/observatory/lib/src/elements/script_inset.dart @@ -965,7 +965,7 @@ class ScriptInsetElement extends CustomElement implements Renderable { } var position = 0; - consumeUntil(var stop) { + consumeUntil(stop) { if (stop <= position) { return null; // Empty gap between annotations/boundaries. } diff --git a/pkg/observatory/lib/src/service/object.dart b/pkg/observatory/lib/src/service/object.dart index 058d0730e02..d6ab0c0ecc6 100644 --- a/pkg/observatory/lib/src/service/object.dart +++ b/pkg/observatory/lib/src/service/object.dart @@ -2065,12 +2065,12 @@ class Isolate extends ServiceObjectOwner implements M.Isolate { return invokeRpc('_getRetainedSize', params); } - Future getRetainingPath(ServiceObject target, var limit) { + Future getRetainingPath(ServiceObject target, limit) { Map params = {'targetId': target.id, 'limit': limit.toString()}; return invokeRpc('getRetainingPath', params); } - Future getInboundReferences(ServiceObject target, var limit) { + Future getInboundReferences(ServiceObject target, limit) { Map params = {'targetId': target.id, 'limit': limit.toString()}; return invokeRpc('getInboundReferences', params); } @@ -2080,7 +2080,7 @@ class Isolate extends ServiceObjectOwner implements M.Isolate { return invokeRpc('_getTypeArgumentsList', params); } - Future getInstances(Class cls, var limit) { + Future getInstances(Class cls, limit) { Map params = {'objectId': cls.id, 'limit': limit.toString()}; return invokeRpc('getInstances', params); } diff --git a/pkg/test_runner/lib/src/testing_servers.dart b/pkg/test_runner/lib/src/testing_servers.dart index 955b550e681..75e76f5983f 100644 --- a/pkg/test_runner/lib/src/testing_servers.dart +++ b/pkg/test_runner/lib/src/testing_servers.dart @@ -243,7 +243,7 @@ class TestingServers { void _handleUploadRequest(HttpRequest request) async { try { - var builder = await request.fold(BytesBuilder(), (dynamic b, var d) { + var builder = await request.fold(BytesBuilder(), (dynamic b, d) { b.add(d); return b; }); @@ -368,8 +368,7 @@ class TestingServers { // of policies via js-interop, and is tested by // tests/lib/js/static_interop_test/import/import_trustedscripturl_test "require-trusted-types-for: 'script'", - "trusted-types dart.deferred-loading scriptUrl" - , + "trusted-types dart.deferred-loading scriptUrl", ].join('; '); for (var header in [ "Content-Security-Policy", diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/bench_is_prime.dart b/pkg/vm/testcases/transformations/type_flow/transformer/bench_is_prime.dart index 8b9f12dbff4..9b48a43d72c 100644 --- a/pkg/vm/testcases/transformations/type_flow/transformer/bench_is_prime.dart +++ b/pkg/vm/testcases/transformations/type_flow/transformer/bench_is_prime.dart @@ -1,4 +1,4 @@ -bool isPrime(var n) { +bool isPrime(n) { if (n < 2) return false; for (var i = 2; i * i <= n; i++) { if (n % i == 0) return false; diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/extension_type.dart b/pkg/vm/testcases/transformations/type_flow/transformer/extension_type.dart index 257c6abd730..0a7c2b00d57 100644 --- a/pkg/vm/testcases/transformations/type_flow/transformer/extension_type.dart +++ b/pkg/vm/testcases/transformations/type_flow/transformer/extension_type.dart @@ -33,13 +33,13 @@ class C4 { extension type SomeExtensionType(int foo) {} class Run { - void execute(final List list) { + void execute(List list) { // Should be unchecked. } } void testTypeCheckRemoval() { - final list = List.generate(10, (final a) => SomeExtensionType(a)); + final list = List.generate(10, (a) => SomeExtensionType(a)); final obj = Run(); obj.execute(list); } diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/extension_type.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/extension_type.dart.expect index 24b06af0bcf..7ecc10969a9 100644 --- a/pkg/vm/testcases/transformations/type_flow/transformer/extension_type.dart.expect +++ b/pkg/vm/testcases/transformations/type_flow/transformer/extension_type.dart.expect @@ -22,7 +22,7 @@ class Run extends core::Object { [@vm.inferred-return-type.metadata=dart.core::Null? (value: null)] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:3,getterSelectorId:4] - method execute([@vm.inferred-arg-type.metadata=dart.core::_GrowableList (skip check)] covariant-by-class final core::List list) → void {} + method execute([@vm.inferred-arg-type.metadata=dart.core::_GrowableList (skip check)] covariant-by-class core::List list) → void {} } abstract class C5 extends core::Object { } @@ -63,7 +63,7 @@ static extension-type-member method SomeExtensionType|constructor#([@vm.inferred [@vm.inferred-return-type.metadata=dart.core::Null? (value: null)] static method testTypeCheckRemoval() → void { - final core::List list = [@vm.inferred-type.metadata=dart.core::_GrowableList] core::_GrowableList::generate(10, (final core::int a) → self::SomeExtensionType% /* erasure=core::int, declared=! */ => [@vm.inferred-type.metadata=int] self::SomeExtensionType|constructor#(a)); + final core::List list = [@vm.inferred-type.metadata=dart.core::_GrowableList] core::_GrowableList::generate(10, (core::int a) → self::SomeExtensionType% /* erasure=core::int, declared=! */ => [@vm.inferred-type.metadata=int] self::SomeExtensionType|constructor#(a)); final self::Run obj = new self::Run::•(); [@vm.call-site-attributes.metadata=receiverType:#lib::Run<#lib::SomeExtensionType>] [@vm.direct-call.metadata=#lib::Run.execute] [@vm.inferred-type.metadata=? (skip check)] obj.{self::Run::execute}(list){(core::List) → void}; } diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_while_processing.dart b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_while_processing.dart index 14518115fc9..1c7d316ddc8 100644 --- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_while_processing.dart +++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_while_processing.dart @@ -23,7 +23,7 @@ class Point { Point newPoint2() => new Point(x); } -getX(var point) { +getX(point) { point.x; } diff --git a/pkg/vm_service/test/get_stack_test.dart b/pkg/vm_service/test/get_stack_test.dart index a6ddec1ec43..c479fbd1b02 100644 --- a/pkg/vm_service/test/get_stack_test.dart +++ b/pkg/vm_service/test/get_stack_test.dart @@ -46,15 +46,15 @@ Future func10() async { } void expectFrame( - final frame, - final kindExpectation, - final codeNameExpectation, + frame, + kindExpectation, + codeNameExpectation, ) { expect(frame.kind, kindExpectation); expect(frame.code?.name, codeNameExpectation); } -void expectFrames(final frames, final expectKindAndCodeName) { +void expectFrames(frames, expectKindAndCodeName) { for (int i = 0; i < expectKindAndCodeName.length; i++) { expectFrame( frames[i],