File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
ICSharpCode.Decompiler/CSharp/Transforms Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -271,8 +271,15 @@ public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
271271 if ( typeDeclaration . HasPrimaryConstructor )
272272 {
273273 inPrimaryConstructor = true ;
274- typeDeclaration . PrimaryConstructorParameters . AcceptVisitor ( this ) ;
275- inPrimaryConstructor = false ;
274+
275+ try
276+ {
277+ typeDeclaration . PrimaryConstructorParameters . AcceptVisitor ( this ) ;
278+ }
279+ finally
280+ {
281+ inPrimaryConstructor = false ;
282+ }
276283 }
277284
278285 var previousResolver = resolver ;
@@ -294,6 +301,11 @@ public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
294301
295302 public override void VisitParameterDeclaration ( ParameterDeclaration parameterDeclaration )
296303 {
304+ // Parameters of primary constructors are visited separately from the rest of the
305+ // type declaration since their types are at the same scope as the type declaration
306+ // and so need to use the outer resolver. This check ensures that the visitor only
307+ // runs once per parameter since their AstNodes will get revisited by the call to
308+ // `base.VisitTypeDeclaration(typeDeclaration)` in `VisitTypeDeclaration` above.
297309 if ( inPrimaryConstructor || parameterDeclaration . Parent is not TypeDeclaration )
298310 base . VisitParameterDeclaration ( parameterDeclaration ) ;
299311 }
You can’t perform that action at this time.
0 commit comments