Skip to content

Commit

Permalink
Update hidden this param type, closes 0xd4d#392
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsck committed Sep 14, 2020
1 parent 98ea089 commit 3532ba7
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/DotNet/ParameterList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,25 @@ internal void UpdateThisParameterType(TypeDef methodDeclaringType) {
#endif
if (methodDeclaringType is null)
hiddenThisParameter.Type = null;
else if (methodDeclaringType.IsValueType)
hiddenThisParameter.Type = new ByRefSig(new ValueTypeSig(methodDeclaringType));
else
hiddenThisParameter.Type = new ClassSig(methodDeclaringType);
else {
bool isValueType = methodDeclaringType.IsValueType;
ClassOrValueTypeSig instSig;
if (isValueType)
instSig = new ValueTypeSig(methodDeclaringType);
else
instSig = new ClassSig(methodDeclaringType);
TypeSig thisTypeSig;
if (methodDeclaringType.HasGenericParameters) {
int gpCount = methodDeclaringType.GenericParameters.Count;
var genArgs = new List<TypeSig>(gpCount);
for (int i = 0; i < gpCount; i++)
genArgs.Add(new GenericVar(i, methodDeclaringType));
thisTypeSig = new GenericInstSig(instSig, genArgs);
}
else
thisTypeSig = instSig;
hiddenThisParameter.Type = isValueType ? new ByRefSig(thisTypeSig) : thisTypeSig;
}
#if THREAD_SAFE
} finally { theLock.ExitWriteLock(); }
#endif
Expand Down

0 comments on commit 3532ba7

Please sign in to comment.