Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a37a4d4

Browse files
author
Dart CI
committed
Version 2.12.0-112.0.dev
Merge commit '442fa7f44e52b1323ecbcae0db18c4bed9146e34' into 'dev'
2 parents 1ea90aa + 442fa7f commit a37a4d4

File tree

53 files changed

+571
-334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+571
-334
lines changed

pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,9 +1286,6 @@ class FlowModel<Variable, Type> {
12861286
/// variable that is no longer in scope.
12871287
final Map<Variable, VariableModel<Variable, Type> /*!*/ > variableInfo;
12881288

1289-
/// Variable model for variables that have never been seen before.
1290-
final VariableModel<Variable, Type> _freshVariableInfo;
1291-
12921289
/// The empty map, used to [join] variables.
12931290
final Map<Variable, VariableModel<Variable, Type>> _emptyVariableMap = {};
12941291

@@ -1302,8 +1299,7 @@ class FlowModel<Variable, Type> {
13021299
);
13031300

13041301
@visibleForTesting
1305-
FlowModel.withInfo(this.reachable, this.variableInfo)
1306-
: _freshVariableInfo = new VariableModel.fresh() {
1302+
FlowModel.withInfo(this.reachable, this.variableInfo) {
13071303
assert(reachable != null);
13081304
assert(() {
13091305
for (VariableModel<Variable, Type> value in variableInfo.values) {
@@ -1376,17 +1372,15 @@ class FlowModel<Variable, Type> {
13761372
/// A local variable is [initialized] if its declaration has an initializer.
13771373
/// A function parameter is always initialized, so [initialized] is `true`.
13781374
FlowModel<Variable, Type> declare(Variable variable, bool initialized) {
1379-
VariableModel<Variable, Type> newInfoForVar = _freshVariableInfo;
1380-
if (initialized) {
1381-
newInfoForVar = newInfoForVar.initialize();
1382-
}
1375+
VariableModel<Variable, Type> newInfoForVar =
1376+
new VariableModel.fresh(assigned: initialized);
13831377

13841378
return _updateVariableInfo(variable, newInfoForVar);
13851379
}
13861380

13871381
/// Gets the info for the given [variable], creating it if it doesn't exist.
13881382
VariableModel<Variable, Type> infoFor(Variable variable) =>
1389-
variableInfo[variable] ?? _freshVariableInfo;
1383+
variableInfo[variable] ?? new VariableModel.fresh();
13901384

13911385
/// Builds a [FlowModel] based on `this`, but extending the `tested` set to
13921386
/// include types from [other]. This is used at the bottom of certain kinds
@@ -2060,11 +2054,10 @@ class VariableModel<Variable, Type> {
20602054

20612055
/// Creates a [VariableModel] representing a variable that's never been seen
20622056
/// before.
2063-
VariableModel.fresh()
2057+
VariableModel.fresh({this.assigned = false})
20642058
: promotedTypes = null,
20652059
tested = const [],
2066-
assigned = false,
2067-
unassigned = true,
2060+
unassigned = !assigned,
20682061
writeCaptured = false;
20692062

20702063
/// Returns a new [VariableModel] in which any promotions present have been
@@ -2077,16 +2070,6 @@ class VariableModel<Variable, Type> {
20772070
null, tested, assigned, false, writeCaptured);
20782071
}
20792072

2080-
/// Returns a new [VariableModel] reflecting the fact that the variable was
2081-
/// just initialized.
2082-
VariableModel<Variable, Type> initialize() {
2083-
if (promotedTypes == null && tested.isEmpty && assigned && !unassigned) {
2084-
return this;
2085-
}
2086-
return new VariableModel<Variable, Type>(
2087-
null, const [], true, false, writeCaptured);
2088-
}
2089-
20902073
/// Returns an updated model reflect a control path that is known to have
20912074
/// previously passed through some [other] state. See [FlowModel.restrict]
20922075
/// for details.

pkg/front_end/lib/src/fasta/fasta_codes_cfe_generated.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3936,7 +3936,9 @@ const Template<
39363936
Message Function(
39373937
String name, DartType _type, bool isNonNullableByDefault)>(
39383938
messageTemplate:
3939-
r"""Optional parameter '#name' should have a default value because its type '#type' doesn't allow null.""",
3939+
r"""The parameter '#name' can't have a value of 'null' because of its type '#type', but the implicit default value is 'null'.""",
3940+
tipTemplate:
3941+
r"""Try adding either an explicit non-'null' default value or the 'required' modifier.""",
39403942
withArguments:
39413943
_withArgumentsOptionalNonNullableWithoutInitializerError);
39423944

@@ -3945,11 +3947,11 @@ const Code<
39453947
Message Function(
39463948
String name, DartType _type, bool isNonNullableByDefault)>
39473949
codeOptionalNonNullableWithoutInitializerError = const Code<
3948-
Message Function(
3949-
String name, DartType _type, bool isNonNullableByDefault)>(
3950-
"OptionalNonNullableWithoutInitializerError",
3951-
templateOptionalNonNullableWithoutInitializerError,
3952-
);
3950+
Message Function(
3951+
String name, DartType _type, bool isNonNullableByDefault)>(
3952+
"OptionalNonNullableWithoutInitializerError",
3953+
templateOptionalNonNullableWithoutInitializerError,
3954+
analyzerCodes: <String>["MISSING_DEFAULT_VALUE_FOR_PARAMETER"]);
39533955

39543956
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
39553957
Message _withArgumentsOptionalNonNullableWithoutInitializerError(
@@ -3961,8 +3963,9 @@ Message _withArgumentsOptionalNonNullableWithoutInitializerError(
39613963
String type = typeParts.join();
39623964
return new Message(codeOptionalNonNullableWithoutInitializerError,
39633965
message:
3964-
"""Optional parameter '${name}' should have a default value because its type '${type}' doesn't allow null.""" +
3966+
"""The parameter '${name}' can't have a value of 'null' because of its type '${type}', but the implicit default value is 'null'.""" +
39653967
labeler.originMessages,
3968+
tip: """Try adding either an explicit non-'null' default value or the 'required' modifier.""",
39663969
arguments: {'name': name, 'type': _type});
39673970
}
39683971

pkg/front_end/messages.status

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,6 @@ OperatorParameterMismatch1/example: Fail
629629
OperatorParameterMismatch2/example: Fail
630630
OperatorWithOptionalFormals/analyzerCode: Fail
631631
OperatorWithOptionalFormals/example: Fail
632-
OptionalNonNullableWithoutInitializerError/analyzerCode: Fail
633-
OptionalNonNullableWithoutInitializerWarning/analyzerCode: Fail
634632
OverrideFewerNamedArguments/example: Fail
635633
OverrideFewerPositionalArguments/example: Fail
636634
OverrideMismatchNamedParameter/example: Fail

pkg/front_end/messages.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4585,7 +4585,9 @@ ValueForRequiredParameterNotProvidedError:
45854585
template: "Required named parameter '#name' must be provided."
45864586

45874587
OptionalNonNullableWithoutInitializerError:
4588-
template: "Optional parameter '#name' should have a default value because its type '#type' doesn't allow null."
4588+
template: "The parameter '#name' can't have a value of 'null' because of its type '#type', but the implicit default value is 'null'."
4589+
tip: "Try adding either an explicit non-'null' default value or the 'required' modifier."
4590+
analyzerCode: MISSING_DEFAULT_VALUE_FOR_PARAMETER
45894591
configuration: nnbd-strong
45904592
script:
45914593
- method1({int a}) {}

pkg/front_end/testcases/general/constants/with_unevaluated_agnostic/various.dart.outline.expect

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ library /*isNonNullableByDefault*/;
2222
// const Class.method(T t) : this(-t);
2323
// ^
2424
//
25-
// pkg/front_end/testcases/general/constants/with_unevaluated_agnostic/various.dart:123:27: Error: Optional parameter 'named' should have a default value because its type 'int' doesn't allow null.
25+
// pkg/front_end/testcases/general/constants/with_unevaluated_agnostic/various.dart:123:27: Error: The parameter 'named' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'.
26+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
2627
// int procedure(int i, {int named}) => i;
2728
// ^^^^^
2829
//

pkg/front_end/testcases/general/constants/with_unevaluated_agnostic/various.dart.strong.expect

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ library /*isNonNullableByDefault*/;
2222
// const Class.method(T t) : this(-t);
2323
// ^
2424
//
25-
// pkg/front_end/testcases/general/constants/with_unevaluated_agnostic/various.dart:123:27: Error: Optional parameter 'named' should have a default value because its type 'int' doesn't allow null.
25+
// pkg/front_end/testcases/general/constants/with_unevaluated_agnostic/various.dart:123:27: Error: The parameter 'named' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'.
26+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
2627
// int procedure(int i, {int named}) => i;
2728
// ^^^^^
2829
//

pkg/front_end/testcases/general/constants/with_unevaluated_agnostic/various.dart.strong.transformed.expect

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ library /*isNonNullableByDefault*/;
2222
// const Class.method(T t) : this(-t);
2323
// ^
2424
//
25-
// pkg/front_end/testcases/general/constants/with_unevaluated_agnostic/various.dart:123:27: Error: Optional parameter 'named' should have a default value because its type 'int' doesn't allow null.
25+
// pkg/front_end/testcases/general/constants/with_unevaluated_agnostic/various.dart:123:27: Error: The parameter 'named' can't have a value of 'null' because of its type 'int', but the implicit default value is 'null'.
26+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
2627
// int procedure(int i, {int named}) => i;
2728
// ^^^^^
2829
//

pkg/front_end/testcases/nnbd/issue40954.dart.outline.expect

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,39 @@ library /*isNonNullableByDefault*/;
22
//
33
// Problems in library:
44
//
5-
// pkg/front_end/testcases/nnbd/issue40954.dart:8:31: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
5+
// pkg/front_end/testcases/nnbd/issue40954.dart:8:31: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
66
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
7+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
78
// static void test1(var v, [A a]) {}
89
// ^
910
//
10-
// pkg/front_end/testcases/nnbd/issue40954.dart:10:31: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
11+
// pkg/front_end/testcases/nnbd/issue40954.dart:10:31: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
1112
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
13+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
1214
// static void test2(var v, {A a}) {}
1315
// ^
1416
//
15-
// pkg/front_end/testcases/nnbd/issue40954.dart:12:25: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
17+
// pkg/front_end/testcases/nnbd/issue40954.dart:12:25: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
1618
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
19+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
1720
// void test11(var v, [A a]) {}
1821
// ^
1922
//
20-
// pkg/front_end/testcases/nnbd/issue40954.dart:14:25: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
23+
// pkg/front_end/testcases/nnbd/issue40954.dart:14:25: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
2124
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
25+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
2226
// void test22(var v, {A a}) {}
2327
// ^
2428
//
25-
// pkg/front_end/testcases/nnbd/issue40954.dart:17:22: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
29+
// pkg/front_end/testcases/nnbd/issue40954.dart:17:22: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
2630
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
31+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
2732
// void test1(var v, [A a]) {}
2833
// ^
2934
//
30-
// pkg/front_end/testcases/nnbd/issue40954.dart:19:22: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
35+
// pkg/front_end/testcases/nnbd/issue40954.dart:19:22: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
3136
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
37+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
3238
// void test2(var v, {A a}) {}
3339
// ^
3440
//

pkg/front_end/testcases/nnbd/issue40954.dart.strong.expect

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,39 @@ library /*isNonNullableByDefault*/;
22
//
33
// Problems in library:
44
//
5-
// pkg/front_end/testcases/nnbd/issue40954.dart:8:31: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
5+
// pkg/front_end/testcases/nnbd/issue40954.dart:8:31: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
66
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
7+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
78
// static void test1(var v, [A a]) {}
89
// ^
910
//
10-
// pkg/front_end/testcases/nnbd/issue40954.dart:10:31: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
11+
// pkg/front_end/testcases/nnbd/issue40954.dart:10:31: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
1112
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
13+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
1214
// static void test2(var v, {A a}) {}
1315
// ^
1416
//
15-
// pkg/front_end/testcases/nnbd/issue40954.dart:12:25: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
17+
// pkg/front_end/testcases/nnbd/issue40954.dart:12:25: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
1618
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
19+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
1720
// void test11(var v, [A a]) {}
1821
// ^
1922
//
20-
// pkg/front_end/testcases/nnbd/issue40954.dart:14:25: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
23+
// pkg/front_end/testcases/nnbd/issue40954.dart:14:25: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
2124
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
25+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
2226
// void test22(var v, {A a}) {}
2327
// ^
2428
//
25-
// pkg/front_end/testcases/nnbd/issue40954.dart:17:22: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
29+
// pkg/front_end/testcases/nnbd/issue40954.dart:17:22: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
2630
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
31+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
2732
// void test1(var v, [A a]) {}
2833
// ^
2934
//
30-
// pkg/front_end/testcases/nnbd/issue40954.dart:19:22: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
35+
// pkg/front_end/testcases/nnbd/issue40954.dart:19:22: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
3136
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
37+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
3238
// void test2(var v, {A a}) {}
3339
// ^
3440
//

pkg/front_end/testcases/nnbd/issue40954.dart.strong.transformed.expect

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,39 @@ library /*isNonNullableByDefault*/;
22
//
33
// Problems in library:
44
//
5-
// pkg/front_end/testcases/nnbd/issue40954.dart:8:31: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
5+
// pkg/front_end/testcases/nnbd/issue40954.dart:8:31: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
66
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
7+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
78
// static void test1(var v, [A a]) {}
89
// ^
910
//
10-
// pkg/front_end/testcases/nnbd/issue40954.dart:10:31: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
11+
// pkg/front_end/testcases/nnbd/issue40954.dart:10:31: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
1112
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
13+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
1214
// static void test2(var v, {A a}) {}
1315
// ^
1416
//
15-
// pkg/front_end/testcases/nnbd/issue40954.dart:12:25: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
17+
// pkg/front_end/testcases/nnbd/issue40954.dart:12:25: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
1618
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
19+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
1720
// void test11(var v, [A a]) {}
1821
// ^
1922
//
20-
// pkg/front_end/testcases/nnbd/issue40954.dart:14:25: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
23+
// pkg/front_end/testcases/nnbd/issue40954.dart:14:25: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
2124
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
25+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
2226
// void test22(var v, {A a}) {}
2327
// ^
2428
//
25-
// pkg/front_end/testcases/nnbd/issue40954.dart:17:22: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
29+
// pkg/front_end/testcases/nnbd/issue40954.dart:17:22: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
2630
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
31+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
2732
// void test1(var v, [A a]) {}
2833
// ^
2934
//
30-
// pkg/front_end/testcases/nnbd/issue40954.dart:19:22: Error: Optional parameter 'a' should have a default value because its type 'A' doesn't allow null.
35+
// pkg/front_end/testcases/nnbd/issue40954.dart:19:22: Error: The parameter 'a' can't have a value of 'null' because of its type 'A', but the implicit default value is 'null'.
3136
// - 'A' is from 'pkg/front_end/testcases/nnbd/issue40954.dart'.
37+
// Try adding either an explicit non-'null' default value or the 'required' modifier.
3238
// void test2(var v, {A a}) {}
3339
// ^
3440
//

0 commit comments

Comments
 (0)