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

Commit f596cf7

Browse files
author
Dart CI
committed
Version 2.13.0-125.0.dev
Merge commit '39550008d664b90fc67271c540cd0daf9127d0f5' into 'dev'
2 parents abcf1f3 + 3955000 commit f596cf7

File tree

74 files changed

+4445
-3531
lines changed

Some content is hidden

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

74 files changed

+4445
-3531
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,14 @@ class PlainAndColorizedString {
166166
final String plain;
167167
final String colorized;
168168

169+
@override
170+
String toString() {
171+
assert(false, "Called PlainAndColorizedString.toString: $plain");
172+
return 'PlainAndColorizedString:$plain';
173+
}
174+
169175
const PlainAndColorizedString(this.plain, this.colorized);
176+
170177
const PlainAndColorizedString.plainOnly(this.plain) : this.colorized = plain;
171178
}
172179

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ const Code<Null> codeConstEvalUnevaluated = messageConstEvalUnevaluated;
15141514
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
15151515
const MessageCode messageConstEvalUnevaluated = const MessageCode(
15161516
"ConstEvalUnevaluated",
1517-
message: r"""Could not evaluate constant expression.""");
1517+
message: r"""Couldn't evaluate constant expression.""");
15181518

15191519
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
15201520
const Template<
@@ -4051,7 +4051,7 @@ const MessageCode messageFieldInitializerOutsideConstructor = const MessageCode(
40514051
const Template<Message Function(String name)> templateFieldNotPromoted =
40524052
const Template<Message Function(String name)>(
40534053
messageTemplate:
4054-
r"""'#name' refers to a property so it could not be promoted.""",
4054+
r"""'#name' refers to a property so it couldn't be promoted.""",
40554055
withArguments: _withArgumentsFieldNotPromoted);
40564056

40574057
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
@@ -4065,8 +4065,7 @@ Message _withArgumentsFieldNotPromoted(String name) {
40654065
if (name.isEmpty) throw 'No name provided';
40664066
name = demangleMixinApplicationName(name);
40674067
return new Message(codeFieldNotPromoted,
4068-
message:
4069-
"""'${name}' refers to a property so it could not be promoted.""",
4068+
message: """'${name}' refers to a property so it couldn't be promoted.""",
40704069
arguments: {'name': name});
40714070
}
40724071

@@ -7710,11 +7709,10 @@ Message _withArgumentsOverrideTypeVariablesMismatch(String name, String name2) {
77107709
}
77117710

77127711
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
7713-
const Template<
7714-
Message Function(String name, Uri uri_)> templatePackageNotFound =
7712+
const Template<Message Function(String name, Uri uri_)>
7713+
templatePackageNotFound =
77157714
const Template<Message Function(String name, Uri uri_)>(
7716-
messageTemplate:
7717-
r"""Could not resolve the package '#name' in '#uri'.""",
7715+
messageTemplate: r"""Couldn't resolve the package '#name' in '#uri'.""",
77187716
withArguments: _withArgumentsPackageNotFound);
77197717

77207718
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
@@ -7729,7 +7727,7 @@ Message _withArgumentsPackageNotFound(String name, Uri uri_) {
77297727
name = demangleMixinApplicationName(name);
77307728
String? uri = relativizeUri(uri_);
77317729
return new Message(codePackageNotFound,
7732-
message: """Could not resolve the package '${name}' in '${uri}'.""",
7730+
message: """Couldn't resolve the package '${name}' in '${uri}'.""",
77337731
arguments: {'name': name, 'uri': uri_});
77347732
}
77357733

pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_mini_ast.dart

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
1010
import 'package:test/test.dart';
1111

12+
import '../mini_types.dart';
13+
1214
Expression get nullLiteral => new _NullLiteral();
1315

1416
Statement assert_(Expression condition, [Expression? message]) =>
@@ -623,40 +625,6 @@ class SwitchCase implements _Visitable<void> {
623625
}
624626
}
625627

626-
/// Representation of a type in the pseudo-Dart language used for flow analysis
627-
/// testing. This is essentially a thin wrapper around a string representation
628-
/// of the type.
629-
class Type {
630-
static bool _allowComparisons = false;
631-
632-
final String type;
633-
634-
Type(this.type);
635-
636-
@override
637-
int get hashCode {
638-
if (!_allowComparisons) {
639-
// The flow analysis engine should not hash types using hashCode. It
640-
// should compare them using TypeOperations.
641-
fail('Unexpected use of operator== on types');
642-
}
643-
return type.hashCode;
644-
}
645-
646-
@override
647-
bool operator ==(Object other) {
648-
if (!_allowComparisons) {
649-
// The flow analysis engine should not compare types using operator==. It
650-
// should compare them using TypeOperations.
651-
fail('Unexpected use of operator== on types');
652-
}
653-
return other is Type && this.type == other.type;
654-
}
655-
656-
@override
657-
String toString() => type;
658-
}
659-
660628
/// Representation of a local variable in the pseudo-Dart language used for flow
661629
/// analysis testing.
662630
class Var {
@@ -1744,13 +1712,9 @@ class _WhyNotPromoted extends Expression {
17441712
Harness h, FlowAnalysis<Node, Statement, Expression, Var, Type> flow) {
17451713
var type = target._visit(h, flow);
17461714
flow.forwardExpression(this, target);
1747-
assert(!Type._allowComparisons);
1748-
Type._allowComparisons = true;
1749-
try {
1715+
Type.withComparisonsAllowed(() {
17501716
callback(flow.whyNotPromoted(this));
1751-
} finally {
1752-
Type._allowComparisons = false;
1753-
}
1717+
});
17541718
return type;
17551719
}
17561720
}
@@ -1771,13 +1735,9 @@ class _WhyNotPromoted_ImplicitThis extends Statement {
17711735
@override
17721736
void _visit(
17731737
Harness h, FlowAnalysis<Node, Statement, Expression, Var, Type> flow) {
1774-
assert(!Type._allowComparisons);
1775-
Type._allowComparisons = true;
1776-
try {
1738+
Type.withComparisonsAllowed(() {
17771739
callback(flow.whyNotPromotedImplicitThis(staticType));
1778-
} finally {
1779-
Type._allowComparisons = false;
1780-
}
1740+
});
17811741
}
17821742
}
17831743

pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart';
66
import 'package:test/test.dart';
77

8+
import '../mini_types.dart';
89
import 'flow_analysis_mini_ast.dart';
910

1011
main() {

pkg/_fe_analyzer_shared/test/flow_analysis/why_not_promoted/data/for_in_loop_type_not_iterable_nullability_error.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
// `ForInLoopTypeNotIterablePartNullability` errors, for which we wish to report
88
// "why not promoted" context information.
99

10-
// TODO(paulberry): get this to work with the CFE and add additional test cases
11-
// if needed.
12-
1310
class C1 {
1411
List<int>? bad;
1512
}
@@ -18,5 +15,5 @@ test(C1 c) {
1815
if (c.bad == null) return;
1916
for (var x
2017
in /*analyzer.notPromoted(propertyNotPromoted(target: member:C1.bad, type: List<int>?))*/ c
21-
.bad) {}
18+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C1.bad, type: List<int>?))*/ bad) {}
2219
}

pkg/_fe_analyzer_shared/test/flow_analysis/why_not_promoted/data/invalid_assignment_error_nullability_error.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@
77
// `InvalidAssignmentErrorPartNullability` errors, for which we wish to report
88
// "why not promoted" context information.
99

10-
// TODO(paulberry): get this to work with the CFE and add additional test cases
11-
// if needed.
12-
1310
class C1 {
1411
List<int>? bad;
1512
}
1613

1714
test(C1 c) sync* {
1815
if (c.bad == null) return;
1916
yield* /*analyzer.notPromoted(propertyNotPromoted(target: member:C1.bad, type: List<int>?))*/ c
20-
.bad;
17+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C1.bad, type: List<int>?))*/ bad;
2118
}

pkg/_fe_analyzer_shared/test/flow_analysis/why_not_promoted/data/nullable_spread_error.dart

Lines changed: 137 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,146 @@
66
// end's `NullableSpreadError` error, for which we wish to report "why not
77
// promoted" context information.
88

9-
// TODO(paulberry): get this to work with the CFE and add additional test cases
10-
// if needed.
9+
class C {
10+
List<int>? listQuestion;
11+
Object? objectQuestion;
12+
Set<int>? setQuestion;
13+
Map<int, int>? mapQuestion;
14+
}
15+
16+
list_from_list_question(C c) {
17+
if (c.listQuestion == null) return;
18+
return [
19+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.listQuestion, type: List<int>?))*/ c
20+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.listQuestion, type: List<int>?))*/ listQuestion
21+
];
22+
}
23+
24+
list_from_set_question(C c) {
25+
if (c.setQuestion == null) return;
26+
return [
27+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.setQuestion, type: Set<int>?))*/ c
28+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.setQuestion, type: Set<int>?))*/ setQuestion
29+
];
30+
}
1131

12-
class C1 {
13-
List<int>? bad;
32+
list_from_map_question(C c) {
33+
if (c.mapQuestion == null) return;
34+
return [
35+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.mapQuestion, type: Map<int, int>?))*/ c
36+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.mapQuestion, type: Map<int, int>?))*/ mapQuestion
37+
];
1438
}
1539

16-
test(C1 c) {
17-
if (c.bad == null) return;
40+
list_from_object_question(C c) {
41+
if (c.objectQuestion is! List<int>) return;
1842
return [
19-
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C1.bad, type: List<int>?))*/ c
20-
.bad
43+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.objectQuestion, type: Object?))*/ c
44+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.objectQuestion, type: Object?))*/ objectQuestion
2145
];
2246
}
47+
48+
set_from_list_question(C c) {
49+
if (c.listQuestion == null) return;
50+
return {
51+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.listQuestion, type: List<int>?))*/ c
52+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.listQuestion, type: List<int>?))*/ listQuestion
53+
};
54+
}
55+
56+
set_from_set_question(C c) {
57+
if (c.setQuestion == null) return;
58+
return {
59+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.setQuestion, type: Set<int>?))*/ c
60+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.setQuestion, type: Set<int>?))*/ setQuestion
61+
};
62+
}
63+
64+
set_from_map_question(C c) {
65+
if (c.mapQuestion == null) return;
66+
return {
67+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.mapQuestion, type: Map<int, int>?))*/ c
68+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.mapQuestion, type: Map<int, int>?))*/ mapQuestion
69+
};
70+
}
71+
72+
set_from_object_question_type_disambiguate_by_entry(C c) {
73+
if (c.objectQuestion is! Set<int>) return;
74+
return {
75+
null,
76+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.objectQuestion, type: Object?))*/ c
77+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.objectQuestion, type: Object?))*/ objectQuestion
78+
};
79+
}
80+
81+
set_from_object_question_type_disambiguate_by_previous_spread(C c) {
82+
if (c.objectQuestion is! Set<int>) return;
83+
return {
84+
...<int>{},
85+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.objectQuestion, type: Object?))*/ c
86+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.objectQuestion, type: Object?))*/ objectQuestion
87+
};
88+
}
89+
90+
set_from_object_question_type_disambiguate_by_literal_args(C c) {
91+
if (c.objectQuestion is! Set<int>) return;
92+
return <int>{
93+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.objectQuestion, type: Object?))*/ c
94+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.objectQuestion, type: Object?))*/ objectQuestion
95+
};
96+
}
97+
98+
map_from_list_question(C c) {
99+
if (c.listQuestion == null) return;
100+
return {
101+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.listQuestion, type: List<int>?))*/ c
102+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.listQuestion, type: List<int>?))*/ listQuestion
103+
};
104+
}
105+
106+
map_from_set_question(C c) {
107+
if (c.setQuestion == null) return;
108+
return {
109+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.setQuestion, type: Set<int>?))*/ c
110+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.setQuestion, type: Set<int>?))*/ setQuestion
111+
};
112+
}
113+
114+
map_from_map_question(C c) {
115+
if (c.mapQuestion == null) return;
116+
return {
117+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.mapQuestion, type: Map<int, int>?))*/ c
118+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.mapQuestion, type: Map<int, int>?))*/ mapQuestion
119+
};
120+
}
121+
122+
map_from_object_question_type_disambiguate_by_key_value_pair(C c) {
123+
if (c.objectQuestion is! Map<int, int>) return;
124+
return {
125+
null: null,
126+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.objectQuestion, type: Object?))*/ c
127+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.objectQuestion, type: Object?))*/ objectQuestion
128+
};
129+
}
130+
131+
map_from_object_question_type_disambiguate_by_previous_spread(C c) {
132+
if (c.objectQuestion is! Map<int, int>) return;
133+
return {
134+
...<int, int>{},
135+
... /*analyzer.notPromoted(propertyNotPromoted(target: member:C.objectQuestion, type: Object?))*/ c
136+
. /*cfe.notPromoted(propertyNotPromoted(target: member:C.objectQuestion, type: Object?))*/ objectQuestion
137+
};
138+
}
139+
140+
map_from_set_question_type_disambiguate_by_literal_args(C c) {
141+
// Note: analyzer shows "why not promoted" information here, but CFE doesn't.
142+
// That's probably ok, since there are two problems here (set/map mismatch and
143+
// null safety); it's a matter of interpretation whether to prioritize one or
144+
// the other.
145+
if (c.setQuestion == null) return;
146+
return <int, int>{
147+
...
148+
/*analyzer.notPromoted(propertyNotPromoted(target: member:C.setQuestion, type: Set<int>?))*/ c
149+
.setQuestion
150+
};
151+
}

0 commit comments

Comments
 (0)