Browse Source

Fix #868: incorrect inlining of readonly fields.

pull/870/merge
Daniel Grunwald 8 years ago
parent
commit
46e36f7e9a
  1. 3
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/ValueTypeCall.cs
  2. 2
      ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs

3
ICSharpCode.Decompiler.Tests/TestCases/Correctness/ValueTypeCall.cs

@ -81,6 +81,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -81,6 +81,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
MutValueType v = MutableField;
v.Increment();
Console.WriteLine("Final value in MutableField: " + MutableField.val);
// Read-only field copies cannot be inlined for static methods:
MutValueType localCopy = ReadonlyField;
RefParameter(ref localCopy);
}
static void Box()

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

@ -209,7 +209,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -209,7 +209,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
// allow inlining field access only if it's a readonly field
IField f = (((LdObj)inlinedExpression).Target as IInstructionWithFieldOperand)?.Field;
if (f != null && f.IsReadOnly)
return true;
break;
return f != null && f.IsReadOnly;
case OpCode.Call:
var m = ((CallInstruction)inlinedExpression).Method;

Loading…
Cancel
Save