Skip to content
Permalink
Browse files

Fix #882: Don't inline value-type temporaries for setter calls.

  • Loading branch information...
dgrunwald committed Mar 15, 2019
1 parent a5505ab commit 4ad4f6a2327b96c96187a3faa2a1b42fac7c7e99
@@ -480,8 +480,14 @@ public void ForEachBreakWhenFound(string name, ref StringComparison output)
public void ForEachOverListOfStruct(List<DataItem> items, int value)
{
foreach (DataItem item in items) {
#if ROSLYN && OPT
// The variable name differs based on whether roslyn optimizes out the 'item' variable
DataItem current = item;
current.Property = value;
#else
DataItem dataItem = item;
dataItem.Property = value;
#endif
}
}

@@ -671,7 +677,7 @@ public void WhileLoop()
}

//other configurations work fine, just with different labels
#if OPT && !MCS
#if OPT && !MCS
public void WhileWithGoto()
{
while (Condition("Main Loop")) {
@@ -19,6 +19,7 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using ICSharpCode.Decompiler.TypeSystem;

namespace ICSharpCode.Decompiler.IL.Transforms
@@ -275,7 +276,12 @@ internal static bool IsUsedAsThisPointerInCall(LdLoca ldloca)
switch (ldloca.Parent.OpCode) {
case OpCode.Call:
case OpCode.CallVirt:
return !((CallInstruction)ldloca.Parent).Method.IsStatic;
var method = ((CallInstruction)ldloca.Parent).Method;
if (method.IsAccessor && method.AccessorKind != MethodSemanticsAttributes.Getter) {
// C# doesn't allow calling setters on temporary structs
return false;
}
return !method.IsStatic;
case OpCode.Await:
return true;
default:

0 comments on commit 4ad4f6a

Please sign in to comment.
You can’t perform that action at this time.