diff --git a/src/mscorlib/shared/System/Reflection/TypeDelegator.cs b/src/mscorlib/shared/System/Reflection/TypeDelegator.cs index ac3972fb7cc3..e0be6e87b652 100644 --- a/src/mscorlib/shared/System/Reflection/TypeDelegator.cs +++ b/src/mscorlib/shared/System/Reflection/TypeDelegator.cs @@ -112,6 +112,9 @@ public TypeDelegator(Type delegatingType) protected override bool IsCOMObjectImpl() => typeImpl.IsCOMObject; public override bool IsByRefLike => typeImpl.IsByRefLike; public override bool IsConstructedGenericType => typeImpl.IsConstructedGenericType; + + public override bool IsCollectible => typeImpl.IsCollectible; + public override Type GetElementType() => typeImpl.GetElementType(); protected override bool HasElementTypeImpl() => typeImpl.HasElementType; diff --git a/src/mscorlib/shared/System/Type.cs b/src/mscorlib/shared/System/Type.cs index 6b6a7b37699b..a0d219ddd4ab 100644 --- a/src/mscorlib/shared/System/Type.cs +++ b/src/mscorlib/shared/System/Type.cs @@ -102,6 +102,8 @@ public virtual Type[] GetGenericParameterConstraints() public bool IsContextful => IsContextfulImpl(); protected virtual bool IsContextfulImpl() => false; + public virtual bool IsCollectible => true; + public virtual bool IsEnum => IsSubclassOf(typeof(Enum)); public bool IsMarshalByRef => IsMarshalByRefImpl(); protected virtual bool IsMarshalByRefImpl() => false; diff --git a/src/mscorlib/src/System/RtType.cs b/src/mscorlib/src/System/RtType.cs index 9e78e822dfe5..d4afc8a74a01 100644 --- a/src/mscorlib/src/System/RtType.cs +++ b/src/mscorlib/src/System/RtType.cs @@ -2459,7 +2459,7 @@ private RuntimeTypeCache Cache IntPtr gcHandle = Interlocked.CompareExchange(ref m_cache, newgcHandle, IntPtr.Zero); // Leak the handle if the type is collectible. It will be reclaimed when // the type goes away. - if (gcHandle != IntPtr.Zero && !IsCollectible()) + if (gcHandle != IntPtr.Zero && !IsCollectible) GCHandle.InternalFree(newgcHandle); } @@ -3151,10 +3151,7 @@ internal sealed override RuntimeTypeHandle GetTypeHandleInternal() return new RuntimeTypeHandle(this); } - internal bool IsCollectible() - { - return RuntimeTypeHandle.IsCollectible(GetTypeHandleInternal()); - } + public sealed override bool IsCollectible => RuntimeTypeHandle.IsCollectible(GetTypeHandleInternal()); protected override TypeCode GetTypeCodeImpl() {