Browse Source

ref structs cannot be boxed

pull/3500/head
Siegfried Pammer 1 month ago
parent
commit
27e4bc578b
  1. 4
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/Conversions.cs
  2. 2
      ICSharpCode.Decompiler/CSharp/Resolver/CSharpConversions.cs

4
ICSharpCode.Decompiler.Tests/TestCases/Correctness/Conversions.cs

@ -112,7 +112,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -112,7 +112,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
Console.WriteLine(ReadZeroTerminatedString("Hello World!".Length));
C1.Test();
#if ROSLYN2 && !NET40
#if CS120 && !NET40
C3.Run();
#endif
}
@ -204,7 +204,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -204,7 +204,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
}
}
#if ROSLYN2 && !NET40
#if CS120 && !NET40
class C3
{
[InlineArray(4)] struct MyArray { private int elem; }

2
ICSharpCode.Decompiler/CSharp/Resolver/CSharpConversions.cs

@ -779,7 +779,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver @@ -779,7 +779,7 @@ namespace ICSharpCode.Decompiler.CSharp.Resolver
{
// C# 4.0 spec: §6.1.7
fromType = NullableType.GetUnderlyingType(fromType);
if (fromType.IsReferenceType == false && toType.IsReferenceType == true)
if (fromType.IsReferenceType == false && !fromType.IsByRefLike && toType.IsReferenceType == true)
return IsSubtypeOf(fromType, toType, 0);
else
return false;

Loading…
Cancel
Save