diff --git a/pkg/_fe_analyzer_shared/lib/src/exhaustiveness/test_helper.dart b/pkg/_fe_analyzer_shared/lib/src/exhaustiveness/test_helper.dart index 146b71248de..7dd05da5434 100644 --- a/pkg/_fe_analyzer_shared/lib/src/exhaustiveness/test_helper.dart +++ b/pkg/_fe_analyzer_shared/lib/src/exhaustiveness/test_helper.dart @@ -21,23 +21,22 @@ class Tags { String spacesToText(Space space) => space.toString(); /// Returns a textual representation for [fields] used for testing. -String fieldsToText(Map fields) { - // TODO(johnniwinther): Enforce that field maps are always sorted. - List sortedNames = fields.keys.toList()..sort(); +String fieldsToText( + Map fields, Set fieldsOfInterest) { + List sortedNames = fieldsOfInterest.toList()..sort(); StringBuffer sb = new StringBuffer(); String comma = ''; sb.write('{'); for (String name in sortedNames) { - if (name.startsWith('_')) { - // Avoid implementation specific fields, like `Object._identityHashCode` - // and `Enum._name`. - // TODO(johnniwinther): Support private fields in the test code. - continue; - } + StaticType? fieldType = fields[name]; sb.write(comma); sb.write(name); sb.write(':'); - sb.write(staticTypeToText(fields[name]!)); + if (fieldType != null) { + sb.write(staticTypeToText(fieldType)); + } else { + sb.write("-"); + } comma = ','; } sb.write('}'); diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/and_pattern.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/and_pattern.dart index a3833e8afb0..e419377a301 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/and_pattern.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/and_pattern.dart @@ -15,38 +15,29 @@ class D extends B {} class E extends B {} and(A o1, A o2) { - var a = /* - fields={field1:B,field2:B,hashCode:int,runtimeType:Type}, - type=A - */switch (o1) { + var a = /*type=A*/switch (o1) { A() && var a /*space=A*/=> 0, _ /*space=()*/=> 1, }; - var b = /* - fields={field1:B,field2:B,hashCode:int,runtimeType:Type}, - type=A - */switch (o1) { + var b = /*type=A*/switch (o1) { A() && var a /*space=A*/=> 0, }; } intersectSameClass(A o1, A o2, A o3) { - var a = /* - fields={field1:B,field2:B,hashCode:int,runtimeType:Type}, - type=A - */switch (o1) { + var a = /*type=A*/switch (o1) { A() && A() /*space=A*/=> 0, }; var b = /* - fields={field1:B,field2:B,hashCode:int,runtimeType:Type}, + fields={field1:B,field2:B}, type=A */switch (o2) { A(:var field1) && A(:var field2) /*space=A(field1: B, field2: B)*/=> [field1, field2], }; var c = /* error=non-exhaustive:A(field1: C, field2: C), - fields={field1:B,field2:B,hashCode:int,runtimeType:Type}, + fields={field1:B,field2:B}, type=A */switch (o3) { A(:var field1, field2: C()) && A(field1: D(), :var field2) /*space=A(field1: D, field2: C)*/=> 10, @@ -54,21 +45,18 @@ intersectSameClass(A o1, A o2, A o3) { } intersectSubClass(A o1, A o2, A o3) { - var a = /* - fields={field1:B,field2:B,hashCode:int,runtimeType:Type}, - type=A - */switch (o1) { + var a = /*type=A*/switch (o1) { Object() && A() /*space=A*/=> 0, }; var b = /* - fields={field1:B,field2:B,hashCode:int,runtimeType:Type}, + fields={field1:B,hashCode:int}, type=A */switch (o2) { A(:var field1) && Object(:var hashCode) /*space=A(field1: B, hashCode: int)*/=> [field1, hashCode], }; var c = /* error=non-exhaustive:A(field1: C, field2: C, hashCode: int), - fields={field1:B,field2:B,hashCode:int,runtimeType:Type}, + fields={field1:B,field2:B,hashCode:int}, type=A */switch (o3) { Object(:var hashCode) && A(:var field1, field2: D())/*space=A(hashCode: int, field1: B, field2: D)*/=> 10, @@ -77,7 +65,7 @@ intersectSubClass(A o1, A o2, A o3) { intersectUnion(A o1, A o2, B o3, B o4) { var a = /* - fields={field1:B,field2:B,hashCode:int,runtimeType:Type}, + fields={field1:B,field2:B}, type=A */switch (o1) { A(field1: C() || D()) && A(field2: C() || D()) /*space=A(field1: C|D, field2: C|D)*/=> 0, @@ -85,14 +73,13 @@ intersectUnion(A o1, A o2, B o3, B o4) { A(field1: D() || E()) && A(field2: D() || E()) /*space=A(field1: D|E, field2: D|E)*/=> 2, }; var b = /* - fields={field1:B,field2:B,hashCode:int,runtimeType:Type}, + fields={field1:B}, type=A */switch (o2) { A(field1: C() || D()) && A(field1: D() || E()) /*space=A(field1: D|??)*/=> 0, A(field1: C() || E()) && A(field1: C() || E()) /*space=A(field1: C|E|??)*/=> 1, }; var c = /* - fields={hashCode:int,runtimeType:Type}, subtypes={C,D,E}, type=B */switch (o3) { @@ -100,7 +87,6 @@ intersectUnion(A o1, A o2, B o3, B o4) { B() && (D() || E()) /*space=D|E*/= 1, }; var d = /* - fields={hashCode:int,runtimeType:Type}, subtypes={C,D,E}, type=B */switch (o3) { diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/bool.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/bool.dart index 9f76a525a46..ee205f3d6a0 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/bool.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/bool.dart @@ -4,7 +4,6 @@ void exhaustiveSwitch(bool b) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={true,false}, type=bool */ @@ -25,7 +24,6 @@ const f1 = false; void exhaustiveSwitchAliasedBefore(bool b) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={true,false}, type=bool */ @@ -43,7 +41,6 @@ void exhaustiveSwitchAliasedBefore(bool b) { void exhaustiveSwitchAliasedAfter(bool b) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={true,false}, type=bool */ @@ -65,7 +62,6 @@ const f2 = false; void nonExhaustiveSwitch1(bool b) { /* error=non-exhaustive:false, - fields={hashCode:int,runtimeType:Type}, subtypes={true,false}, type=bool */ @@ -80,7 +76,6 @@ void nonExhaustiveSwitch1(bool b) { void nonExhaustiveSwitch2(bool b) { /* error=non-exhaustive:true, - fields={hashCode:int,runtimeType:Type}, subtypes={true,false}, type=bool */ @@ -95,7 +90,6 @@ void nonExhaustiveSwitch2(bool b) { void nonExhaustiveSwitchWithDefault(bool b) { /* error=non-exhaustive:false, - fields={hashCode:int,runtimeType:Type}, subtypes={true,false}, type=bool */ @@ -113,7 +107,6 @@ void nonExhaustiveSwitchWithDefault(bool b) { void exhaustiveNullableSwitch(bool? b) { /* expandedSubtypes={true,false,Null}, - fields={}, subtypes={bool,Null}, type=bool? */ @@ -137,7 +130,6 @@ void nonExhaustiveNullableSwitch1(bool? b) { /* error=non-exhaustive:Null, expandedSubtypes={true,false,Null}, - fields={}, subtypes={bool,Null}, type=bool? */ @@ -157,7 +149,6 @@ void nonExhaustiveNullableSwitch2(bool? b) { /* error=non-exhaustive:false, expandedSubtypes={true,false,Null}, - fields={}, subtypes={bool,Null}, type=bool? */ @@ -175,7 +166,6 @@ void nonExhaustiveNullableSwitch2(bool? b) { void unreachableCase1(bool b) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={true,false}, type=bool */ @@ -201,7 +191,6 @@ void unreachableCase1(bool b) { void unreachableCase2(bool b) { // TODO(johnniwinther): Should we avoid the unreachable error here? /* - fields={hashCode:int,runtimeType:Type}, subtypes={true,false}, type=bool */ @@ -224,7 +213,6 @@ void unreachableCase2(bool b) { void unreachableCase3(bool? b) { /* expandedSubtypes={true,false,Null}, - fields={}, subtypes={bool,Null}, type=bool? */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/bounded_generic_sealed_classes.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/bounded_generic_sealed_classes.dart index d2b67e55e39..ff4554be477 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/bounded_generic_sealed_classes.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/bounded_generic_sealed_classes.dart @@ -8,7 +8,6 @@ class C extends A {} exhaustiveGeneric(A a) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */ @@ -26,7 +25,6 @@ exhaustiveGeneric(A a) { exhaustiveDynamic(A a) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */ @@ -44,7 +42,6 @@ exhaustiveDynamic(A a) { exhaustiveGenericFixed(A a) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */ @@ -62,7 +59,6 @@ exhaustiveGenericFixed(A a) { exhaustiveGenericCatchAll(A a) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */ @@ -81,7 +77,6 @@ exhaustiveGenericCatchAll(A a) { nonExhaustiveGeneric(A a) { /* error=non-exhaustive:C, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */ @@ -93,7 +88,6 @@ nonExhaustiveGeneric(A a) { } /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */ @@ -108,7 +102,6 @@ nonExhaustiveGeneric(A a) { nonExhaustiveDynamic1(A a) { /* error=non-exhaustive:C, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */ @@ -123,7 +116,6 @@ nonExhaustiveDynamic1(A a) { nonExhaustiveDynamic2(A a) { /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */ @@ -138,7 +130,6 @@ nonExhaustiveDynamic2(A a) { nonExhaustiveGenericFixed(A a) { /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */ @@ -150,7 +141,6 @@ nonExhaustiveGenericFixed(A a) { } /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */ @@ -165,7 +155,6 @@ nonExhaustiveGenericFixed(A a) { nonExhaustiveGenericCatchAll(A a) { /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */ @@ -181,7 +170,6 @@ nonExhaustiveGenericCatchAll(A a) { } /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */ @@ -200,7 +188,6 @@ nonExhaustiveGenericCatchAll(A a) { nonExhaustiveFixed(A a) { /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/cast.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/cast.dart index dc524d87009..15200512b68 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/cast.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/cast.dart @@ -15,7 +15,6 @@ class E extends B {} simpleCast(o1, o2) { var a = /* - fields={}, subtypes={Object,Null}, type=Object? */switch (o1) { @@ -27,7 +26,6 @@ simpleCast(o1, o2) { }; var b = /* - fields={}, subtypes={Object,Null}, type=Object? */switch (o2) { @@ -39,7 +37,7 @@ restrictedCase(o1, o2) { // Cast shouldn't match everything, because even though it doesn't throw, // it might not match. var a = /* - fields={}, + fields={field:-}, subtypes={Object,Null}, type=Object? */switch (o1) { @@ -49,7 +47,7 @@ restrictedCase(o1, o2) { var b = /* error=non-exhaustive:Object, - fields={}, + fields={field:-}, subtypes={Object,Null}, type=Object? */switch (o2) { @@ -59,7 +57,6 @@ restrictedCase(o1, o2) { sealedCast(B b1, B b2) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={C,D,E}, type=B */switch (b1) { @@ -68,7 +65,6 @@ sealedCast(B b1, B b2) { } /* error=non-exhaustive:E, - fields={hashCode:int,runtimeType:Type}, subtypes={C,D,E}, type=B */switch (b2) { diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/enum.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/enum.dart index 82d3241cc52..f9199d295eb 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/enum.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/enum.dart @@ -6,7 +6,6 @@ enum Enum { a, b, c } void exhaustiveSwitch(Enum e) { /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.a,Enum.b,Enum.c}, type=Enum */ @@ -32,7 +31,6 @@ const c1 = Enum.c; void exhaustiveSwitchAliasedBefore(Enum e) { /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.a,Enum.b,Enum.c}, type=Enum */ @@ -54,7 +52,6 @@ void exhaustiveSwitchAliasedBefore(Enum e) { void exhaustiveSwitchAliasedAfter(Enum e) { /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.a,Enum.b,Enum.c}, type=Enum */ @@ -81,7 +78,6 @@ const c2 = Enum.c; void nonExhaustiveSwitch1(Enum e) { /* error=non-exhaustive:Enum.c, - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.a,Enum.b,Enum.c}, type=Enum */ @@ -100,7 +96,6 @@ void nonExhaustiveSwitch1(Enum e) { void nonExhaustiveSwitch2(Enum e) { /* error=non-exhaustive:Enum.b, - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.a,Enum.b,Enum.c}, type=Enum */ @@ -119,7 +114,6 @@ void nonExhaustiveSwitch2(Enum e) { void nonExhaustiveSwitch3(Enum e) { /* error=non-exhaustive:Enum.a, - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.a,Enum.b,Enum.c}, type=Enum */ @@ -138,7 +132,6 @@ void nonExhaustiveSwitch3(Enum e) { void nonExhaustiveSwitch4(Enum e) { /* error=non-exhaustive:Enum.a, - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.a,Enum.b,Enum.c}, type=Enum */ @@ -153,7 +146,6 @@ void nonExhaustiveSwitch4(Enum e) { void nonExhaustiveSwitchWithDefault(Enum e) { /* error=non-exhaustive:Enum.a, - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.a,Enum.b,Enum.c}, type=Enum */ @@ -171,7 +163,6 @@ void nonExhaustiveSwitchWithDefault(Enum e) { void exhaustiveNullableSwitch(Enum? e) { /* expandedSubtypes={Enum.a,Enum.b,Enum.c,Null}, - fields={}, subtypes={Enum,Null}, type=Enum? */ @@ -199,7 +190,6 @@ void nonExhaustiveNullableSwitch1(Enum? e) { /* error=non-exhaustive:Null, expandedSubtypes={Enum.a,Enum.b,Enum.c,Null}, - fields={}, subtypes={Enum,Null}, type=Enum? */ @@ -223,7 +213,6 @@ void nonExhaustiveNullableSwitch2(Enum? e) { /* error=non-exhaustive:Enum.b, expandedSubtypes={Enum.a,Enum.b,Enum.c,Null}, - fields={}, subtypes={Enum,Null}, type=Enum? */ @@ -245,7 +234,6 @@ void nonExhaustiveNullableSwitch2(Enum? e) { void unreachableCase1(Enum e) { /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.a,Enum.b,Enum.c}, type=Enum */ @@ -275,7 +263,6 @@ void unreachableCase1(Enum e) { void unreachableCase2(Enum e) { /* error=non-exhaustive:Enum.c, - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.a,Enum.b,Enum.c}, type=Enum */ @@ -301,7 +288,6 @@ void unreachableCase2(Enum e) { void unreachableCase3(Enum e) { // TODO(johnniwinther): Should we avoid the unreachable error here? /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.a,Enum.b,Enum.c}, type=Enum */ @@ -328,7 +314,6 @@ void unreachableCase3(Enum e) { void unreachableCase4(Enum? e) { /* expandedSubtypes={Enum.a,Enum.b,Enum.c,Null}, - fields={}, subtypes={Enum,Null}, type=Enum? */ @@ -361,7 +346,6 @@ void unreachableCase4(Enum? e) { void unreachableCase5(Enum e) { /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.a,Enum.b,Enum.c}, type=Enum */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/f_bounded.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/f_bounded.dart index a572a79737a..f1b54b250c3 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/f_bounded.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/f_bounded.dart @@ -19,7 +19,6 @@ enum Enum> { exhaustiveSwitchDynamic(A a, Enum e) { /* expandedSubtypes={B,C,D1,D2}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D>}, type=A */ @@ -42,7 +41,6 @@ exhaustiveSwitchDynamic(A a, Enum e) { break; } /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.b,Enum.c,Enum.d1,Enum.d2}, type=Enum */ @@ -69,7 +67,6 @@ exhaustiveSwitchDynamic(A a, Enum e) { exhaustiveSwitchGeneric>(A a, Enum e) { /* expandedSubtypes={B,C,D1,D2}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D>}, type=A */ @@ -88,7 +85,6 @@ exhaustiveSwitchGeneric>(A a, Enum e) { break; } /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.b,Enum.c,Enum.d1,Enum.d2}, type=Enum */switch (e) { @@ -114,7 +110,6 @@ exhaustiveSwitchGeneric>(A a, Enum e) { exhaustiveSwitchBounded>(A a, Enum e) { /* expandedSubtypes={D1,D2}, - fields={hashCode:int,runtimeType:Type}, subtypes={D}, type=A */ @@ -129,7 +124,6 @@ exhaustiveSwitchBounded>(A a, Enum e) { break; } /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.d1,Enum.d2}, type=Enum */ @@ -148,7 +142,6 @@ exhaustiveSwitchBounded>(A a, Enum e) { exhaustiveSwitchCatchAll>(A a, Enum e) { /* expandedSubtypes={B,C,D1,D2}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D>}, type=A */ @@ -167,7 +160,6 @@ exhaustiveSwitchCatchAll>(A a, Enum e) { break; } /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.b,Enum.c,Enum.d1,Enum.d2}, type=Enum */ @@ -191,7 +183,6 @@ nonExhaustiveSwitchDynamic(A a, Enum e) { /* error=non-exhaustive:D1, expandedSubtypes={B,C,D1,D2}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D>}, type=A */ @@ -211,7 +202,6 @@ nonExhaustiveSwitchDynamic(A a, Enum e) { } /* error=non-exhaustive:Enum.c, - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.b,Enum.c,Enum.d1,Enum.d2}, type=Enum */ @@ -235,7 +225,6 @@ nonExhaustiveSwitchGeneric>(A a, Enum e) { /* error=non-exhaustive:D1, expandedSubtypes={B,C,D1,D2}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D>}, type=A */ @@ -255,7 +244,6 @@ nonExhaustiveSwitchGeneric>(A a, Enum e) { } /* error=non-exhaustive:Enum.d1, - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.b,Enum.c,Enum.d1,Enum.d2}, type=Enum */ @@ -279,7 +267,6 @@ nonExhaustiveSwitchBounded>(A a, Enum e) { /* error=non-exhaustive:D1, expandedSubtypes={D1,D2}, - fields={hashCode:int,runtimeType:Type}, subtypes={D}, type=A */ @@ -291,7 +278,6 @@ nonExhaustiveSwitchBounded>(A a, Enum e) { } /* error=non-exhaustive:Enum.d2, - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.d1,Enum.d2}, type=Enum */ @@ -307,7 +293,6 @@ nonExhaustiveSwitchCatchAll>(A a, Enum e) { /* error=non-exhaustive:D1, expandedSubtypes={B,C,D1,D2}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D>}, type=A */ @@ -323,7 +308,6 @@ nonExhaustiveSwitchCatchAll>(A a, Enum e) { } /* error=non-exhaustive:Enum.b, - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={Enum.b,Enum.c,Enum.d1,Enum.d2}, type=Enum */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/function_bounded_sealed_classes.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/function_bounded_sealed_classes.dart index 8321e58b363..7bc47ae2eaf 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/function_bounded_sealed_classes.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/function_bounded_sealed_classes.dart @@ -9,7 +9,6 @@ class D extends A {} exhaustiveCovariant(A a) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -31,7 +30,6 @@ exhaustiveCovariant(A a) { exhaustiveContravariant(A a) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -53,7 +51,6 @@ exhaustiveContravariant(A a) { exhaustiveBivariant(A a) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -76,7 +73,6 @@ exhaustiveBivariant(A a) { nonExhaustiveCovariant(A a) { /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -92,7 +88,6 @@ nonExhaustiveCovariant(A a) { } /* error=non-exhaustive:C, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -108,7 +103,6 @@ nonExhaustiveCovariant(A a) { } /* error=non-exhaustive:D, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -127,7 +121,6 @@ nonExhaustiveCovariant(A a) { nonExhaustiveContravariant(A a) { /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -143,7 +136,6 @@ nonExhaustiveContravariant(A a) { } /* error=non-exhaustive:C, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -159,7 +151,6 @@ nonExhaustiveContravariant(A a) { } /* error=non-exhaustive:D, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -178,7 +169,6 @@ nonExhaustiveContravariant(A a) { nonExhaustiveBivariant(A a) { /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -194,7 +184,6 @@ nonExhaustiveBivariant(A a) { } /* error=non-exhaustive:C, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -210,7 +199,6 @@ nonExhaustiveBivariant(A a) { } /* error=non-exhaustive:D, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/future_or.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/future_or.dart index 1e7c5a102b1..34db442bfc8 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/future_or.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/future_or.dart @@ -11,7 +11,6 @@ class C extends A {} exhaustiveBoolByValue(FutureOr f) { /* expandedSubtypes={true,false,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool,Future}, type=FutureOr */ @@ -31,7 +30,6 @@ exhaustiveBoolByValue(FutureOr f) { } var a = /* expandedSubtypes={true,false,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool,Future}, type=FutureOr */switch (f) { @@ -44,7 +42,6 @@ exhaustiveBoolByValue(FutureOr f) { exhaustiveBoolByType(FutureOr f) { /* expandedSubtypes={true,false,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool,Future}, type=FutureOr */ @@ -60,7 +57,6 @@ exhaustiveBoolByType(FutureOr f) { } /* expandedSubtypes={true,false,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool,Future}, type=FutureOr */switch (f) { @@ -75,7 +71,6 @@ exhaustiveBoolByType(FutureOr f) { } var a = /* expandedSubtypes={true,false,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool,Future}, type=FutureOr */switch (f) { @@ -88,7 +83,6 @@ nonExhaustiveBool(FutureOr f) { /* error=non-exhaustive:Future, expandedSubtypes={true,false,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool,Future}, type=FutureOr */ @@ -105,7 +99,6 @@ nonExhaustiveBool(FutureOr f) { /* error=non-exhaustive:false, expandedSubtypes={true,false,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool,Future}, type=FutureOr */ @@ -122,7 +115,6 @@ nonExhaustiveBool(FutureOr f) { /* error=non-exhaustive:true, expandedSubtypes={true,false,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool,Future}, type=FutureOr */ @@ -139,7 +131,6 @@ nonExhaustiveBool(FutureOr f) { /* error=non-exhaustive:Future, expandedSubtypes={true,false,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool,Future}, type=FutureOr */ @@ -160,7 +151,6 @@ nonExhaustiveBool(FutureOr f) { var a = /* error=non-exhaustive:Future, expandedSubtypes={true,false,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool,Future}, type=FutureOr */switch (f) { @@ -170,7 +160,6 @@ nonExhaustiveBool(FutureOr f) { var b = /* error=non-exhaustive:false, expandedSubtypes={true,false,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool,Future}, type=FutureOr */switch (f) { @@ -180,7 +169,6 @@ nonExhaustiveBool(FutureOr f) { var c = /* error=non-exhaustive:true, expandedSubtypes={true,false,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool,Future}, type=FutureOr */switch (f) { @@ -190,7 +178,6 @@ nonExhaustiveBool(FutureOr f) { var d = /* error=non-exhaustive:Future, expandedSubtypes={true,false,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool,Future}, type=FutureOr */switch (f) { @@ -203,7 +190,6 @@ nonExhaustiveBool(FutureOr f) { exhaustiveSealedBySubtype(FutureOr f) { /* expandedSubtypes={B,C,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={A,Future}, type=FutureOr */ @@ -223,7 +209,6 @@ exhaustiveSealedBySubtype(FutureOr f) { } var a = /* expandedSubtypes={B,C,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={A,Future}, type=FutureOr */switch (f) { @@ -236,7 +221,6 @@ exhaustiveSealedBySubtype(FutureOr f) { exhaustiveSealedByType(FutureOr f) { /* expandedSubtypes={B,C,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={A,Future}, type=FutureOr */ @@ -252,7 +236,6 @@ exhaustiveSealedByType(FutureOr f) { } var a = /* expandedSubtypes={B,C,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={A,Future}, type=FutureOr */switch (f) { @@ -265,7 +248,6 @@ nonExhaustiveSealed(FutureOr f) { /* error=non-exhaustive:Future, expandedSubtypes={B,C,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={A,Future}, type=FutureOr */ @@ -282,7 +264,6 @@ nonExhaustiveSealed(FutureOr f) { /* error=non-exhaustive:C, expandedSubtypes={B,C,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={A,Future}, type=FutureOr */ @@ -299,7 +280,6 @@ nonExhaustiveSealed(FutureOr f) { /* error=non-exhaustive:B, expandedSubtypes={B,C,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={A,Future}, type=FutureOr */ @@ -316,7 +296,6 @@ nonExhaustiveSealed(FutureOr f) { /* error=non-exhaustive:Future, expandedSubtypes={B,C,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={A,Future}, type=FutureOr */switch (f) { @@ -340,7 +319,6 @@ nonExhaustiveSealed(FutureOr f) { var a = /* error=non-exhaustive:Future, expandedSubtypes={B,C,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={A,Future}, type=FutureOr */switch (f) { @@ -350,7 +328,6 @@ nonExhaustiveSealed(FutureOr f) { var b = /* error=non-exhaustive:C, expandedSubtypes={B,C,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={A,Future}, type=FutureOr */switch (f) { @@ -360,7 +337,6 @@ nonExhaustiveSealed(FutureOr f) { var c = /* error=non-exhaustive:B, expandedSubtypes={B,C,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={A,Future}, type=FutureOr */switch (f) { @@ -371,7 +347,6 @@ nonExhaustiveSealed(FutureOr f) { exhaustiveRegular(FutureOr f) { var a = /* - fields={hashCode:int,runtimeType:Type}, subtypes={int,Future}, type=FutureOr */switch (f) { @@ -383,7 +358,6 @@ exhaustiveRegular(FutureOr f) { nonExhaustiveRegular(FutureOr f) { var a = /* error=non-exhaustive:Future, - fields={hashCode:int,runtimeType:Type}, subtypes={int,Future}, type=FutureOr */switch (f) { @@ -392,7 +366,6 @@ nonExhaustiveRegular(FutureOr f) { }; var b = /* error=non-exhaustive:int, - fields={hashCode:int,runtimeType:Type}, subtypes={int,Future}, type=FutureOr */switch (f) { @@ -407,7 +380,6 @@ exhaustiveNullable( FutureOr? f3) { /* expandedSubtypes={true,false,Future,Null}, - fields={}, subtypes={FutureOr,Null}, type=FutureOr? */ @@ -431,7 +403,6 @@ exhaustiveNullable( } /* expandedSubtypes={true,false,Null,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool?,Future}, type=FutureOr */ @@ -455,7 +426,6 @@ exhaustiveNullable( } /* expandedSubtypes={true,false,Null,Future}, - fields={}, subtypes={FutureOr,Null}, type=FutureOr? */ @@ -486,7 +456,6 @@ nonExhaustiveNullable( /* error=non-exhaustive:Null, expandedSubtypes={true,false,Future,Null}, - fields={}, subtypes={FutureOr,Null}, type=FutureOr? */ @@ -507,7 +476,6 @@ nonExhaustiveNullable( /* error=non-exhaustive:Null, expandedSubtypes={true,false,Null,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool?,Future}, type=FutureOr */ @@ -528,7 +496,6 @@ nonExhaustiveNullable( /* error=non-exhaustive:Future, expandedSubtypes={true,false,Null,Future}, - fields={hashCode:int,runtimeType:Type}, subtypes={bool?,Future}, type=FutureOr */ @@ -553,7 +520,6 @@ nonExhaustiveNullable( /* error=non-exhaustive:Null, expandedSubtypes={true,false,Null,Future}, - fields={}, subtypes={FutureOr,Null}, type=FutureOr? */ @@ -574,7 +540,6 @@ nonExhaustiveNullable( /* error=non-exhaustive:Future, expandedSubtypes={true,false,Null,Future}, - fields={}, subtypes={FutureOr,Null}, type=FutureOr? */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_class.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_class.dart index 8f47217a020..697a3b12977 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_class.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_class.dart @@ -5,55 +5,36 @@ class A {} switchADynamic(A o) { - var a = /* - fields={hashCode:int,runtimeType:Type}, - type=A - */ + var a = /*type=A*/ switch (o) { A() /*space=A*/=> 0, }; - var b = /* - fields={hashCode:int,runtimeType:Type}, - type=A - */ + var b = /*type=A*/ switch (o) { A() /*space=A*/=> 0, }; } switchANum(A o) { - var a = /* - fields={hashCode:int,runtimeType:Type}, - type=A - */ + var a = /*type=A*/ switch (o) { A() /*space=A*/=> 0, }; - var b = /* - fields={hashCode:int,runtimeType:Type}, - type=A - */ + var b = /*type=A*/ switch (o) { A() /*cfe.space=A*//*analyzer.space=A*/=> 0, }; - var c = /* - fields={hashCode:int,runtimeType:Type}, - type=A - */ + var c = /*type=A*/ switch (o) { A() /*space=A*/=> 0, }; - var d1 = /* - fields={hashCode:int,runtimeType:Type}, - type=A - */ + var d1 = /*type=A*/ switch (o) { A() /*space=A*/=> 0, _ /*space=()*/=> 1, }; var d2 = /* error=non-exhaustive:A, - fields={hashCode:int,runtimeType:Type}, type=A */ switch (o) { @@ -62,38 +43,25 @@ switchANum(A o) { } switchAGeneric(A o) { - var a = /* - fields={hashCode:int,runtimeType:Type}, - type=A - */ + var a = /*type=A*/ switch (o) { A() /*space=A*/=> 0, }; - var b = /* - fields={hashCode:int,runtimeType:Type}, - type=A - */ + var b = /*type=A*/ switch (o) { A() /*cfe.space=A*//*analyzer.space=A*/=> 0, }; - var c = /* - fields={hashCode:int,runtimeType:Type}, - type=A - */ + var c = /*type=A*/ switch (o) { A() /*space=A*/=> 0, }; - var d1 = /* - fields={hashCode:int,runtimeType:Type}, - type=A - */ + var d1 = /*type=A*/ switch (o) { A() /*space=A*/=> 0, _ /*space=()*/=> 1, }; var d2 = /* error=non-exhaustive:A, - fields={hashCode:int,runtimeType:Type}, type=A */ switch (o) { diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_enum.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_enum.dart index 9fdd5861b46..682d87a3ed2 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_enum.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_enum.dart @@ -10,7 +10,6 @@ enum GenericEnum { void exhaustiveGenericSwitch(GenericEnum e) { /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={GenericEnum.a,GenericEnum.b,GenericEnum.c}, type=GenericEnum */ @@ -32,7 +31,6 @@ void exhaustiveGenericSwitch(GenericEnum e) { void exhaustiveGenericSwitchTyped(GenericEnum e) { /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={GenericEnum.a}, type=GenericEnum */ @@ -46,7 +44,6 @@ void exhaustiveGenericSwitchTyped(GenericEnum e) { void exhaustiveGenericSwitchTypeVariable(GenericEnum e) { /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={GenericEnum.a,GenericEnum.b,GenericEnum.c}, type=GenericEnum */ @@ -68,7 +65,6 @@ void exhaustiveGenericSwitchTypeVariable(GenericEnum e) { void exhaustiveGenericSwitchBounded(GenericEnum e) { /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={GenericEnum.a}, type=GenericEnum */ @@ -83,7 +79,6 @@ void exhaustiveGenericSwitchBounded(GenericEnum e) { void nonExhaustiveGenericSwitchTypeVariable(GenericEnum e) { /* error=non-exhaustive:GenericEnum.c, - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={GenericEnum.a,GenericEnum.b,GenericEnum.c}, type=GenericEnum */ @@ -101,7 +96,6 @@ void nonExhaustiveGenericSwitchTypeVariable(GenericEnum e) { void exhaustiveGenericSwitchTypeVariableByType(GenericEnum e) { /* - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={GenericEnum.a,GenericEnum.b,GenericEnum.c}, type=GenericEnum */ @@ -123,7 +117,6 @@ void exhaustiveGenericSwitchTypeVariableByType(GenericEnum e) { void nonExhaustiveGenericSwitchTypeVariableByType(GenericEnum e) { /* error=non-exhaustive:GenericEnum.c, - fields={hashCode:int,index:int,runtimeType:Type}, subtypes={GenericEnum.a,GenericEnum.b,GenericEnum.c}, type=GenericEnum */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_nested_sealed_classes.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_nested_sealed_classes.dart index 855de3a61d1..ca2ffec03f7 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_nested_sealed_classes.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_nested_sealed_classes.dart @@ -21,7 +21,6 @@ class D4 extends D {} exhaustiveLevel0(A a) { /* expandedSubtypes={B1,B2,C1,C2,D1,D2,D3,D4}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -36,7 +35,6 @@ exhaustiveLevel0(A a) { exhaustiveLevel0_1(A a) { /* expandedSubtypes={B1,B2,C1,C2,D1,D2,D3,D4}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -62,7 +60,6 @@ exhaustiveLevel1(A a) { /* error=non-exhaustive:D1, expandedSubtypes={B1,B2,C1,C2,D1,D2,D3,D4}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -84,7 +81,6 @@ exhaustiveLevel1(A a) { exhaustiveLevel1b(B a) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={B1,B2}, type=B */ @@ -95,7 +91,6 @@ exhaustiveLevel1b(B a) { break; } /* - fields={hashCode:int,runtimeType:Type}, subtypes={B1,B2}, type=B */ @@ -117,7 +112,6 @@ exhaustiveLevel2(A a) { /* error=non-exhaustive:D1, expandedSubtypes={B1,B2,C1,C2,D1,D2,D3,D4}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -159,7 +153,6 @@ exhaustiveLevel2(A a) { exhaustiveLevel0_1_2(A a) { /* expandedSubtypes={B1,B2,C1,C2,D1,D2,D3,D4}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */switch (a) { diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_sealed_class.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_sealed_class.dart index fe072700773..6fbed1aa093 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_sealed_class.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/generic_sealed_class.dart @@ -14,7 +14,6 @@ void exhaustiveSwitchGeneric(A a) { // direct passing of type variables in D. /* error=non-exhaustive:D, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -35,7 +34,6 @@ void exhaustiveSwitchGeneric(A a) { } void exhaustiveSwitchGenericCatchAll(A a) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -60,7 +58,6 @@ void exhaustiveSwitchGenericBounded(A a) { // direct passing of type variables in D. /* error=non-exhaustive:D, - fields={hashCode:int,runtimeType:Type}, subtypes={B,D}, type=A */ @@ -79,7 +76,6 @@ void exhaustiveSwitchGenericBounded(A a) { void nonExhaustiveSwitchWrongGeneric1(A a) { /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -102,7 +98,6 @@ void nonExhaustiveSwitchWrongGeneric1(A a) { void nonExhaustiveSwitchWrongGeneric2(A a) { /* error=non-exhaustive:D, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -127,7 +122,6 @@ void exhaustiveSwitch3(A a) { // direct passing of type variables in D. /* error=non-exhaustive:D, - fields={hashCode:int,runtimeType:Type}, subtypes={B,D}, type=A */ @@ -146,7 +140,6 @@ void exhaustiveSwitch3(A a) { void nonExhaustiveSwitch1(A a) { /* error=non-exhaustive:D, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -165,7 +158,6 @@ void nonExhaustiveSwitch1(A a) { void nonExhaustiveSwitch2(A a) { /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -182,7 +174,6 @@ void nonExhaustiveSwitch2(A a) { void nonExhaustiveSwitch3(A a) { /* error=non-exhaustive:D, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -205,7 +196,6 @@ void nonExhaustiveSwitch3(A a) { void nonExhaustiveSwitchWithDefault(A a) { /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -226,7 +216,6 @@ void exhaustiveNullableSwitch(A? a) { /* error=non-exhaustive:D, expandedSubtypes={B,C,D,Null}, - fields={}, subtypes={A,Null}, type=A? */ @@ -254,7 +243,6 @@ void nonExhaustiveNullableSwitch1(A? a) { /* error=non-exhaustive:Null, expandedSubtypes={B,C,D,Null}, - fields={}, subtypes={A,Null}, type=A? */ @@ -270,7 +258,6 @@ void nonExhaustiveNullableSwitch2(A? a) { /* error=non-exhaustive:D, expandedSubtypes={B,C,D,Null}, - fields={}, subtypes={A,Null}, type=A? */ @@ -292,7 +279,6 @@ void nonExhaustiveNullableSwitch2(A? a) { void unreachableCase1(A a) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -319,7 +305,6 @@ void unreachableCase1(A a) { void unreachableCase2(A a) { // TODO(johnniwinther): Should we avoid the unreachable error here? /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -338,7 +323,6 @@ void unreachableCase2(A a) { void unreachableCase3(A? a) { /* expandedSubtypes={B,C,D,Null}, - fields={}, subtypes={A,Null}, type=A? */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/list.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/list.dart index fa05dd9b259..5fef9e1e4c8 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/list.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/list.dart @@ -3,13 +3,8 @@ // BSD-style license that can be found in the LICENSE file. untypedList(List list) { - var a = /*cfe. + var a = /* error=non-exhaustive:List, - fields={first:Object?,hashCode:int,isEmpty:bool,isNotEmpty:bool,iterator:Iterator,last:Object?,length:int,reversed:Iterable,runtimeType:Type,single:Object?}, - type=List - *//*analyzer. - error=non-exhaustive:List, - fields={first:Object?,hashCode:int,isEmpty:bool,isNotEmpty:bool,iterator:Iterator,last:Object?,length:int,runtimeType:Type}, type=List */switch (list) { [] /*space=??*/=> 0, @@ -24,13 +19,8 @@ class B extends A {} class C extends A {} typedList(List list) { - var a = /*cfe. + var a = /* error=non-exhaustive:List, - fields={first:A,hashCode:int,isEmpty:bool,isNotEmpty:bool,iterator:Iterator,last:A,length:int,reversed:Iterable,runtimeType:Type,single:A}, - type=List - *//*analyzer. - error=non-exhaustive:List, - fields={first:A,hashCode:int,isEmpty:bool,isNotEmpty:bool,iterator:Iterator,last:A,length:int,runtimeType:Type}, type=List */switch (list) { [] /*space=??*/=> 0, @@ -43,24 +33,14 @@ typedList(List list) { } restWithSubpattern(List list) { - var a = /*cfe. + var a = /* error=non-exhaustive:List, - fields={first:Object?,hashCode:int,isEmpty:bool,isNotEmpty:bool,iterator:Iterator,last:Object?,length:int,reversed:Iterable,runtimeType:Type,single:Object?}, - type=List - *//*analyzer. - error=non-exhaustive:List, - fields={first:Object?,hashCode:int,isEmpty:bool,isNotEmpty:bool,iterator:Iterator,last:Object?,length:int,runtimeType:Type}, type=List */switch (list) { [...var l] /*space=??*/=> l.length, }; - var b = /*cfe. + var b = /* error=non-exhaustive:List, - fields={first:Object?,hashCode:int,isEmpty:bool,isNotEmpty:bool,iterator:Iterator,last:Object?,length:int,reversed:Iterable,runtimeType:Type,single:Object?}, - type=List - *//*analyzer. - error=non-exhaustive:List, - fields={first:Object?,hashCode:int,isEmpty:bool,isNotEmpty:bool,iterator:Iterator,last:Object?,length:int,runtimeType:Type}, type=List */switch (list) { [...List l] /*space=??*/=> l.length, diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/map.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/map.dart index 875a8786333..914d528c9b1 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/map.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/map.dart @@ -3,13 +3,8 @@ // BSD-style license that can be found in the LICENSE file. untypedMap(Map map) { - var a = /*cfe. + var a = /* error=non-exhaustive:Map, - fields={entries:Iterable>,hashCode:int,isEmpty:bool,isNotEmpty:bool,keys:Iterable,length:int,runtimeType:Type,values:Iterable}, - type=Map - *//*analyzer. - error=non-exhaustive:Map, - fields={hashCode:int,isEmpty:bool,isNotEmpty:bool,keys:Iterable,length:int,runtimeType:Type,values:Iterable}, type=Map */switch (map) { {} /*space=??*/=> 0, @@ -25,13 +20,8 @@ class B extends A {} class C extends A {} typedList(List list) { - var a = /*cfe. + var a = /* error=non-exhaustive:List, - fields={first:A,hashCode:int,isEmpty:bool,isNotEmpty:bool,iterator:Iterator,last:A,length:int,reversed:Iterable,runtimeType:Type,single:A}, - type=List - *//*analyzer. - error=non-exhaustive:List, - fields={first:A,hashCode:int,isEmpty:bool,isNotEmpty:bool,iterator:Iterator,last:A,length:int,runtimeType:Type}, type=List */switch (list) { [] /*space=??*/=> 0, diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/nested_sealed_classes.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/nested_sealed_classes.dart index 8ce733f9d49..164736f8ccb 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/nested_sealed_classes.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/nested_sealed_classes.dart @@ -19,7 +19,6 @@ class D2 extends D {} exhaustiveLevel0(A a) { /* expandedSubtypes={B1,B2,C1,C2,D1,D2}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -34,7 +33,6 @@ exhaustiveLevel0(A a) { exhaustiveLevel0_1(A a) { /* expandedSubtypes={B1,B2,C1,C2,D1,D2}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -58,7 +56,6 @@ exhaustiveLevel0_1(A a) { exhaustiveLevel1(A a) { /* expandedSubtypes={B1,B2,C1,C2,D1,D2}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -81,7 +78,6 @@ exhaustiveLevel1(A a) { exhaustiveLevel2(A a) { /* expandedSubtypes={B1,B2,C1,C2,D1,D2}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -116,7 +112,6 @@ exhaustiveLevel2(A a) { exhaustiveLevel0_1_2(A a) { /* expandedSubtypes={B1,B2,C1,C2,D1,D2}, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/null_assert.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/null_assert.dart index ba62e0bcec3..6898ddff2c7 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/null_assert.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/null_assert.dart @@ -14,7 +14,6 @@ class D extends B {} simpleAssert(o1, o2) { var a = /* - fields={}, subtypes={Object,Null}, type=Object? */switch (o1) { @@ -26,7 +25,6 @@ simpleAssert(o1, o2) { }; var b = /* - fields={}, subtypes={Object,Null}, type=Object? */switch (o2) { @@ -38,7 +36,7 @@ restrictedCase(o1, o2) { // Null assert shouldn't match everything, because even though it doesn't // throw, it might not match. var a = /* - fields={}, + fields={field:-}, subtypes={Object,Null}, type=Object? */switch (o1) { @@ -48,7 +46,7 @@ restrictedCase(o1, o2) { var b = /* error=non-exhaustive:Object, - fields={}, + fields={field:-}, subtypes={Object,Null}, type=Object? */switch (o2) { @@ -59,7 +57,6 @@ restrictedCase(o1, o2) { nullableBool(bool? b1, bool? b2) { /* expandedSubtypes={true,false,Null}, - fields={}, subtypes={bool,Null}, type=bool? */ @@ -74,7 +71,6 @@ nullableBool(bool? b1, bool? b2) { /* error=non-exhaustive:false, expandedSubtypes={true,false,Null}, - fields={}, subtypes={bool,Null}, type=bool? */ @@ -87,14 +83,13 @@ nullableBool(bool? b1, bool? b2) { nullableA(A? a1, A? a2, A? a3) { var a = /* - fields={}, subtypes={A,Null}, type=A? */switch (a1) { A()! /*space=A?*/=> 0, }; var b = /* - fields={}, + fields={field:-}, subtypes={A,Null}, type=A? */switch (a2) { @@ -102,7 +97,7 @@ nullableA(A? a1, A? a2, A? a3) { }; var c = /* error=non-exhaustive:A(field: int), - fields={}, + fields={field:-}, subtypes={A,Null}, type=A? */switch (a3) { @@ -115,7 +110,6 @@ nullableA(A? a1, A? a2, A? a3) { nullableB(B? b1, B? b2, B? b3) { /* expandedSubtypes={C,D,Null}, - fields={}, subtypes={B,Null}, type=B? */ @@ -126,7 +120,6 @@ nullableB(B? b1, B? b2, B? b3) { } /* expandedSubtypes={C,D,Null}, - fields={}, subtypes={B,Null}, type=B? */ @@ -141,7 +134,6 @@ nullableB(B? b1, B? b2, B? b3) { /* error=non-exhaustive:D, expandedSubtypes={C,D,Null}, - fields={}, subtypes={B,Null}, type=B? */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/null_check.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/null_check.dart index 1a983740e76..d1e21c2f758 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/null_check.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/null_check.dart @@ -6,7 +6,6 @@ typedef NullableObject = Object?; object(o) { var a = /* - fields={}, subtypes={Object,Null}, type=Object? */switch (o) { @@ -15,7 +14,6 @@ object(o) { }; var b = /* error=non-exhaustive:Null, - fields={}, subtypes={Object,Null}, type=Object? */switch (o) { @@ -25,7 +23,6 @@ object(o) { wildcard(o) { var a = /* - fields={}, subtypes={Object,Null}, type=Object? */switch (o) { @@ -34,7 +31,6 @@ wildcard(o) { }; var b = /* error=non-exhaustive:Null, - fields={}, subtypes={Object,Null}, type=Object? */switch (o) { @@ -44,7 +40,6 @@ wildcard(o) { or(o) { var a = /* - fields={}, subtypes={Object,Null}, type=Object? */switch (o) { @@ -53,7 +48,6 @@ or(o) { }; var b = /* error=non-exhaustive:Null, - fields={}, subtypes={Object,Null}, type=Object? */switch (o) { @@ -63,7 +57,6 @@ or(o) { typedVariable(o) { var a = /* - fields={}, subtypes={Object,Null}, type=Object? */switch (o) { @@ -72,7 +65,6 @@ typedVariable(o) { }; var b = /* error=non-exhaustive:Null, - fields={}, subtypes={Object,Null}, type=Object? */switch (o) { @@ -82,7 +74,6 @@ typedVariable(o) { untypedVariable(o) { var a = /* - fields={}, subtypes={Object,Null}, type=Object? */switch (o) { @@ -91,7 +82,6 @@ untypedVariable(o) { }; var b = /* error=non-exhaustive:Null, - fields={}, subtypes={Object,Null}, type=Object? */switch (o) { diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/object_pattern.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/object_pattern.dart index 7afdaa874fb..bd985523f99 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/object_pattern.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/object_pattern.dart @@ -17,7 +17,7 @@ class B extends A { void exhaustiveSwitch1(A r) { /* - fields={a:Enum,b:bool,hashCode:int,runtimeType:Type}, + fields={a:Enum,b:bool}, subtypes={B}, type=A */ @@ -43,7 +43,7 @@ void exhaustiveSwitch1(A r) { void exhaustiveSwitch2(A r) { /* - fields={a:Enum,b:bool,hashCode:int,runtimeType:Type}, + fields={a:Enum,b:bool}, subtypes={B}, type=A */ @@ -70,7 +70,7 @@ void exhaustiveSwitch2(A r) { void nonExhaustiveSwitch1(A r) { /* error=non-exhaustive:B(a: Enum.b, b: false), - fields={a:Enum,b:bool,hashCode:int,runtimeType:Type}, + fields={a:Enum,b:bool}, subtypes={B}, type=A */ @@ -93,7 +93,7 @@ void nonExhaustiveSwitch1(A r) { void nonExhaustiveSwitch2(A r) { /* error=non-exhaustive:B(a: Enum.a, b: false), - fields={a:Enum,b:bool,hashCode:int,runtimeType:Type}, + fields={a:Enum,b:bool}, subtypes={B}, type=A */ @@ -116,7 +116,7 @@ void nonExhaustiveSwitch2(A r) { void nonExhaustiveSwitchWithDefault(A r) { /* error=non-exhaustive:B(a: Enum.a, b: true), - fields={a:Enum,b:bool,hashCode:int,runtimeType:Type}, + fields={a:Enum,b:bool}, subtypes={B}, type=A */ @@ -134,7 +134,7 @@ void nonExhaustiveSwitchWithDefault(A r) { void exhaustiveNullableSwitch(A? r) { /* expandedSubtypes={B,Null}, - fields={}, + fields={a:-,b:-}, subtypes={A,Null}, type=A? */ @@ -166,7 +166,7 @@ void nonExhaustiveNullableSwitch1(A? r) { /* error=non-exhaustive:Null, expandedSubtypes={B,Null}, - fields={}, + fields={a:-,b:-}, subtypes={A,Null}, type=A? */ @@ -194,7 +194,7 @@ void nonExhaustiveNullableSwitch2(A? r) { /* error=non-exhaustive:B(a: Enum.b, b: false), expandedSubtypes={B,Null}, - fields={}, + fields={a:-,b:-}, subtypes={A,Null}, type=A? */ @@ -220,7 +220,7 @@ void nonExhaustiveNullableSwitch2(A? r) { void unreachableCase1(A r) { /* - fields={a:Enum,b:bool,hashCode:int,runtimeType:Type}, + fields={a:Enum,b:bool}, subtypes={B}, type=A */ @@ -254,7 +254,7 @@ void unreachableCase1(A r) { void unreachableCase2(A r) { // TODO(johnniwinther): Should we avoid the unreachable error here? /* - fields={a:Enum,b:bool,hashCode:int,runtimeType:Type}, + fields={a:Enum,b:bool}, subtypes={B}, type=A */ @@ -285,7 +285,7 @@ void unreachableCase2(A r) { void unreachableCase3(A? r) { /* expandedSubtypes={B,Null}, - fields={}, + fields={a:-,b:-}, subtypes={A,Null}, type=A? */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/or_pattern.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/or_pattern.dart index 9ff51d4d4f5..3bace2c11f4 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/or_pattern.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/or_pattern.dart @@ -4,7 +4,6 @@ or(bool b1, bool? b2) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={true,false}, type=bool */ @@ -15,7 +14,6 @@ or(bool b1, bool? b2) { /* expandedSubtypes={true,false,Null}, - fields={}, subtypes={bool,Null}, type=bool? */ @@ -28,7 +26,6 @@ or(bool b1, bool? b2) { /* expandedSubtypes={true,false,Null}, - fields={}, subtypes={bool,Null}, type=bool? */ @@ -41,7 +38,6 @@ or(bool b1, bool? b2) { /* expandedSubtypes={true,false,Null}, - fields={}, subtypes={bool,Null}, type=bool? */ @@ -54,7 +50,6 @@ or(bool b1, bool? b2) { /* expandedSubtypes={true,false,Null}, - fields={}, subtypes={bool,Null}, type=bool? */ @@ -65,7 +60,6 @@ or(bool b1, bool? b2) { /* expandedSubtypes={true,false,Null}, - fields={}, subtypes={bool,Null}, type=bool? */ @@ -77,7 +71,6 @@ or(bool b1, bool? b2) { /* error=non-exhaustive:false, expandedSubtypes={true,false,Null}, - fields={}, subtypes={bool,Null}, type=bool? */ @@ -89,7 +82,6 @@ or(bool b1, bool? b2) { /* error=non-exhaustive:true, expandedSubtypes={true,false,Null}, - fields={}, subtypes={bool,Null}, type=bool? */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record.dart index dbcbb1f1993..482f834f42e 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record.dart @@ -96,7 +96,7 @@ void nonExhaustiveSwitchWithDefault((Enum, bool) r) { void exhaustiveNullableSwitch((Enum, bool)? r) { /* - fields={}, + fields={$1:-,$2:-}, subtypes={(Enum, bool),Null}, type=(Enum, bool)? */ @@ -127,7 +127,7 @@ void exhaustiveNullableSwitch((Enum, bool)? r) { void nonExhaustiveNullableSwitch1((Enum, bool)? r) { /* error=non-exhaustive:Null, - fields={}, + fields={$1:-,$2:-}, subtypes={(Enum, bool),Null}, type=(Enum, bool)? */switch (r) { @@ -153,7 +153,7 @@ void nonExhaustiveNullableSwitch1((Enum, bool)? r) { void nonExhaustiveNullableSwitch2((Enum, bool)? r) { /* error=non-exhaustive:($1: Enum.b, $2: false), - fields={}, + fields={$1:-,$2:-}, subtypes={(Enum, bool),Null}, type=(Enum, bool)? */ @@ -241,7 +241,7 @@ void unreachableCase2((Enum, bool) r) { void unreachableCase3((Enum, bool)? r) { /* - fields={}, + fields={$1:-,$2:-}, subtypes={(Enum, bool),Null}, type=(Enum, bool)? */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record_literal.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record_literal.dart index caf11cb0535..341e55eb2e6 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record_literal.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record_literal.dart @@ -92,7 +92,7 @@ void nonExhaustiveSwitchWithDefault((Enum, bool) r) { void exhaustiveNullableSwitch((Enum, bool)? r) { /* - fields={}, + fields={$1:-,$2:-}, subtypes={(Enum, bool),Null}, type=(Enum, bool)? */ @@ -122,7 +122,7 @@ void exhaustiveNullableSwitch((Enum, bool)? r) { void nonExhaustiveNullableSwitch1((Enum, bool)? r) { /* error=non-exhaustive:Null, - fields={}, + fields={$1:-,$2:-}, subtypes={(Enum, bool),Null}, type=(Enum, bool)? */ @@ -149,7 +149,7 @@ void nonExhaustiveNullableSwitch1((Enum, bool)? r) { void nonExhaustiveNullableSwitch2((Enum, bool)? r) { /* error=non-exhaustive:($1: Enum.b, $2: false), - fields={}, + fields={$1:-,$2:-}, subtypes={(Enum, bool),Null}, type=(Enum, bool)? */ @@ -237,7 +237,7 @@ void unreachableCase2((Enum, bool) r) { void unreachableCase3((Enum, bool)? r) { /* - fields={}, + fields={$1:-,$2:-}, subtypes={(Enum, bool),Null}, type=(Enum, bool)? */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record_literal_named.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record_literal_named.dart index cf75274fb62..eba97de3ae1 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record_literal_named.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record_literal_named.dart @@ -90,7 +90,7 @@ void nonExhaustiveSwitchWithDefault(({Enum a, bool b}) r) { void exhaustiveNullableSwitch(({Enum a, bool b})? r) { /* - fields={}, + fields={a:-,b:-}, subtypes={({Enum a, bool b}),Null}, type=({Enum a, bool b})? */ @@ -121,7 +121,7 @@ void exhaustiveNullableSwitch(({Enum a, bool b})? r) { void nonExhaustiveNullableSwitch1(({Enum a, bool b})? r) { /* error=non-exhaustive:Null, - fields={}, + fields={a:-,b:-}, subtypes={({Enum a, bool b}),Null}, type=({Enum a, bool b})? */ @@ -148,7 +148,7 @@ void nonExhaustiveNullableSwitch1(({Enum a, bool b})? r) { void nonExhaustiveNullableSwitch2(({Enum a, bool b})? r) { /* error=non-exhaustive:(a: Enum.b, b: false), - fields={}, + fields={a:-,b:-}, subtypes={({Enum a, bool b}),Null}, type=({Enum a, bool b})? */ @@ -234,7 +234,7 @@ void unreachableCase2(({Enum a, bool b}) r) { void unreachableCase3(({Enum a, bool b})? r) { /* - fields={}, + fields={a:-,b:-}, subtypes={({Enum a, bool b}),Null}, type=({Enum a, bool b})? */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record_sealed.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record_sealed.dart index 048c97d2e88..b35aa014bdb 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record_sealed.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/record_sealed.dart @@ -14,7 +14,7 @@ class Class { method(Class c) { /*analyzer. error=non-exhaustive:Class(field: ($1: C, $2: C)), - fields={field:(A, A),hashCode:int,runtimeType:Type}, + fields={field:(A, A)}, type=Class */ switch (c) { diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/relational.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/relational.dart index cb385324ca5..90f64b9c15e 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/relational.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/relational.dart @@ -4,7 +4,6 @@ equals(o1, o2) { var a = /* - fields={}, subtypes={Object,Null}, type=Object? */switch (o1) { @@ -14,7 +13,6 @@ equals(o1, o2) { var b = /* error=non-exhaustive:Object, - fields={}, subtypes={Object,Null}, type=Object? */switch (o2) { @@ -24,7 +22,6 @@ equals(o1, o2) { greaterThan(o1, o2) { var a = /* - fields={}, subtypes={Object,Null}, type=Object? */switch (o1) { @@ -34,7 +31,6 @@ greaterThan(o1, o2) { var b = /* error=non-exhaustive:Object, - fields={}, subtypes={Object,Null}, type=Object? */switch (o2) { diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/sealed_class.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/sealed_class.dart index 02286717cda..38fa2c2d2d6 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/sealed_class.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/sealed_class.dart @@ -11,7 +11,6 @@ enum Enum {a, b} void exhaustiveSwitch1(A a) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -33,7 +32,6 @@ void exhaustiveSwitch1(A a) { void exhaustiveSwitch2(A a) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -52,7 +50,6 @@ void exhaustiveSwitch2(A a) { void nonExhaustiveSwitch1(A a) { /* error=non-exhaustive:D, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -71,7 +68,6 @@ void nonExhaustiveSwitch1(A a) { void nonExhaustiveSwitch2(A a) { /* error=non-exhaustive:B, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -90,7 +86,6 @@ void nonExhaustiveSwitch2(A a) { void nonExhaustiveSwitch3(A a) { /* error=non-exhaustive:C, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -109,7 +104,6 @@ void nonExhaustiveSwitch3(A a) { void nonExhaustiveSwitchWithDefault(A a) { /* error=non-exhaustive:C, - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -127,7 +121,6 @@ void nonExhaustiveSwitchWithDefault(A a) { void exhaustiveNullableSwitch(A? a) { /* expandedSubtypes={B,C,D,Null}, - fields={}, subtypes={A,Null}, type=A? */switch (a) { @@ -154,7 +147,6 @@ void nonExhaustiveNullableSwitch1(A? a) { /* error=non-exhaustive:Null, expandedSubtypes={B,C,D,Null}, - fields={}, subtypes={A,Null}, type=A? */ @@ -170,7 +162,6 @@ void nonExhaustiveNullableSwitch2(A? a) { /* error=non-exhaustive:D, expandedSubtypes={B,C,D,Null}, - fields={}, subtypes={A,Null}, type=A? */ @@ -192,7 +183,6 @@ void nonExhaustiveNullableSwitch2(A? a) { void unreachableCase1(A a) { /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -222,7 +212,6 @@ void unreachableCase1(A a) { void unreachableCase2(A a) { // TODO(johnniwinther): Should we avoid the unreachable error here? /* - fields={hashCode:int,runtimeType:Type}, subtypes={B,C,D}, type=A */ @@ -241,7 +230,6 @@ void unreachableCase2(A a) { void unreachableCase3(A? a) { /* expandedSubtypes={B,C,D,Null}, - fields={}, subtypes={A,Null}, type=A? */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/variable_pattern.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/variable_pattern.dart index c94664dab86..fd4270b4e18 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/variable_pattern.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/variable_pattern.dart @@ -111,7 +111,7 @@ void nonExhaustiveSwitchWithDefault((Enum, bool) r) { void exhaustiveNullableSwitch((Enum, bool)? r) { /* - fields={}, + fields={$1:-,$2:-}, subtypes={(Enum, bool),Null}, type=(Enum, bool)? */ @@ -134,7 +134,7 @@ void exhaustiveNullableSwitch((Enum, bool)? r) { void nonExhaustiveNullableSwitch1((Enum, bool)? r) { /* error=non-exhaustive:Null, - fields={}, + fields={$1:-,$2:-}, subtypes={(Enum, bool),Null}, type=(Enum, bool)? */ @@ -149,7 +149,7 @@ void nonExhaustiveNullableSwitch1((Enum, bool)? r) { void nonExhaustiveNullableSwitch2((Enum, bool)? r) { /* error=non-exhaustive:($1: Enum.a, $2: true), - fields={}, + fields={$1:-,$2:-}, subtypes={(Enum, bool),Null}, type=(Enum, bool)? */ @@ -221,7 +221,7 @@ void unreachableCase2((Enum, bool) r) { void unreachableCase3((Enum, bool)? r) { /* - fields={}, + fields={$1:-,$2:-}, subtypes={(Enum, bool),Null}, type=(Enum, bool)? */ diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/when.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/when.dart index 928a5b9456e..298c4559843 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/data/when.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/data/when.dart @@ -19,7 +19,6 @@ class C extends A { method(A a) { /* - fields={field:int,hashCode:int,runtimeType:Type}, subtypes={B,C}, type=A */switch (a) { @@ -27,7 +26,7 @@ method(A a) { /*space=C*/case C(): } /* - fields={field:int,hashCode:int,runtimeType:Type}, + fields={field:int}, subtypes={B,C}, type=A */switch (a) { @@ -36,7 +35,7 @@ method(A a) { } /* error=non-exhaustive:B, - fields={field:int,hashCode:int,runtimeType:Type}, + fields={field:int}, subtypes={B,C}, type=A */switch (a) { @@ -45,7 +44,7 @@ method(A a) { } /* error=non-exhaustive:C, - fields={field:int,hashCode:int,runtimeType:Type}, + fields={field:int}, subtypes={B,C}, type=A */switch (a) { diff --git a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart index 4fe78973081..4fa06ef0580 100644 --- a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart +++ b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart @@ -829,6 +829,7 @@ class ConstantVerifier extends RecursiveAstVisitor { exhaustivenessDataForTesting.caseSpaces[caseNode] = caseSpaces[i]; } exhaustivenessDataForTesting.switchScrutineeType[node] = scrutineeTypeEx; + exhaustivenessDataForTesting.switchCases[node] = caseSpaces; for (var error in errors) { if (error is UnreachableCaseError) { exhaustivenessDataForTesting.errors[caseNodesWithSpace[error.index]] = diff --git a/pkg/analyzer/lib/src/generated/exhaustiveness.dart b/pkg/analyzer/lib/src/generated/exhaustiveness.dart index 3f647952db1..a5e3dc5ed09 100644 --- a/pkg/analyzer/lib/src/generated/exhaustiveness.dart +++ b/pkg/analyzer/lib/src/generated/exhaustiveness.dart @@ -288,6 +288,9 @@ class ExhaustivenessDataForTesting { /// scrutinee. Map switchScrutineeType = {}; + /// Map from switch statement/expression nodes the spaces for its cases. + Map> switchCases = {}; + /// Map from switch case nodes to the space for its pattern/expression. Map caseSpaces = {}; diff --git a/pkg/analyzer/test/id_tests/exhaustiveness_test.dart b/pkg/analyzer/test/id_tests/exhaustiveness_test.dart index a70bc3f25a0..eae8960a207 100644 --- a/pkg/analyzer/test/id_tests/exhaustiveness_test.dart +++ b/pkg/analyzer/test/id_tests/exhaustiveness_test.dart @@ -68,9 +68,19 @@ class _ExhaustivenessDataExtractor extends AstDataExtractor { Features features = Features(); if (node is SwitchStatement || node is SwitchExpression) { StaticType? scrutineeType = _exhaustivenessData.switchScrutineeType[node]; - if (scrutineeType != null) { + List? caseSpaces = _exhaustivenessData.switchCases[node]; + if (scrutineeType != null && caseSpaces != null) { + Set fieldsOfInterest = {}; + for (Space caseSpace in caseSpaces) { + for (SingleSpace singleSpace in caseSpace.singleSpaces) { + fieldsOfInterest.addAll(singleSpace.fields.keys); + } + } features[Tags.scrutineeType] = staticTypeToText(scrutineeType); - features[Tags.scrutineeFields] = fieldsToText(scrutineeType.fields); + if (fieldsOfInterest.isNotEmpty) { + features[Tags.scrutineeFields] = + fieldsToText(scrutineeType.fields, fieldsOfInterest); + } String? subtypes = typesToText(scrutineeType.subtypes); if (subtypes != null) { features[Tags.subtypes] = subtypes; diff --git a/pkg/front_end/test/id_tests/exhaustiveness_test.dart b/pkg/front_end/test/id_tests/exhaustiveness_test.dart index 93243bfd604..f28e33ab9ab 100644 --- a/pkg/front_end/test/id_tests/exhaustiveness_test.dart +++ b/pkg/front_end/test/id_tests/exhaustiveness_test.dart @@ -81,8 +81,16 @@ class ExhaustivenessDataExtractor extends CfeDataExtractor { features[Tags.expandedSubtypes] = expandedSubtypes; } } - features[Tags.scrutineeFields] = - fieldsToText(result.scrutineeType.fields); + Set fieldsOfInterest = {}; + for (Space caseSpace in result.caseSpaces) { + for (SingleSpace singleSpace in caseSpace.singleSpaces) { + fieldsOfInterest.addAll(singleSpace.fields.keys); + } + } + if (fieldsOfInterest.isNotEmpty) { + features[Tags.scrutineeFields] = + fieldsToText(result.scrutineeType.fields, fieldsOfInterest); + } for (ExhaustivenessError error in result.errors) { if (error is NonExhaustiveError) { features[Tags.error] = errorToText(error);