@@ -67,27 +67,23 @@ class CasePattern : Case<CasePatternSwitchLabelSyntax>
6767 private CasePattern ( Context cx , CasePatternSwitchLabelSyntax node , Switch parent , int child )
6868 : base ( cx , node , parent , child ) { }
6969
70- private void PopulatePattern ( PatternSyntax pattern , TypeSyntax optionalType , SyntaxToken varKeyword , VariableDesignationSyntax designation )
70+ private void PopulatePattern ( PatternSyntax pattern , TypeSyntax optionalType , VariableDesignationSyntax designation )
7171 {
7272 var isVar = optionalType is null ;
73- if ( ! isVar )
74- Expressions . TypeAccess . Create ( cx , optionalType , this , 1 ) ;
75-
7673 switch ( designation )
7774 {
7875 case SingleVariableDesignationSyntax _:
7976 if ( cx . Model ( pattern ) . GetDeclaredSymbol ( designation ) is ILocalSymbol symbol )
8077 {
8178 var type = Type . Create ( cx , symbol . Type ) ;
82-
83- if ( isVar )
84- new Expression ( new ExpressionInfo ( cx , type , cx . Create ( varKeyword . GetLocation ( ) ) , ExprKind . TYPE_ACCESS , this , 1 , false , null ) ) ;
85-
8679 Expressions . VariableDeclaration . Create ( cx , symbol , type , cx . Create ( pattern . GetLocation ( ) ) , cx . Create ( designation . GetLocation ( ) ) , isVar , this , 0 ) ;
8780 }
8881 break ;
8982 case DiscardDesignationSyntax discard :
90- new Expressions . Discard ( cx , discard , this , 0 ) ;
83+ if ( ! isVar )
84+ Expressions . TypeAccess . Create ( cx , optionalType , this , 0 ) ;
85+ else
86+ new Expressions . Discard ( cx , discard , this , 0 ) ;
9187 break ;
9288 case null :
9389 break ;
@@ -104,10 +100,10 @@ protected override void Populate()
104100 switch ( Stmt . Pattern )
105101 {
106102 case VarPatternSyntax varPattern :
107- PopulatePattern ( varPattern , null , varPattern . VarKeyword , varPattern . Designation ) ;
103+ PopulatePattern ( varPattern , null , varPattern . Designation ) ;
108104 break ;
109105 case DeclarationPatternSyntax declarationPattern :
110- PopulatePattern ( declarationPattern , declarationPattern . Type , default ( SyntaxToken ) , declarationPattern . Designation ) ;
106+ PopulatePattern ( declarationPattern , declarationPattern . Type , declarationPattern . Designation ) ;
111107 break ;
112108 case ConstantPatternSyntax pattern :
113109 Expression . Create ( cx , pattern . Expression , this , 0 ) ;
@@ -121,7 +117,7 @@ protected override void Populate()
121117
122118 if ( Stmt . WhenClause != null )
123119 {
124- Expression . Create ( cx , Stmt . WhenClause . Condition , this , 2 ) ;
120+ Expression . Create ( cx , Stmt . WhenClause . Condition , this , 1 ) ;
125121 }
126122 }
127123
0 commit comments