@@ -28,20 +28,20 @@ internal static Expression Create(Context cx, PatternSyntax syntax, IExpressionP
2828 case DeclarationPatternSyntax declPattern :
2929 // Creates a single local variable declaration.
3030 {
31- if ( declPattern . Designation is VariableDesignationSyntax designation )
31+ switch ( declPattern . Designation )
3232 {
33- if ( cx . GetModel ( syntax ) . GetDeclaredSymbol ( designation ) is ILocalSymbol symbol )
34- {
35- var type = symbol . GetAnnotatedType ( ) ;
36- return VariableDeclaration . Create ( cx , symbol , type , declPattern . Type , cx . CreateLocation ( syntax . GetLocation ( ) ) , false , parent , child ) ;
37- }
38- if ( designation is DiscardDesignationSyntax )
39- {
33+ case SingleVariableDesignationSyntax singleDesignation :
34+ if ( cx . GetModel ( syntax ) . GetDeclaredSymbol ( singleDesignation ) is ILocalSymbol symbol )
35+ {
36+ var type = symbol . GetAnnotatedType ( ) ;
37+ return VariableDeclaration . Create ( cx , symbol , type , declPattern . Type , cx . CreateLocation ( syntax . GetLocation ( ) ) , false , parent , child ) ;
38+ }
39+ throw new InternalError ( singleDesignation , "Unable to get the declared symbol of the declaration pattern designation." ) ;
40+ case DiscardDesignationSyntax _:
4041 return Expressions . TypeAccess . Create ( cx , declPattern . Type , parent , child ) ;
41- }
42- throw new InternalError ( designation , "Designation pattern not handled ") ;
42+ default :
43+ throw new InternalError ( $ "declaration pattern designation of type { declPattern . Designation . GetType ( ) } is unhandled ") ;
4344 }
44- throw new InternalError ( declPattern , "Declaration pattern not handled" ) ;
4545 }
4646
4747 case RecursivePatternSyntax recPattern :
@@ -59,7 +59,6 @@ internal static Expression Create(Context cx, PatternSyntax syntax, IExpressionP
5959 if ( cx . GetModel ( syntax ) . GetDeclaredSymbol ( varDesignation ) is ILocalSymbol symbol )
6060 {
6161 var type = symbol . GetAnnotatedType ( ) ;
62-
6362 return VariableDeclaration . Create ( cx , symbol , type , null , cx . CreateLocation ( syntax . GetLocation ( ) ) , true , parent , child ) ;
6463 }
6564
0 commit comments