Browse Source

Fix #2321: Missing readonly modifier for ref local

pull/2333/head
Siegfried Pammer 4 years ago
parent
commit
4ae41a855e
  1. 12
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/RefLocalsAndReturns.cs
  2. 2
      ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs

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

@ -137,6 +137,13 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -137,6 +137,13 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine("No inlining");
Console.WriteLine(field.GetHashCode());
}
public void RefReadonlyCallVirt(RefLocalsAndReturns provider)
{
ref readonly NormalStruct readonlyRefInstance = ref provider.GetReadonlyRefInstance<NormalStruct>();
Console.WriteLine("No inlining");
readonlyRefInstance.Method();
}
}
private static int[] numbers = new int[10] { 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023 };
@ -156,6 +163,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -156,6 +163,11 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
throw new NotImplementedException();
}
public ref readonly T GetReadonlyRefInstance<T>()
{
throw new NotImplementedException();
}
public void CallOnRefReturn()
{
// Both direct calls:

2
ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs

@ -459,6 +459,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -459,6 +459,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return ldloc.Variable.IsRefReadOnly;
case Call call:
return call.Method.ReturnTypeIsRefReadOnly;
case CallVirt call:
return call.Method.ReturnTypeIsRefReadOnly;
case CallIndirect calli:
return calli.FunctionPointerType.ReturnIsRefReadOnly;
case AddressOf _:

Loading…
Cancel
Save