@@ -10,15 +10,13 @@ namespace Semmle.Extraction.CSharp.Entities
10
10
{
11
11
internal class Parameter : CachedSymbol < IParameterSymbol > , IExpressionParentEntity
12
12
{
13
- protected IEntity Parent { get ; set ; }
13
+ protected IEntity ? Parent { get ; set ; }
14
14
protected Parameter Original { get ; }
15
15
16
16
protected Parameter ( Context cx , IParameterSymbol init , IEntity ? parent , Parameter ? original )
17
17
: base ( cx , init )
18
18
{
19
- Parent = parent
20
- ?? Method . Create ( Context , Symbol . ContainingSymbol as IMethodSymbol )
21
- ?? throw new InternalError ( Symbol , "Couldn't get parent of symbol." ) ;
19
+ Parent = parent ;
22
20
Original = original ?? this ;
23
21
}
24
22
@@ -65,6 +63,12 @@ public static Parameter Create(Context cx, IParameterSymbol param) =>
65
63
66
64
public override void WriteId ( EscapingTextWriter trapFile )
67
65
{
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
+
68
72
trapFile . WriteSubId ( Parent ) ;
69
73
trapFile . Write ( '_' ) ;
70
74
trapFile . Write ( Ordinal ) ;
@@ -95,7 +99,7 @@ public override void Populate(TextWriter trapFile)
95
99
Context . ModelError ( Symbol , "Inconsistent parameter declaration" ) ;
96
100
97
101
var type = Type . Create ( Context , Symbol . Type ) ;
98
- trapFile . @params ( this , Name , type . TypeRef , Ordinal , ParamKind , Parent , Original ) ;
102
+ trapFile . @params ( this , Name , type . TypeRef , Ordinal , ParamKind , Parent ! , Original ) ;
99
103
100
104
foreach ( var l in Symbol . Locations )
101
105
trapFile . param_location ( this , Context . CreateLocation ( l ) ) ;
@@ -228,11 +232,11 @@ public override void Populate(TextWriter trapFile)
228
232
{
229
233
var typeKey = VarargsType . Create ( Context ) ;
230
234
// !! Maybe originaldefinition is wrong
231
- trapFile . @params ( this , "" , typeKey , Ordinal , Kind . None , Parent , this ) ;
235
+ trapFile . @params ( this , "" , typeKey , Ordinal , Kind . None , Parent ! , this ) ;
232
236
trapFile . param_location ( this , GeneratedLocation . Create ( Context ) ) ;
233
237
}
234
238
235
- protected override int Ordinal => ( ( Method ) Parent ) . OriginalDefinition . Symbol . Parameters . Length ;
239
+ protected override int Ordinal => ( ( Method ) Parent ! ) . OriginalDefinition . Symbol . Parameters . Length ;
236
240
237
241
public override int GetHashCode ( )
238
242
{
0 commit comments