Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ILLlink] In DIM finding, exit early if the interface doesn't impl the DIM we're looking for #98436

Closed
wants to merge 3 commits into from
Closed
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
13 changes: 13 additions & 0 deletions src/tools/illink/src/linker/Linker/TypeMapInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Mono.Cecil;

namespace Mono.Linker
Expand Down Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could refactor this into a local function to avoid doing the break-continue dance.

}
}
if (!potentialImplInterfaceImplementsInterface)
continue;

bool foundImpl = false;

foreach (var potentialImplMethod in potentialImplInterface.Methods) {
Expand Down
Loading