Skip to content

Commit f3ed888

Browse files
authored
Fixes #3275. Update the tests so that ?.id is expected to be parsed as ? C.id. (#3277)
Update the tests so that `?.id` is expected to be parsed as `? C.id.`.
1 parent 9d3557a commit f3ed888

File tree

2 files changed

+34
-154
lines changed

2 files changed

+34
-154
lines changed

LanguageFeatures/Static-access-shorthand/non_ambiguity_A02_t01.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/// `? C.id`.
1414
/// @author [email protected]
1515
16-
// SharedOptions=--enable-experiment=dot-shorthands,null-aware-elements
16+
// SharedOptions=--enable-experiment=dot-shorthands
1717

1818
import '../../Utils/expect.dart';
1919

LanguageFeatures/Static-access-shorthand/non_ambiguity_A02_t02.dart

Lines changed: 33 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
/// different meanings, where the existing grammar didn’t allow the `?` token to
1010
/// be followed by `.` anywhere.
1111
///
12-
/// @description Checks that `?.id` is parsed as `?. id` which is a compile-time
13-
/// error.
12+
/// @description Checks that `?.id` is parsed like `? .id`.
1413
/// @author [email protected]
1514
16-
// SharedOptions=--enable-experiment=dot-shorthands,null-aware-elements
15+
// SharedOptions=--enable-experiment=dot-shorthands
16+
17+
import '../../Utils/expect.dart';
1718

1819
class C {
1920
int value;
@@ -57,164 +58,43 @@ extension type ET(int value) {
5758
static ET? three() => ET(3);
5859
}
5960

60-
void testConstructors() {
61-
var l = <C>[
62-
?.id(0)
63-
// ^^
64-
// [analyzer] unspecified
65-
// [cfe] unspecified
66-
];
67-
68-
var s = <C>{
69-
?.new(0),
70-
// ^^
71-
// [analyzer] unspecified
72-
// [cfe] unspecified
73-
};
74-
75-
var m1 = <String, ET> {
76-
"key": ?.id(0)
77-
// ^^
78-
// [analyzer] unspecified
79-
// [cfe] unspecified
80-
?.new(0): "value1",
81-
// ^^
82-
// [analyzer] unspecified
83-
// [cfe] unspecified
84-
};
85-
86-
var m2 = <ET, String> {
87-
?.new(0): "value"
88-
// ^^
89-
// [analyzer] unspecified
90-
// [cfe] unspecified
91-
};
92-
}
93-
94-
void testVariables() {
95-
var l = <C>[
96-
?.one
97-
// ^^
98-
// [analyzer] unspecified
99-
// [cfe] unspecified
100-
];
101-
102-
var s = <M>{
103-
?.one
104-
// ^^
105-
// [analyzer] unspecified
106-
// [cfe] unspecified
107-
};
108-
109-
var m1 = <String, E>{
110-
"key": ?.one,
111-
// ^^
112-
// [analyzer] unspecified
113-
// [cfe] unspecified
114-
};
115-
116-
var m2 = <ET, String> {
117-
?.one: "value"
118-
// ^^
119-
// [analyzer] unspecified
120-
// [cfe] unspecified
121-
};
122-
}
123-
124-
void testGetters() {
125-
var l = <C>[
126-
?.two
127-
// ^^
128-
// [analyzer] unspecified
129-
// [cfe] unspecified
130-
];
131-
132-
var s = <M>{
133-
?.two
134-
// ^^
135-
// [analyzer] unspecified
136-
// [cfe] unspecified
137-
};
138-
139-
var m1 = <String, E>{
140-
"key": ?.two,
141-
// ^^
142-
// [analyzer] unspecified
143-
// [cfe] unspecified
144-
};
145-
146-
var m2 = <ET, String> {
147-
?.two: "value"
148-
// ^^
149-
// [analyzer] unspecified
150-
// [cfe] unspecified
151-
};
152-
}
153-
154-
void testMethods() {
155-
var l = <C>[
156-
?.three()
157-
// ^^
158-
// [analyzer] unspecified
159-
// [cfe] unspecified
61+
main() {
62+
var l1 = <C>[
63+
?.id(0), // ignore: invalid_null_aware_operator
64+
?.new(0), // ignore: invalid_null_aware_operator
65+
?.one,
66+
?.two,
67+
?.three()
16068
];
69+
Expect.listEquals([C(0), C(0), C(1), C(2), C(3)], l1);
16170

16271
var s = <M>{
163-
?.three()
164-
// ^^
165-
// [analyzer] unspecified
166-
// [cfe] unspecified
72+
?.one,
73+
?.two,
74+
?.three()
16775
};
76+
Expect.setEquals({MC(1), MC(2), MC(3)}, s);
16877

16978
var m1 = <String, E>{
170-
"key": ?.three(),
171-
// ^^
172-
// [analyzer] unspecified
173-
// [cfe] unspecified
79+
"key0": ?.e1, // ignore: invalid_null_aware_operator
80+
"key1": ?.one,
81+
"key2": ?.two,
82+
"key3": ?.three()
17483
};
84+
Expect.mapEquals({"key0": E.e1, "key1": E.e1, "key2": E.e2, "key3":E.e3}, m1);
17585

17686
var m2 = <ET, String> {
177-
?.three(): "value"
178-
// ^^
179-
// [analyzer] unspecified
180-
// [cfe] unspecified
181-
};
182-
}
183-
184-
void testEnumValues() {
185-
var l = <E>[
186-
?.e0
187-
// ^^
188-
// [analyzer] unspecified
189-
// [cfe] unspecified
190-
];
191-
192-
var s = <E>{
193-
?.e0
194-
// ^^
195-
// [analyzer] unspecified
196-
// [cfe] unspecified
197-
};
198-
199-
var m1 = <String, E>{
200-
"key": ?.e0,
201-
// ^^
202-
// [analyzer] unspecified
203-
// [cfe] unspecified
204-
};
205-
206-
var m2 = <E, String> {
207-
?.e0: "value"
208-
// ^^
209-
// [analyzer] unspecified
210-
// [cfe] unspecified
87+
?.id(-1): "value0",
88+
?.new(0): "value1",
89+
?.one: "value2",
90+
?.two: "value3",
91+
?.three(): "value4"
21192
};
212-
}
213-
214-
main() {
215-
testConstructors();
216-
testVariables();
217-
testGetters();
218-
testMethods();
219-
testEnumValues();
93+
Expect.mapEquals({
94+
ET(-1): "value0",
95+
ET(0): "value1",
96+
ET(1): "value2",
97+
ET(2): "value3",
98+
ET(3): "value4"
99+
}, m2);
220100
}

0 commit comments

Comments
 (0)