Browse Source

Relax ExpressionBuilder invariant for lifted instructions with unknown result type.

release/6.2
Daniel Grunwald 5 years ago
parent
commit
103a6461e4
  1. 21
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

21
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -167,16 +167,19 @@ namespace ICSharpCode.Decompiler.CSharp @@ -167,16 +167,19 @@ namespace ICSharpCode.Decompiler.CSharp
}
else if (inst is ILiftableInstruction liftable && liftable.IsLifted)
{
Debug.Assert(NullableType.IsNullable(cexpr.Type));
IType underlying = NullableType.GetUnderlyingType(cexpr.Type);
if (liftable.UnderlyingResultType.IsIntegerType())
if (liftable.UnderlyingResultType != StackType.Unknown)
{
Debug.Assert(underlying.GetStackType().IsIntegerType(), "IL instructions of integer type must convert into C# expressions of integer type");
Debug.Assert(underlying.GetSign() != Sign.None, "Must have a sign specified for zero/sign-extension");
}
else
{
Debug.Assert(underlying.GetStackType() == liftable.UnderlyingResultType);
Debug.Assert(NullableType.IsNullable(cexpr.Type));
IType underlying = NullableType.GetUnderlyingType(cexpr.Type);
if (liftable.UnderlyingResultType.IsIntegerType())
{
Debug.Assert(underlying.GetStackType().IsIntegerType(), "IL instructions of integer type must convert into C# expressions of integer type");
Debug.Assert(underlying.GetSign() != Sign.None, "Must have a sign specified for zero/sign-extension");
}
else
{
Debug.Assert(underlying.GetStackType() == liftable.UnderlyingResultType);
}
}
}
else if (inst.ResultType == StackType.Ref)

Loading…
Cancel
Save