Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Jan 9, 2024
1 parent b5be806 commit 16bfde7
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/IKVM.Reflection/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ T[] GetMembers<T>(BindingFlags flags)

if ((flags & BindingFlags.DeclaredOnly) == 0)
{
for (Type type = BaseType; type != null; type = type.BaseType)
for (var type = BaseType; type != null; type = type.BaseType)
{
type.CheckBaked();

Expand Down Expand Up @@ -1739,9 +1739,15 @@ public bool IsSubclassOf(Type type)
return false;
}

// This returns true if this type directly (i.e. not inherited from the base class) implements the interface.
// Note that a complicating factor is that the interface itself can be implemented by an interface that extends it.
private bool IsDirectlyImplementedInterface(Type interfaceType)
/// <summary>
/// This returns true if this type directly (i.e. not inherited from the base class) implements the interface.
/// </summary>
/// <remarks>
/// Note that a complicating factor is that the interface itself can be implemented by an interface that extends it.
/// </remarks>
/// <param name="interfaceType"></param>
/// <returns></returns>
bool IsDirectlyImplementedInterface(Type interfaceType)
{
foreach (var iface in __GetDeclaredInterfaces())
if (interfaceType.IsAssignableFrom(iface))
Expand All @@ -1766,6 +1772,7 @@ public InterfaceMapping GetInterfaceMap(Type interfaceType)
void FillInInterfaceMethods(Type interfaceType, MethodInfo[] interfaceMethods, MethodInfo[] targetMethods)
{
FillInExplicitInterfaceMethods(interfaceMethods, targetMethods);

var direct = IsDirectlyImplementedInterface(interfaceType);
if (direct)
FillInImplicitInterfaceMethods(interfaceMethods, targetMethods);
Expand All @@ -1782,7 +1789,7 @@ void FillInInterfaceMethods(Type interfaceType, MethodInfo[] interfaceMethods, M
type.FillInImplicitInterfaceMethods(interfaceMethods, targetMethods);
}

private void FillInImplicitInterfaceMethods(MethodInfo[] interfaceMethods, MethodInfo[] targetMethods)
void FillInImplicitInterfaceMethods(MethodInfo[] interfaceMethods, MethodInfo[] targetMethods)
{
MethodBase[] methods = null;

Expand Down Expand Up @@ -1943,7 +1950,7 @@ public MethodBase __CreateMissingMethod(string name, CallingConventions callingC
return CreateMissingMethod(name, callingConvention, returnType, parameterTypes, PackedCustomModifiers.CreateFromExternal(returnTypeCustomModifiers, parameterTypeCustomModifiers, parameterTypes.Length));
}

private MethodBase CreateMissingMethod(string name, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, PackedCustomModifiers customModifiers)
MethodBase CreateMissingMethod(string name, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, PackedCustomModifiers customModifiers)
{
var sig = new MethodSignature(returnType ?? Module.universe.System_Void, Util.Copy(parameterTypes), customModifiers, callingConvention, 0);
var method = new MissingMethod(this, name, sig);
Expand Down

0 comments on commit 16bfde7

Please sign in to comment.