Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ internal static CustomAttributeEncoding TypeToCustomAttributeEncoding(RuntimeTyp
if (type.IsClass)
return CustomAttributeEncoding.Object;

if (type.IsInterface)
if (type.IsActualInterface)
return CustomAttributeEncoding.Object;

if (type.IsActualValueType)
Expand Down Expand Up @@ -2263,7 +2263,7 @@ internal static bool IsDefined(RuntimeFieldInfo field, RuntimeType? caType)

internal static StructLayoutAttribute? GetStructLayoutCustomAttribute(RuntimeType type)
{
if (type.IsInterface || type.HasElementType || type.IsGenericParameter)
if (type.IsActualInterface || type.HasElementType || type.IsGenericParameter)
return null;

LayoutKind layoutKind = LayoutKind.Auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Signature LazyCreateSignature()

internal RuntimeMethodInfo? GetParentDefinition()
{
if (!IsVirtual || m_declaringType.IsInterface)
if (!IsVirtual || m_declaringType.IsActualInterface)
return null;

RuntimeType? parent = (RuntimeType?)m_declaringType.BaseType;
Expand Down Expand Up @@ -323,7 +323,7 @@ internal void InvokePropertySetter(object? obj, BindingFlags invokeAttr, Binder?

public override MethodInfo GetBaseDefinition()
{
if (!IsVirtual || IsStatic || m_declaringType == null || m_declaringType.IsInterface)
if (!IsVirtual || IsStatic || m_declaringType == null || m_declaringType.IsActualInterface)
return this;

int slot = RuntimeMethodHandle.GetSlot(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal static bool IsInterfaceImplemented(IDynamicInterfaceCastable castable,
throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, castable.GetType(), interfaceType));

RuntimeType implType = handle.GetRuntimeType();
if (!implType.IsInterface)
if (!implType.IsActualInterface)
throw new InvalidOperationException(SR.Format(SR.IDynamicInterfaceCastable_NotInterface, implType.ToString()));

if (!implType.IsDefined(typeof(DynamicInterfaceCastableImplementationAttribute), inherit: false))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ private unsafe RuntimeMethodInfo[] PopulateMethods(Filter filter)
RuntimeType declaringType = ReflectedType;
Debug.Assert(declaringType != null);

if (declaringType.IsInterface)
if (declaringType.IsActualInterface)
{
#region IsInterface

Expand Down Expand Up @@ -998,7 +998,7 @@ private RuntimeType[] PopulateInterfaces(Filter filter)
continue;
}

Debug.Assert(interfaceType.IsInterface);
Debug.Assert(interfaceType.IsActualInterface);
list.Add(interfaceType);
}

Expand Down Expand Up @@ -1028,7 +1028,7 @@ private RuntimeType[] PopulateInterfaces(Filter filter)
for (int i = 0; i < constraints.Length; i++)
{
RuntimeType constraint = (RuntimeType)constraints[i];
if (constraint.IsInterface)
if (constraint.IsActualInterface)
al.Add(constraint);

Type[] temp = constraint.GetInterfaces();
Expand Down Expand Up @@ -1113,7 +1113,7 @@ private RuntimeEventInfo[] PopulateEvents(Filter filter)
RuntimeType declaringType = ReflectedType;
ListBuilder<RuntimeEventInfo> list = default;

if (!declaringType.IsInterface)
if (!declaringType.IsActualInterface)
{
while (RuntimeTypeHandle.IsGenericVariable(declaringType))
declaringType = declaringType.GetBaseType()!;
Expand Down Expand Up @@ -1206,7 +1206,7 @@ private RuntimePropertyInfo[] PopulateProperties(Filter filter)

ListBuilder<RuntimePropertyInfo> list = default;

if (!declaringType.IsInterface)
if (!declaringType.IsActualInterface)
{
while (RuntimeTypeHandle.IsGenericVariable(declaringType))
declaringType = declaringType.GetBaseType()!;
Expand Down Expand Up @@ -1258,8 +1258,8 @@ private void PopulateProperties(

int numVirtuals = RuntimeTypeHandle.GetNumVirtuals(declaringType);

Debug.Assert((declaringType.IsInterface && isInterface && csPropertyInfos == null) ||
(!declaringType.IsInterface && !isInterface && usedSlots.Length >= numVirtuals));
Debug.Assert((declaringType.IsActualInterface && isInterface && csPropertyInfos == null) ||
(!declaringType.IsActualInterface && !isInterface && usedSlots.Length >= numVirtuals));

for (int i = 0; i < tkProperties.Length; i++)
{
Expand Down Expand Up @@ -2697,7 +2697,7 @@ public override InterfaceMapping GetInterfaceMap([DynamicallyAccessedMembers(Dyn

TypeHandle.VerifyInterfaceIsImplemented(ifaceRtTypeHandle);
Debug.Assert(interfaceType.IsInterface); // VerifyInterfaceIsImplemented enforces this invariant
Debug.Assert(!IsInterface); // VerifyInterfaceIsImplemented enforces this invariant
Debug.Assert(!IsActualInterface); // VerifyInterfaceIsImplemented enforces this invariant

// SZArrays implement the methods on IList`1, IEnumerable`1, and ICollection`1 with
// SZArrayHelper and some runtime magic. We don't have accurate interface maps for them.
Expand Down Expand Up @@ -2739,7 +2739,7 @@ public override InterfaceMapping GetInterfaceMap([DynamicallyAccessedMembers(Dyn

// If we resolved to an interface method, use the interface type as reflected type. Otherwise use `this`.
RuntimeType reflectedType = RuntimeMethodHandle.GetDeclaringType(classRtMethodHandle);
if (!reflectedType.IsInterface)
if (!reflectedType.IsActualInterface)
reflectedType = this;

// GetMethodBase will convert this to the instantiating/unboxing stub if necessary
Expand Down Expand Up @@ -3432,7 +3432,7 @@ internal unsafe bool IsActualEnum
}
}

internal new unsafe bool IsInterface
internal unsafe bool IsActualInterface
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<Compile Include="System\MathF.NativeAot.cs" />
<Compile Include="System\Object.NativeAot.cs" />
<Compile Include="System\RuntimeArgumentHandle.cs" />
<Compile Include="System\RuntimeType.cs" />
<Compile Include="System\RuntimeType.NativeAot.cs" />
<Compile Include="System\Runtime\ControlledExecution.NativeAot.cs" />
<Compile Include="System\Runtime\DependentHandle.cs" />
<Compile Include="System\Runtime\CompilerServices\EagerStaticClassConstructionAttribute.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public override RuntimeTypeHandle TypeHandle
}
}

internal new unsafe bool IsInterface
internal unsafe bool IsActualInterface
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private void Init(string name,
if (owner?.UnderlyingSystemType is RuntimeType rtOwner)
{
if (rtOwner.HasElementType || rtOwner.ContainsGenericParameters
|| rtOwner.IsGenericParameter || rtOwner.IsInterface)
|| rtOwner.IsGenericParameter || rtOwner.IsActualInterface)
throw new ArgumentException(SR.Argument_InvalidTypeForDynamicMethod);

_typeOwner = rtOwner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public override bool IsAssignableFrom([NotNullWhen(true)] Type? c)
if (c.IsSubclassOf(this))
return true;

if (IsInterface)
if (IsActualInterface)
{
return c.ImplementInterface(this);
}
Expand Down Expand Up @@ -711,7 +711,7 @@ public override bool IsAssignableFrom([NotNullWhen(true)] Type? c)
// `class G3<T,U> where T:U where U:Stream`: typeof(G3<,>).GetGenericArguments()[0].BaseType is Object (!)
private RuntimeType? GetBaseType()
{
if (IsInterface)
if (IsActualInterface)
return null;

if (RuntimeTypeHandle.IsGenericVariable(this))
Expand All @@ -724,7 +724,7 @@ public override bool IsAssignableFrom([NotNullWhen(true)] Type? c)
{
RuntimeType constraint = (RuntimeType)constraints[i];

if (constraint.IsInterface)
if (constraint.IsActualInterface)
continue;

if (constraint.IsGenericParameter)
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Private.CoreLib/src/System/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public bool IsInterface
{
#if !MONO
if (this is RuntimeType rt)
return rt.IsInterface;
return rt.IsActualInterface;
#endif
return (GetAttributeFlagsImpl() & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,8 @@ protected override bool IsValueTypeImpl()
return res;
}

internal bool IsActualInterface => IsInterface;

// Returns true for actual value types only, ignoring generic parameter constraints.
internal bool IsActualValueType => RuntimeTypeHandle.IsValueType(this);

Expand Down
Loading