Skip to content

Commit 3b20c71

Browse files
ref structs cannot be boxed
1 parent b05b923 commit 3b20c71

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static void Main(string[] args)
112112

113113
Console.WriteLine(ReadZeroTerminatedString("Hello World!".Length));
114114
C1.Test();
115-
#if ROSLYN2 && !NET40
115+
#if CS120 && !NET40
116116
C3.Run();
117117
#endif
118118
}
@@ -204,7 +204,7 @@ public static implicit operator C1(C2 c)
204204
}
205205
}
206206

207-
#if ROSLYN2 && !NET40
207+
#if CS120 && !NET40
208208
class C3
209209
{
210210
[InlineArray(4)] struct MyArray { private int elem; }

ICSharpCode.Decompiler/CSharp/Resolver/CSharpConversions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ bool IsBoxingConversion(IType fromType, IType toType)
779779
{
780780
// C# 4.0 spec: §6.1.7
781781
fromType = NullableType.GetUnderlyingType(fromType);
782-
if (fromType.IsReferenceType == false && toType.IsReferenceType == true)
782+
if (fromType.IsReferenceType == false && !fromType.IsByRefLike && toType.IsReferenceType == true)
783783
return IsSubtypeOf(fromType, toType, 0);
784784
else
785785
return false;

0 commit comments

Comments
 (0)