@@ -48,7 +48,7 @@ public static Expression CreatePattern(this Context cx, PatternSyntax syntax, IE
4848 {
4949 var type = Type . Create ( cx , symbol . GetAnnotatedType ( ) ) ;
5050
51- return VariableDeclaration . Create ( cx , symbol , type , null , cx . Create ( syntax . GetLocation ( ) ) , false , parent , child ) ;
51+ return VariableDeclaration . Create ( cx , symbol , type , null , cx . Create ( syntax . GetLocation ( ) ) , true , parent , child ) ;
5252 }
5353 else
5454 {
@@ -138,38 +138,10 @@ private IsPattern(ExpressionNodeInfo info) : base(info.SetKind(ExprKind.IS))
138138 {
139139 }
140140
141- private void PopulatePattern ( PatternSyntax pattern , TypeSyntax optionalType , SyntaxToken varKeyword , VariableDesignationSyntax designation )
142- {
143- var isVar = optionalType is null ;
144- if ( ! ( designation is null ) && cx . GetModel ( pattern ) . GetDeclaredSymbol ( designation ) is ILocalSymbol symbol )
145- {
146- var type = Entities . Type . Create ( cx , symbol . GetAnnotatedType ( ) ) ;
147- VariableDeclaration . Create ( cx , symbol , type , optionalType , cx . Create ( pattern . GetLocation ( ) ) , isVar , this , 1 ) ;
148- }
149- else if ( ! isVar )
150- Expressions . TypeAccess . Create ( cx , optionalType , this , 1 ) ;
151- }
152-
153141 protected override void PopulateExpression ( TextWriter trapFile )
154142 {
155143 Create ( cx , Syntax . Expression , this , 0 ) ;
156- switch ( Syntax . Pattern )
157- {
158- case ConstantPatternSyntax constantPattern :
159- Create ( cx , constantPattern . Expression , this , 1 ) ;
160- return ;
161- case VarPatternSyntax varPattern :
162- PopulatePattern ( varPattern , null , varPattern . VarKeyword , varPattern . Designation ) ;
163- return ;
164- case DeclarationPatternSyntax declPattern :
165- PopulatePattern ( declPattern , declPattern . Type , default ( SyntaxToken ) , declPattern . Designation ) ;
166- return ;
167- case RecursivePatternSyntax recPattern :
168- new RecursivePattern ( cx , recPattern , this , 1 ) ;
169- return ;
170- default :
171- throw new InternalError ( Syntax , "Is pattern not handled" ) ;
172- }
144+ cx . CreatePattern ( Syntax . Pattern , this , 1 ) ;
173145 }
174146
175147 public static Expression Create ( ExpressionNodeInfo info ) => new IsPattern ( info ) . TryPopulate ( ) ;
0 commit comments