Browse Source

Fix `in` erroneously being applied to `this`

pull/3682/head
nikitalita 3 weeks ago
parent
commit
7d88d43a92
  1. 5
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/RefLocalsAndReturns.cs
  2. 2
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

5
ICSharpCode.Decompiler.Tests/TestCases/Pretty/RefLocalsAndReturns.cs

@ -320,6 +320,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -320,6 +320,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine(ElementAtOrDefault(-5));
}
public void CallWithTemplatedInParameterOnSelf()
{
M2<RefLocalsAndReturns>(this);
}
#if CS120
public ref readonly int M(in int x)
{

2
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -4376,7 +4376,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -4376,7 +4376,7 @@ namespace ICSharpCode.Decompiler.CSharp
{
if (!(input.Expression is DirectionExpression dirExpr && input.ResolveResult is ByReferenceResolveResult brrr))
return input;
if (isAddressOf && kind is ReferenceKind.In or ReferenceKind.RefReadOnly)
if ((isAddressOf || dirExpr.Expression is ThisReferenceExpression) && kind is ReferenceKind.In or ReferenceKind.RefReadOnly)
{
return input.UnwrapChild(dirExpr.Expression);
}

Loading…
Cancel
Save