diff --git a/src/tools/illink/src/linker/Linker/TypeMapInfo.cs b/src/tools/illink/src/linker/Linker/TypeMapInfo.cs index a2f118adf9fb7..a64f4f60016a2 100644 --- a/src/tools/illink/src/linker/Linker/TypeMapInfo.cs +++ b/src/tools/illink/src/linker/Linker/TypeMapInfo.cs @@ -32,6 +32,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Linq; using Mono.Cecil; namespace Mono.Linker @@ -293,6 +294,18 @@ void FindAndAddDefaultInterfaceImplementations (TypeDefinition type, MethodDefin if (potentialImplInterface == null) continue; + // If the interface doesn't implement the interface with the method we're looking for, exit early + bool potentialImplInterfaceImplementsInterface = false; + foreach (var iface in potentialImplInterface.Interfaces) { + if (context.TryResolve (iface.InterfaceType) == interfaceMethod.DeclaringType) + { + potentialImplInterfaceImplementsInterface = true; + break; + } + } + if (!potentialImplInterfaceImplementsInterface) + continue; + bool foundImpl = false; foreach (var potentialImplMethod in potentialImplInterface.Methods) {