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

Commit ddbeaab

Browse files
author
Dart CI
committed
Version 2.11.0-181.0.dev
Merge commit '6a1c54ec302854a8b13d03ca5b9a6463b4a82df2' into 'dev'
2 parents 0ed6ae6 + 6a1c54e commit ddbeaab

File tree

474 files changed

+14701
-1253
lines changed

Some content is hidden

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

474 files changed

+14701
-1253
lines changed

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ vars = {
4444
# co19 is a cipd package. Use update.sh in tests/co19[_2] to update these
4545
# hashes. It requires access to the dart-build-access group, which EngProd
4646
# has.
47-
"co19_rev": "58e95961ea492a749ca6eccf5586fdf8271f8266",
47+
"co19_rev": "53dd55a31d345320a6aa2b6eea0467f868b72377",
4848
"co19_2_rev": "e48b3090826cf40b8037648f19d211e8eab1b4b6",
4949

5050
# The internal benchmarks to use. See go/dart-benchmarks-internal

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,12 +1525,11 @@ class FlowModel<Variable, Type> {
15251525
return _identicalOrNew(this, other, newReachable, newVariableInfo);
15261526
}
15271527

1528-
/// Updates the state to indicate whether the control flow path is
1529-
/// [reachable].
1530-
FlowModel<Variable, Type> setReachable(bool reachable) {
1531-
if (this.reachable == reachable) return this;
1528+
/// Updates the state to indicate that the control flow path is unreachable.
1529+
FlowModel<Variable, Type> setUnreachable() {
1530+
if (!reachable) return this;
15321531

1533-
return new FlowModel<Variable, Type>.withInfo(reachable, variableInfo);
1532+
return new FlowModel<Variable, Type>.withInfo(false, variableInfo);
15341533
}
15351534

15361535
@override
@@ -2547,7 +2546,7 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
25472546

25482547
@override
25492548
void booleanLiteral(Expression expression, bool value) {
2550-
FlowModel<Variable, Type> unreachable = _current.setReachable(false);
2549+
FlowModel<Variable, Type> unreachable = _current.setUnreachable();
25512550
_storeExpressionInfo(
25522551
expression,
25532552
value
@@ -2676,7 +2675,7 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
26762675
@override
26772676
void for_bodyBegin(Statement node, Expression condition) {
26782677
ExpressionInfo<Variable, Type> conditionInfo = condition == null
2679-
? new ExpressionInfo(_current, _current, _current.setReachable(false))
2678+
? new ExpressionInfo(_current, _current, _current.setUnreachable())
26802679
: _expressionEnd(condition);
26812680
_WhileContext<Variable, Type> context =
26822681
new _WhileContext<Variable, Type>(conditionInfo);
@@ -2755,11 +2754,9 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
27552754
void functionExpression_end() {
27562755
--_functionNestingLevel;
27572756
assert(_functionNestingLevel >= 0);
2758-
FlowModel<Variable, Type> afterBody = _current;
27592757
_SimpleContext<Variable, Type> context =
27602758
_stack.removeLast() as _SimpleContext<Variable, Type>;
27612759
_current = context._previous;
2762-
_current = _current.joinUnassigned(afterBody);
27632760
}
27642761

27652762
@override
@@ -2768,7 +2765,7 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
27682765
if (context != null) {
27692766
context._breakModel = _join(context._breakModel, _current);
27702767
}
2771-
_current = _current.setReachable(false);
2768+
_current = _current.setUnreachable();
27722769
}
27732770

27742771
@override
@@ -2777,12 +2774,12 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
27772774
if (context != null) {
27782775
context._continueModel = _join(context._continueModel, _current);
27792776
}
2780-
_current = _current.setReachable(false);
2777+
_current = _current.setUnreachable();
27812778
}
27822779

27832780
@override
27842781
void handleExit() {
2785-
_current = _current.setReachable(false);
2782+
_current = _current.setUnreachable();
27862783
}
27872784

27882785
@override

pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart

Lines changed: 66 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,33 +1194,32 @@ const MessageCode messageConstEvalContext =
11941194
const Template<
11951195
Message Function(
11961196
String
1197-
name)> templateConstEvalDeferredLibrary = const Template<
1198-
Message Function(String name)>(
1197+
nameOKEmpty)> templateConstEvalDeferredLibrary = const Template<
1198+
Message Function(String nameOKEmpty)>(
11991199
messageTemplate:
1200-
r"""'#name' can't be used in a constant expression because it's marked as 'deferred' which means it isn't available until loaded.""",
1200+
r"""'#nameOKEmpty' can't be used in a constant expression because it's marked as 'deferred' which means it isn't available until loaded.""",
12011201
tipTemplate:
12021202
r"""Try moving the constant from the deferred library, or removing 'deferred' from the import.
12031203
""",
12041204
withArguments: _withArgumentsConstEvalDeferredLibrary);
12051205

12061206
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
1207-
const Code<Message Function(String name)> codeConstEvalDeferredLibrary =
1208-
const Code<Message Function(String name)>(
1207+
const Code<Message Function(String nameOKEmpty)> codeConstEvalDeferredLibrary =
1208+
const Code<Message Function(String nameOKEmpty)>(
12091209
"ConstEvalDeferredLibrary", templateConstEvalDeferredLibrary,
12101210
analyzerCodes: <String>[
12111211
"NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY"
12121212
]);
12131213

12141214
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
1215-
Message _withArgumentsConstEvalDeferredLibrary(String name) {
1216-
if (name.isEmpty) throw 'No name provided';
1217-
name = demangleMixinApplicationName(name);
1215+
Message _withArgumentsConstEvalDeferredLibrary(String nameOKEmpty) {
1216+
if (nameOKEmpty == null || nameOKEmpty.isEmpty) nameOKEmpty = '(unnamed)';
12181217
return new Message(codeConstEvalDeferredLibrary,
12191218
message:
1220-
"""'${name}' can't be used in a constant expression because it's marked as 'deferred' which means it isn't available until loaded.""",
1219+
"""'${nameOKEmpty}' can't be used in a constant expression because it's marked as 'deferred' which means it isn't available until loaded.""",
12211220
tip: """Try moving the constant from the deferred library, or removing 'deferred' from the import.
12221221
""",
1223-
arguments: {'name': name});
1222+
arguments: {'nameOKEmpty': nameOKEmpty});
12241223
}
12251224

12261225
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
@@ -1243,53 +1242,53 @@ const MessageCode messageConstEvalFailedAssertion = const MessageCode(
12431242
message: r"""This assertion failed.""");
12441243

12451244
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
1246-
const Template<Message Function(String string)>
1245+
const Template<Message Function(String stringOKEmpty)>
12471246
templateConstEvalFailedAssertionWithMessage =
1248-
const Template<Message Function(String string)>(
1249-
messageTemplate: r"""This assertion failed with message: #string""",
1247+
const Template<Message Function(String stringOKEmpty)>(
1248+
messageTemplate:
1249+
r"""This assertion failed with message: #stringOKEmpty""",
12501250
withArguments: _withArgumentsConstEvalFailedAssertionWithMessage);
12511251

12521252
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
1253-
const Code<Message Function(String string)>
1253+
const Code<Message Function(String stringOKEmpty)>
12541254
codeConstEvalFailedAssertionWithMessage =
1255-
const Code<Message Function(String string)>(
1255+
const Code<Message Function(String stringOKEmpty)>(
12561256
"ConstEvalFailedAssertionWithMessage",
12571257
templateConstEvalFailedAssertionWithMessage,
12581258
analyzerCodes: <String>["CONST_EVAL_THROWS_EXCEPTION"]);
12591259

12601260
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
1261-
Message _withArgumentsConstEvalFailedAssertionWithMessage(String string) {
1262-
if (string.isEmpty) throw 'No string provided';
1261+
Message _withArgumentsConstEvalFailedAssertionWithMessage(
1262+
String stringOKEmpty) {
1263+
if (stringOKEmpty == null || stringOKEmpty.isEmpty) stringOKEmpty = '(empty)';
12631264
return new Message(codeConstEvalFailedAssertionWithMessage,
1264-
message: """This assertion failed with message: ${string}""",
1265-
arguments: {'string': string});
1265+
message: """This assertion failed with message: ${stringOKEmpty}""",
1266+
arguments: {'stringOKEmpty': stringOKEmpty});
12661267
}
12671268

12681269
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
1269-
const Template<
1270-
Message Function(
1271-
String
1272-
name)> templateConstEvalInvalidStaticInvocation = const Template<
1273-
Message Function(String name)>(
1274-
messageTemplate:
1275-
r"""The invocation of '#name' is not allowed in a constant expression.""",
1276-
withArguments: _withArgumentsConstEvalInvalidStaticInvocation);
1270+
const Template<Message Function(String nameOKEmpty)>
1271+
templateConstEvalInvalidStaticInvocation =
1272+
const Template<Message Function(String nameOKEmpty)>(
1273+
messageTemplate:
1274+
r"""The invocation of '#nameOKEmpty' is not allowed in a constant expression.""",
1275+
withArguments: _withArgumentsConstEvalInvalidStaticInvocation);
12771276

12781277
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
1279-
const Code<Message Function(String name)> codeConstEvalInvalidStaticInvocation =
1280-
const Code<Message Function(String name)>(
1278+
const Code<Message Function(String nameOKEmpty)>
1279+
codeConstEvalInvalidStaticInvocation =
1280+
const Code<Message Function(String nameOKEmpty)>(
12811281
"ConstEvalInvalidStaticInvocation",
12821282
templateConstEvalInvalidStaticInvocation,
12831283
analyzerCodes: <String>["CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE"]);
12841284

12851285
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
1286-
Message _withArgumentsConstEvalInvalidStaticInvocation(String name) {
1287-
if (name.isEmpty) throw 'No name provided';
1288-
name = demangleMixinApplicationName(name);
1286+
Message _withArgumentsConstEvalInvalidStaticInvocation(String nameOKEmpty) {
1287+
if (nameOKEmpty == null || nameOKEmpty.isEmpty) nameOKEmpty = '(unnamed)';
12891288
return new Message(codeConstEvalInvalidStaticInvocation,
12901289
message:
1291-
"""The invocation of '${name}' is not allowed in a constant expression.""",
1292-
arguments: {'name': name});
1290+
"""The invocation of '${nameOKEmpty}' is not allowed in a constant expression.""",
1291+
arguments: {'nameOKEmpty': nameOKEmpty});
12931292
}
12941293

12951294
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
@@ -1328,27 +1327,27 @@ Message _withArgumentsConstEvalNegativeShift(
13281327
const Template<
13291328
Message Function(
13301329
String
1331-
string)> templateConstEvalNonConstantVariableGet = const Template<
1332-
Message Function(String string)>(
1330+
nameOKEmpty)> templateConstEvalNonConstantVariableGet = const Template<
1331+
Message Function(String nameOKEmpty)>(
13331332
messageTemplate:
1334-
r"""The variable '#string' is not a constant, only constant expressions are allowed.""",
1333+
r"""The variable '#nameOKEmpty' is not a constant, only constant expressions are allowed.""",
13351334
withArguments: _withArgumentsConstEvalNonConstantVariableGet);
13361335

13371336
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
1338-
const Code<Message Function(String string)>
1337+
const Code<Message Function(String nameOKEmpty)>
13391338
codeConstEvalNonConstantVariableGet =
1340-
const Code<Message Function(String string)>(
1339+
const Code<Message Function(String nameOKEmpty)>(
13411340
"ConstEvalNonConstantVariableGet",
13421341
templateConstEvalNonConstantVariableGet,
13431342
analyzerCodes: <String>["NON_CONSTANT_VALUE_IN_INITIALIZER"]);
13441343

13451344
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
1346-
Message _withArgumentsConstEvalNonConstantVariableGet(String string) {
1347-
if (string.isEmpty) throw 'No string provided';
1345+
Message _withArgumentsConstEvalNonConstantVariableGet(String nameOKEmpty) {
1346+
if (nameOKEmpty == null || nameOKEmpty.isEmpty) nameOKEmpty = '(unnamed)';
13481347
return new Message(codeConstEvalNonConstantVariableGet,
13491348
message:
1350-
"""The variable '${string}' is not a constant, only constant expressions are allowed.""",
1351-
arguments: {'string': string});
1349+
"""The variable '${nameOKEmpty}' is not a constant, only constant expressions are allowed.""",
1350+
arguments: {'nameOKEmpty': nameOKEmpty});
13521351
}
13531352

13541353
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
@@ -5820,6 +5819,30 @@ Message _withArgumentsLanguageVersionTooHigh(int count, int count2) {
58205819
arguments: {'count': count, 'count2': count2});
58215820
}
58225821

5822+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
5823+
const Template<Message Function(String name)>
5824+
templateLateDefinitelyAssignedError =
5825+
const Template<Message Function(String name)>(
5826+
messageTemplate:
5827+
r"""Late final variable '#name' definitely assigned.""",
5828+
withArguments: _withArgumentsLateDefinitelyAssignedError);
5829+
5830+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
5831+
const Code<Message Function(String name)> codeLateDefinitelyAssignedError =
5832+
const Code<Message Function(String name)>(
5833+
"LateDefinitelyAssignedError",
5834+
templateLateDefinitelyAssignedError,
5835+
);
5836+
5837+
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
5838+
Message _withArgumentsLateDefinitelyAssignedError(String name) {
5839+
if (name.isEmpty) throw 'No name provided';
5840+
name = demangleMixinApplicationName(name);
5841+
return new Message(codeLateDefinitelyAssignedError,
5842+
message: """Late final variable '${name}' definitely assigned.""",
5843+
arguments: {'name': name});
5844+
}
5845+
58235846
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
58245847
const Template<
58255848
Message Function(
@@ -6621,32 +6644,6 @@ const MessageCode messageNonInstanceTypeVariableUse = const MessageCode(
66216644
analyzerCodes: <String>["TYPE_PARAMETER_REFERENCED_BY_STATIC"],
66226645
message: r"""Can only use type variables in instance methods.""");
66236646

6624-
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
6625-
const Template<Message Function(String name)>
6626-
templateNonNullableLateDefinitelyAssignedError =
6627-
const Template<Message Function(String name)>(
6628-
messageTemplate:
6629-
r"""Non-nullable late final variable '#name' definitely assigned.""",
6630-
withArguments: _withArgumentsNonNullableLateDefinitelyAssignedError);
6631-
6632-
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
6633-
const Code<Message Function(String name)>
6634-
codeNonNullableLateDefinitelyAssignedError =
6635-
const Code<Message Function(String name)>(
6636-
"NonNullableLateDefinitelyAssignedError",
6637-
templateNonNullableLateDefinitelyAssignedError,
6638-
);
6639-
6640-
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
6641-
Message _withArgumentsNonNullableLateDefinitelyAssignedError(String name) {
6642-
if (name.isEmpty) throw 'No name provided';
6643-
name = demangleMixinApplicationName(name);
6644-
return new Message(codeNonNullableLateDefinitelyAssignedError,
6645-
message:
6646-
"""Non-nullable late final variable '${name}' definitely assigned.""",
6647-
arguments: {'name': name});
6648-
}
6649-
66506647
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
66516648
const Template<
66526649
Message Function(
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
test() {
6+
late int x;
7+
late int y;
8+
var f = () => x;
9+
int z0 = /*unassigned*/ x;
10+
int z1 = /*unassigned*/ y;
11+
x = 3;
12+
y = 3;
13+
}

pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,32 @@ main() {
10141014
});
10151015
});
10161016

1017+
test(
1018+
'functionExpression_end does not propagate "definitely unassigned" data',
1019+
() {
1020+
var h = _Harness();
1021+
var x = h.addVar('x', 'int');
1022+
var functionNode = _Node();
1023+
h.assignedVariables((vars) {
1024+
vars.function(functionNode, () {});
1025+
vars.write(x);
1026+
});
1027+
h.run((flow) {
1028+
flow.declare(x, false);
1029+
expect(flow.isUnassigned(x), true);
1030+
flow.functionExpression_begin(functionNode);
1031+
// The function expression could be called at any time, so x might be
1032+
// assigned now.
1033+
expect(flow.isUnassigned(x), false);
1034+
flow.functionExpression_end();
1035+
// But now that we are back outside the function expression, we once
1036+
// again know that x is unassigned.
1037+
expect(flow.isUnassigned(x), true);
1038+
flow.write(x, _Type('int'));
1039+
expect(flow.isUnassigned(x), false);
1040+
});
1041+
});
1042+
10171043
test('ifNullExpression allows ensure guarding', () {
10181044
var h = _Harness();
10191045
var x = h.addVar('x', 'int?');
@@ -2189,24 +2215,22 @@ main() {
21892215
var intQVar = _Var('x', _Type('int?'));
21902216
var objectQVar = _Var('x', _Type('Object?'));
21912217
var nullVar = _Var('x', _Type('Null'));
2192-
group('setReachable', () {
2218+
group('setUnreachable', () {
21932219
var unreachable = FlowModel<_Var, _Type>(false);
21942220
var reachable = FlowModel<_Var, _Type>(true);
21952221
test('unchanged', () {
2196-
expect(unreachable.setReachable(false), same(unreachable));
2197-
expect(reachable.setReachable(true), same(reachable));
2222+
expect(unreachable.setUnreachable(), same(unreachable));
21982223
});
21992224

22002225
test('changed', () {
2201-
void _check(FlowModel<_Var, _Type> initial, bool newReachability) {
2202-
var s = initial.setReachable(newReachability);
2226+
void _check(FlowModel<_Var, _Type> initial) {
2227+
var s = initial.setUnreachable();
22032228
expect(s, isNot(same(initial)));
2204-
expect(s.reachable, newReachability);
2229+
expect(s.reachable, false);
22052230
expect(s.variableInfo, same(initial.variableInfo));
22062231
}
22072232

2208-
_check(unreachable, true);
2209-
_check(reachable, false);
2233+
_check(reachable);
22102234
});
22112235
});
22122236

@@ -2927,7 +2951,7 @@ main() {
29272951
test('reachability', () {
29282952
var h = _Harness();
29292953
var reachable = FlowModel<_Var, _Type>(true);
2930-
var unreachable = reachable.setReachable(false);
2954+
var unreachable = reachable.setUnreachable();
29312955
expect(reachable.restrict(h, reachable, Set()), same(reachable));
29322956
expect(reachable.restrict(h, unreachable, Set()), same(unreachable));
29332957
expect(unreachable.restrict(h, unreachable, Set()), same(unreachable));

0 commit comments

Comments
 (0)