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 @@ -156,7 +156,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return false;
if (!switchVar.IsSingleDefinition || switchVar.LoadCount != 1)
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;
if (!(switchBlock.Instructions[1] is SwitchInstruction si))
return false;
@ -167,7 +167,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -167,7 +167,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
// this is the special case where `call GetValueOrDefault(ldloca tmp)` is inlined into the switch.
if (!(switchBlock.Instructions[0] is SwitchInstruction si))
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;
switchInst = si;
break;

Loading…
Cancel
Save