@@ -23,17 +23,7 @@ internal PropertyPattern(Context cx, PropertyPatternClauseSyntax pp, IExpression
2323 }
2424 }
2525
26- private class AccessStep
27- {
28- public readonly string Identifier ;
29- public readonly Microsoft . CodeAnalysis . Location Location ;
30-
31- public AccessStep ( string identifier , Microsoft . CodeAnalysis . Location location )
32- {
33- Identifier = identifier ;
34- Location = location ;
35- }
36- }
26+ private record AccessStep ( string Identifier , Microsoft . CodeAnalysis . Location Location ) ;
3727
3828 private class AccessStepPack
3929 {
@@ -47,37 +37,25 @@ public AccessStepPack Add(string identifier, Microsoft.CodeAnalysis.Location loc
4737 return this ;
4838 }
4939
50- public AccessStepPack ( string identifier , Microsoft . CodeAnalysis . Location location )
51- {
40+ public AccessStepPack ( string identifier , Microsoft . CodeAnalysis . Location location ) =>
5241 Last = new AccessStep ( identifier , location ) ;
53- }
5442 }
5543
56- private static AccessStepPack GetAccessStepPack ( ExpressionSyntax syntax )
57- {
58- switch ( syntax )
44+ private static AccessStepPack GetAccessStepPack ( ExpressionSyntax syntax ) =>
45+ syntax switch
5946 {
60- case MemberAccessExpressionSyntax memberAccess :
61- return GetAccessStepPack ( memberAccess . Expression ) . Add ( memberAccess . Name . Identifier . ValueText , memberAccess . Name . Identifier . GetLocation ( ) ) ;
62- case IdentifierNameSyntax identifier :
63- return new AccessStepPack ( identifier . Identifier . Text , identifier . GetLocation ( ) ) ;
64- default :
65- throw new InternalError ( syntax , "Unexpected expression syntax in property patterns." ) ;
66- }
67- }
47+ MemberAccessExpressionSyntax memberAccess => GetAccessStepPack ( memberAccess . Expression ) . Add ( memberAccess . Name . Identifier . ValueText , memberAccess . Name . Identifier . GetLocation ( ) ) ,
48+ IdentifierNameSyntax identifier => new AccessStepPack ( identifier . Identifier . Text , identifier . GetLocation ( ) ) ,
49+ _ => throw new InternalError ( syntax , "Unexpected expression syntax in property patterns." ) ,
50+ } ;
6851
69- private static AccessStepPack GetAccessStepPack ( BaseExpressionColonSyntax syntax )
70- {
71- switch ( syntax )
52+ private static AccessStepPack GetAccessStepPack ( BaseExpressionColonSyntax syntax ) =>
53+ syntax switch
7254 {
73- case NameColonSyntax ncs :
74- return new AccessStepPack ( ncs . Name . ToString ( ) , ncs . Name . GetLocation ( ) ) ;
75- case ExpressionColonSyntax ecs :
76- return GetAccessStepPack ( ecs . Expression ) ;
77- default :
78- throw new InternalError ( syntax , "Unsupported expression colon in property pattern." ) ;
55+ NameColonSyntax ncs => new AccessStepPack ( ncs . Name . ToString ( ) , ncs . Name . GetLocation ( ) ) ,
56+ ExpressionColonSyntax ecs => GetAccessStepPack ( ecs . Expression ) ,
57+ _ => throw new InternalError ( syntax , "Unsupported expression colon in property pattern." ) ,
7958 } ;
80- }
8159
8260 private static Expression CreateSyntheticExp ( Context cx , Microsoft . CodeAnalysis . Location location , IExpressionParentEntity parent , int child ) =>
8361 new Expression ( new ExpressionInfo ( cx , null , cx . CreateLocation ( location ) , ExprKind . PROPERTY_PATTERN , parent , child , false , null ) ) ;
0 commit comments