diff options
author | Michal Strehovský <MichalStrehovsky@users.noreply.github.com> | 2017-08-22 01:41:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-22 01:41:52 +0300 |
commit | f23fb52ce14fa680bcebc07eab9a20fa8780e47f (patch) | |
tree | 5ee00590c5f99b471a5916c82f05823606bedf13 /src/ILCompiler.TypeSystem | |
parent | 6468f5fc5da3d39ad0515a8821f246e988aca662 (diff) |
Emit IsByRefLike flag on generic definitions (#4346)
Also took the opportunity to make the IsByRefLike flag not be a property
of the field layout (but use the newly approved custom attribute that
everyone else uses).
Fixes #4220.
Diffstat (limited to 'src/ILCompiler.TypeSystem')
3 files changed, 14 insertions, 14 deletions
diff --git a/src/ILCompiler.TypeSystem/tests/CoreTestAssembly/InstanceFieldLayout.cs b/src/ILCompiler.TypeSystem/tests/CoreTestAssembly/InstanceFieldLayout.cs index 912d7e778..2deac86e1 100644 --- a/src/ILCompiler.TypeSystem/tests/CoreTestAssembly/InstanceFieldLayout.cs +++ b/src/ILCompiler.TypeSystem/tests/CoreTestAssembly/InstanceFieldLayout.cs @@ -148,27 +148,24 @@ namespace Sequential namespace IsByRefLike { + [System.Runtime.CompilerServices.IsByRefLike] public struct ByRefLikeStruct { ByReference<object> ByRef; } - public struct ComposedStruct - { - ByRefLikeStruct ByRefLike; - } - public struct NotByRefLike { int X; } - public class Invalid + [System.Runtime.CompilerServices.IsByRefLike] + public class InvalidClass { ByReference<int> ByRef; } - public class ComposedInvalid + public struct InvalidStruct { ByRefLikeStruct ByRefLike; } diff --git a/src/ILCompiler.TypeSystem/tests/CoreTestAssembly/Platform.cs b/src/ILCompiler.TypeSystem/tests/CoreTestAssembly/Platform.cs index b15af240e..2d65cdfff 100644 --- a/src/ILCompiler.TypeSystem/tests/CoreTestAssembly/Platform.cs +++ b/src/ILCompiler.TypeSystem/tests/CoreTestAssembly/Platform.cs @@ -67,12 +67,14 @@ namespace System public class Exception { } + [System.Runtime.CompilerServices.IsByRefLike] public struct TypedReference { private readonly ByReference<byte> _value; private readonly RuntimeTypeHandle _typeHandle; } + [System.Runtime.CompilerServices.IsByRefLike] public struct ByReference<T> { } } @@ -128,3 +130,9 @@ namespace System.Runtime.InteropServices } } +namespace System.Runtime.CompilerServices +{ + public sealed class IsByRefLikeAttribute : Attribute + { + } +} diff --git a/src/ILCompiler.TypeSystem/tests/InstanceFieldLayoutTests.cs b/src/ILCompiler.TypeSystem/tests/InstanceFieldLayoutTests.cs index ef65ceb5d..97e6cb568 100644 --- a/src/ILCompiler.TypeSystem/tests/InstanceFieldLayoutTests.cs +++ b/src/ILCompiler.TypeSystem/tests/InstanceFieldLayoutTests.cs @@ -319,11 +319,6 @@ namespace TypeSystemTests } { - DefType type = _testModule.GetType("IsByRefLike", "ComposedStruct"); - Assert.True(type.IsByRefLike); - } - - { DefType type = _testModule.GetType("IsByRefLike", "NotByRefLike"); Assert.False(type.IsByRefLike); } @@ -333,12 +328,12 @@ namespace TypeSystemTests public void TestInvalidByRefLikeTypes() { { - DefType type = _testModule.GetType("IsByRefLike", "Invalid"); + DefType type = _testModule.GetType("IsByRefLike", "InvalidClass"); Assert.Throws<TypeSystemException.TypeLoadException>(() => type.ComputeInstanceLayout(InstanceLayoutKind.TypeAndFields)); } { - DefType type = _testModule.GetType("IsByRefLike", "ComposedInvalid"); + DefType type = _testModule.GetType("IsByRefLike", "InvalidStruct"); Assert.Throws<TypeSystemException.TypeLoadException>(() => type.ComputeInstanceLayout(InstanceLayoutKind.TypeAndFields)); } } |