Browse Source

Fix #1779: Do not inline compound assignment target, if it is a temporary struct.

pull/1790/head
Siegfried Pammer 6 years ago
parent
commit
a781e37d98
  1. 572
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs
  2. 13
      ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs

572
ICSharpCode.Decompiler.Tests/TestCases/Pretty/CompoundAssignmentTest.cs

File diff suppressed because it is too large Load Diff

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

@ -299,9 +299,16 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -299,9 +299,16 @@ namespace ICSharpCode.Decompiler.IL.Transforms
case OpCode.Call:
case OpCode.CallVirt:
method = ((CallInstruction)inst.Parent).Method;
if (method.IsAccessor && method.AccessorKind != MethodSemanticsAttributes.Getter) {
// C# doesn't allow calling setters on temporary structs
return false;
if (method.IsAccessor) {
if (method.AccessorKind == MethodSemanticsAttributes.Getter) {
// C# doesn't allow property compound assignments on temporary structs
return !(inst.Parent.Parent is CompoundAssignmentInstruction cai
&& cai.TargetKind == CompoundTargetKind.Property
&& cai.Target == inst.Parent);
} else {
// C# doesn't allow calling setters on temporary structs
return false;
}
}
return !method.IsStatic;
case OpCode.Await:

Loading…
Cancel
Save