@@ -10,13 +10,15 @@ namespace Semmle.Extraction.CSharp.Entities
1010{
1111 internal class Parameter : CachedSymbol < IParameterSymbol > , IExpressionParentEntity
1212 {
13- protected IEntity ? Parent { get ; set ; }
13+ protected IEntity Parent { get ; set ; }
1414 protected Parameter Original { get ; }
1515
1616 protected Parameter ( Context cx , IParameterSymbol init , IEntity ? parent , Parameter ? original )
1717 : base ( cx , init )
1818 {
19- Parent = parent ;
19+ Parent = parent
20+ ?? Method . Create ( Context , Symbol . ContainingSymbol as IMethodSymbol )
21+ ?? throw new InternalError ( Symbol , "Couldn't get parent of symbol." ) ;
2022 Original = original ?? this ;
2123 }
2224
@@ -63,12 +65,6 @@ public static Parameter Create(Context cx, IParameterSymbol param) =>
6365
6466 public override void WriteId ( EscapingTextWriter trapFile )
6567 {
66- if ( Parent is null )
67- Parent = Method . Create ( Context , Symbol . ContainingSymbol as IMethodSymbol ) ;
68-
69- if ( Parent is null )
70- throw new InternalError ( Symbol , "Couldn't get parent of symbol." ) ;
71-
7268 trapFile . WriteSubId ( Parent ) ;
7369 trapFile . Write ( '_' ) ;
7470 trapFile . Write ( Ordinal ) ;
@@ -99,7 +95,7 @@ public override void Populate(TextWriter trapFile)
9995 Context . ModelError ( Symbol , "Inconsistent parameter declaration" ) ;
10096
10197 var type = Type . Create ( Context , Symbol . Type ) ;
102- trapFile . @params ( this , Name , type . TypeRef , Ordinal , ParamKind , Parent ! , Original ) ;
98+ trapFile . @params ( this , Name , type . TypeRef , Ordinal , ParamKind , Parent , Original ) ;
10399
104100 foreach ( var l in Symbol . Locations )
105101 trapFile . param_location ( this , Context . CreateLocation ( l ) ) ;
@@ -232,11 +228,11 @@ public override void Populate(TextWriter trapFile)
232228 {
233229 var typeKey = VarargsType . Create ( Context ) ;
234230 // !! Maybe originaldefinition is wrong
235- trapFile . @params ( this , "" , typeKey , Ordinal , Kind . None , Parent ! , this ) ;
231+ trapFile . @params ( this , "" , typeKey , Ordinal , Kind . None , Parent , this ) ;
236232 trapFile . param_location ( this , GeneratedLocation . Create ( Context ) ) ;
237233 }
238234
239- protected override int Ordinal => ( ( Method ) Parent ! ) . OriginalDefinition . Symbol . Parameters . Length ;
235+ protected override int Ordinal => ( ( Method ) Parent ) . OriginalDefinition . Symbol . Parameters . Length ;
240236
241237 public override int GetHashCode ( )
242238 {
0 commit comments