@@ -28,20 +28,20 @@ internal static Expression Create(Context cx, PatternSyntax syntax, IExpressionP
28
28
case DeclarationPatternSyntax declPattern :
29
29
// Creates a single local variable declaration.
30
30
{
31
- if ( declPattern . Designation is VariableDesignationSyntax designation )
31
+ switch ( declPattern . Designation )
32
32
{
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 _:
40
41
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 ") ;
43
44
}
44
- throw new InternalError ( declPattern , "Declaration pattern not handled" ) ;
45
45
}
46
46
47
47
case RecursivePatternSyntax recPattern :
@@ -59,7 +59,6 @@ internal static Expression Create(Context cx, PatternSyntax syntax, IExpressionP
59
59
if ( cx . GetModel ( syntax ) . GetDeclaredSymbol ( varDesignation ) is ILocalSymbol symbol )
60
60
{
61
61
var type = symbol . GetAnnotatedType ( ) ;
62
-
63
62
return VariableDeclaration . Create ( cx , symbol , type , null , cx . CreateLocation ( syntax . GetLocation ( ) ) , true , parent , child ) ;
64
63
}
65
64
0 commit comments