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