@@ -13,14 +13,14 @@ internal class VariableDeclaration : Expression
1313 {
1414 private VariableDeclaration ( IExpressionInfo info ) : base ( info ) { }
1515
16- public static VariableDeclaration Create ( Context cx , ISymbol symbol , AnnotatedTypeSymbol ? type , TypeSyntax ? optionalSyntax , Location exprLocation , bool isVar , IExpressionParentEntity parent , int child , bool isPattern = false )
16+ public static VariableDeclaration Create ( Context cx , ISymbol symbol , AnnotatedTypeSymbol ? type , TypeSyntax ? optionalSyntax , Location exprLocation , bool isVar , IExpressionParentEntity parent , int child , bool createAccess = true )
1717 {
1818 var ret = new VariableDeclaration ( new ExpressionInfo ( cx , type , exprLocation , ExprKind . LOCAL_VAR_DECL , parent , child , isCompilerGenerated : false , null ) ) ;
1919 cx . Try ( null , null , ( ) =>
2020 {
2121 var l = LocalVariable . Create ( cx , symbol ) ;
2222 l . PopulateManual ( ret , isVar ) ;
23- if ( isPattern )
23+ if ( createAccess )
2424 ret . CreateDefiningAccess ( l , type ) ;
2525 if ( optionalSyntax is not null )
2626 TypeMention . Create ( cx , optionalSyntax , ret , type ) ;
@@ -43,6 +43,9 @@ private static VariableDeclaration CreateSingle(Context cx, DeclarationExpressio
4343 {
4444 var l = LocalVariable . Create ( cx , variableSymbol ) ;
4545 l . PopulateManual ( ret , node . Type . IsVar ) ;
46+ // An out declaration is itself the access in the QL model.
47+ if ( node . Parent is not ArgumentSyntax argument || ! argument . RefOrOutKeyword . IsKind ( SyntaxKind . OutKeyword ) )
48+ ret . CreateDefiningAccess ( l , type ) ;
4649 } ) ;
4750 return ret ;
4851 }
@@ -88,7 +91,7 @@ public static Expression CreateParenthesized(Context cx, VarPatternSyntax varPat
8891 case SingleVariableDesignationSyntax single :
8992 if ( cx . GetModel ( variable ) . GetDeclaredSymbol ( single ) is ILocalSymbol local )
9093 {
91- sub = Create ( cx , local , local . GetAnnotatedType ( ) , null , cx . CreateLocation ( single . FixedLocation ( ) ) , true , tuple , child0 ++ , isPattern : true ) ;
94+ sub = Create ( cx , local , local . GetAnnotatedType ( ) , null , cx . CreateLocation ( single . FixedLocation ( ) ) , true , tuple , child0 ++ ) ;
9295 }
9396 else
9497 {
@@ -159,6 +162,7 @@ public static VariableDeclaration Create(Context cx, CatchDeclarationSyntax d, b
159162 var declSymbol = cx . GetModel ( d ) . GetDeclaredSymbol ( d ) ! ;
160163 var l = LocalVariable . Create ( cx , declSymbol ) ;
161164 l . PopulateManual ( ret , isVar ) ;
165+ ret . CreateDefiningAccess ( l , type ) ;
162166 TypeMention . Create ( cx , d . Type , ret , type ) ;
163167 } ) ;
164168 return ret ;
@@ -172,10 +176,10 @@ public static VariableDeclaration CreateDeclarator(Context cx, VariableDeclarato
172176 var declSymbol = cx . GetModel ( d ) . GetDeclaredSymbol ( d ) ! ;
173177 var localVar = LocalVariable . Create ( cx , declSymbol ) ;
174178 localVar . PopulateManual ( ret , isVar ) ;
179+ ret . CreateDefiningAccess ( localVar , type ) ;
175180
176181 if ( d . Initializer is not null )
177182 {
178- ret . CreateDefiningAccess ( localVar , type ) ;
179183 Create ( cx , d . Initializer . Value , ret , 1 ) ;
180184 }
181185
0 commit comments