Browse Source

Fix type of ref-locals when there's ref-assignment involved.

pull/1072/merge
Daniel Grunwald 8 years ago
parent
commit
937b86be68
  1. 2
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

2
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -439,7 +439,7 @@ namespace ICSharpCode.Decompiler.CSharp
if (inst.Variable.Kind == VariableKind.StackSlot && !loadedVariablesSet.Contains(inst.Variable)) { if (inst.Variable.Kind == VariableKind.StackSlot && !loadedVariablesSet.Contains(inst.Variable)) {
// Stack slots in the ILAst have inaccurate types (e.g. System.Object for StackType.O) // Stack slots in the ILAst have inaccurate types (e.g. System.Object for StackType.O)
// so we should replace them with more accurate types where possible: // so we should replace them with more accurate types where possible:
if ((inst.Variable.IsSingleDefinition || IsOtherValueType(translatedValue.Type)) if ((inst.Variable.IsSingleDefinition || IsOtherValueType(translatedValue.Type) || inst.Variable.StackType == StackType.Ref)
&& inst.Variable.StackType == translatedValue.Type.GetStackType() && inst.Variable.StackType == translatedValue.Type.GetStackType()
&& translatedValue.Type.Kind != TypeKind.Null) { && translatedValue.Type.Kind != TypeKind.Null) {
inst.Variable.Type = translatedValue.Type; inst.Variable.Type = translatedValue.Type;

Loading…
Cancel
Save