Browse Source

Fix #1760: NRE in ILInlining, if nullable.rewrap is used with an expression that has a type parameter as its type.

pull/1790/head
Siegfried Pammer 6 years ago
parent
commit
ea3a005908
  1. 7
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Generics.cs
  2. 3
      ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs

7
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Generics.cs

@ -24,10 +24,17 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -24,10 +24,17 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
private class GenericClass<T>
{
private readonly T issue1760;
public void M(out GenericClass<T> self)
{
self = this;
}
public void Issue1760()
{
Console.WriteLine(", " + issue1760);
}
}
public class BaseClass

3
ICSharpCode.Decompiler/IL/Transforms/ILInlining.cs

@ -269,6 +269,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -269,6 +269,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
internal static bool MethodRequiresCopyForReadonlyLValue(IMethod method)
{
if (method == null)
return true;
var type = method.DeclaringType;
if (type.IsReferenceType == true)
return false; // reference types are never implicitly copied
@ -303,6 +305,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -303,6 +305,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
return !method.IsStatic;
case OpCode.Await:
method = ((Await)inst.Parent).GetAwaiterMethod;
return true;
case OpCode.NullableUnwrap:
return ((NullableUnwrap)inst.Parent).RefInput;

Loading…
Cancel
Save