@@ -252,6 +252,102 @@ void s(Subclassed e) {
252252
253253@reflectiveTest
254254class ExhaustiveCasesTest extends BaseExhaustiveCasesTest {
255+ Future <void > test_dotShorthands_enumLike () async {
256+ await assertDiagnostics (
257+ r'''
258+ class E {
259+ final int i;
260+ const E._(this.i);
261+
262+ static const e = E._(1);
263+ static const f = E._(2);
264+ static const g = E._(3);
265+ }
266+
267+ void fn(E e) {
268+ switch (e) {
269+ case .e:
270+ break;
271+ case .f:
272+ }
273+ }
274+ ''' ,
275+ [lint (148 , 10 )],
276+ );
277+ }
278+
279+ Future <void > test_dotShorthands_enumLike_default_ok () async {
280+ await assertNoDiagnostics (r'''
281+ class E {
282+ final int i;
283+ const E._(this.i);
284+
285+ static const e = E._(1);
286+ static const f = E._(2);
287+ static const g = E._(3);
288+ }
289+
290+ void fn(E e) {
291+ switch (e) {
292+ case .e:
293+ break;
294+ default:
295+ break;
296+ }
297+ }
298+ ''' );
299+ }
300+
301+ Future <void > test_dotShorthands_notEnumLike_ok () async {
302+ await assertNoDiagnostics (r'''
303+ class TooFew {
304+ const TooFew._();
305+
306+ static const e = TooFew._();
307+ }
308+
309+ void t(TooFew e) {
310+ switch (e) {
311+ case TooFew.e:
312+ }
313+ }
314+
315+ class PublicCons {
316+ const PublicCons();
317+ static const e = PublicCons();
318+ static const f = PublicCons();
319+ }
320+
321+ void p(PublicCons e) {
322+ switch (e) {
323+ case .e:
324+ }
325+ }
326+ ''' );
327+ }
328+
329+ Future <void > test_dotShorthands_notEnumLike_subclassed_ok () async {
330+ await assertNoDiagnostics (r'''
331+ class Subclassed {
332+ const Subclassed._();
333+
334+ static const e = Subclassed._();
335+ static const f = Subclassed._();
336+ static const g = Subclassed._();
337+ }
338+
339+ class Subclass extends Subclassed {
340+ Subclass() : super._();
341+ }
342+
343+ void s(Subclassed e) {
344+ switch (e) {
345+ case .e:
346+ }
347+ }
348+ ''' );
349+ }
350+
255351 test_enum_ok () async {
256352 await assertDiagnostics (actualEnumSource, [
257353 error (CompileTimeErrorCode .NON_EXHAUSTIVE_SWITCH_STATEMENT , 52 , 6 ),
0 commit comments