Browse Source

Fix #1455: NRE in MatchRoslynSwitchOnNullable

pull/1464/head
Siegfried Pammer 7 years ago
parent
commit
d4d647bbad
  1. 4
      ICSharpCode.Decompiler/IL/Transforms/SwitchOnNullableTransform.cs

4
ICSharpCode.Decompiler/IL/Transforms/SwitchOnNullableTransform.cs

@ -156,7 +156,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false; return false;
if (!switchVar.IsSingleDefinition || switchVar.LoadCount != 1) if (!switchVar.IsSingleDefinition || switchVar.LoadCount != 1)
return false; return false;
if (!NullableLiftingTransform.MatchGetValueOrDefault(getValueOrDefault, out ILInstruction target2) && target2.Match(target).Success) if (!(NullableLiftingTransform.MatchGetValueOrDefault(getValueOrDefault, out ILInstruction target2) && target2.Match(target).Success))
return false; return false;
if (!(switchBlock.Instructions[1] is SwitchInstruction si)) if (!(switchBlock.Instructions[1] is SwitchInstruction si))
return false; return false;
@ -167,7 +167,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
// this is the special case where `call GetValueOrDefault(ldloca tmp)` is inlined into the switch. // this is the special case where `call GetValueOrDefault(ldloca tmp)` is inlined into the switch.
if (!(switchBlock.Instructions[0] is SwitchInstruction si)) if (!(switchBlock.Instructions[0] is SwitchInstruction si))
return false; return false;
if (!NullableLiftingTransform.MatchGetValueOrDefault(si.Value, out ILInstruction target2) && target2.Match(target).Success) if (!(NullableLiftingTransform.MatchGetValueOrDefault(si.Value, out ILInstruction target2) && target2.Match(target).Success))
return false; return false;
switchInst = si; switchInst = si;
break; break;

Loading…
Cancel
Save