From 9aa607be455d6d3b013fdb8caaabda600d649fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Mon, 15 May 2017 13:06:44 -0700 Subject: Finish support for rank 1 mdarrays (#3610) Three parts: 1. Update casting logic to allow casting SzArray to rank 1 MdArray (but not the other way around) 2. Update MdArray rank 1 methods to be able to operate on SzArrays 3. Update array creation path to emulate the behavior where allocating rank 1 MdArray with 0 lower bounds actually gives you an SzArray Third bullet point makes this the most annoying, because we can't reliably support `newobj instance void int32[0...]::.ctor(int32)` without hitting the type loader. I was also considering adding an optional field on Rank 1 MdArrays that lets you get to the SzArray's EEType from it. It might be better. Fixes #3331. --- src/ILCompiler.TypeSystem/tests/CastingTests.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/ILCompiler.TypeSystem') diff --git a/src/ILCompiler.TypeSystem/tests/CastingTests.cs b/src/ILCompiler.TypeSystem/tests/CastingTests.cs index b2771234c..573bc1822 100644 --- a/src/ILCompiler.TypeSystem/tests/CastingTests.cs +++ b/src/ILCompiler.TypeSystem/tests/CastingTests.cs @@ -73,6 +73,7 @@ namespace TypeSystemTests TypeDesc shortBasedEnumType = _testModule.GetType("Casting", "ShortBasedEnum"); Assert.True(intType.MakeArrayType().CanCastTo(uintType.MakeArrayType())); + Assert.True(intType.MakeArrayType().CanCastTo(uintType.MakeArrayType(1))); Assert.False(intType.CanCastTo(uintType)); Assert.True(byteType.MakeArrayType().CanCastTo(sbyteType.MakeArrayType())); @@ -121,7 +122,9 @@ namespace TypeSystemTests TypeDesc stringSzArrayType = stringType.MakeArrayType(); TypeDesc objectSzArrayType = objectType.MakeArrayType(); - Assert.False(intSzArrayType.CanCastTo(intArray1Type)); + Assert.True(intSzArrayType.CanCastTo(intArray1Type)); + Assert.False(intArray1Type.CanCastTo(intSzArrayType)); + Assert.False(intArray1Type.CanCastTo(intArray2Type)); Assert.True(intSzArrayType.CanCastTo(arrayType)); -- cgit v1.2.3