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

Remove call to InflateInterfaces that does nothing #99070

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion 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 @@ -148,7 +149,7 @@ void MapInterfaceMethodsInTypeHierarchy (TypeDefinition type)

// Foreach interface and for each newslot virtual method on the interface, try
// to find the method implementation and record it.
foreach (var interfaceImpl in type.GetInflatedInterfaces (context)) {
foreach (var interfaceImpl in type.Interfaces.Select(i => (InflatedInterface: i.InterfaceType, OriginalImpl: i))) {
Copy link
Member

Choose a reason for hiding this comment

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

Interesting, I wonder how this is working today for generic interfaces. What if I have:

interface I<T> {
    void M(T t);
}

class C : I<int> {
    public void M(int i) {}
}

Presumably MapInterfaceMethodsInTypeHierarchy doesn't discover this? So what is keeping C.M?

foreach (MethodReference interfaceMethod in interfaceImpl.InflatedInterface.GetMethods (context)) {
MethodDefinition? resolvedInterfaceMethod = context.TryResolve (interfaceMethod);
if (resolvedInterfaceMethod == null)
Expand Down
19 changes: 0 additions & 19 deletions src/tools/illink/src/linker/Linker/TypeReferenceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,6 @@ void parseArrayDimensions (ArrayType at)
return null;
}

public static IEnumerable<(TypeReference InflatedInterface, InterfaceImplementation OriginalImpl)> GetInflatedInterfaces (this TypeReference typeRef, ITryResolveMetadata resolver)
{
var typeDef = resolver.TryResolve (typeRef);

if (typeDef?.HasInterfaces != true)
yield break;

if (typeRef is GenericInstanceType genericInstance) {
foreach (var interfaceImpl in typeDef.Interfaces) {
// InflateGenericType only returns null when inflating generic parameters (and the generic instance type doesn't resolve).
// Here we are not inflating a generic parameter but an interface type reference.
yield return (InflateGenericType (genericInstance, interfaceImpl.InterfaceType, resolver), interfaceImpl)!;
}
} else {
foreach (var interfaceImpl in typeDef.Interfaces)
yield return (interfaceImpl.InterfaceType, interfaceImpl);
}
}

public static TypeReference? InflateGenericType (GenericInstanceType genericInstanceProvider, TypeReference typeToInflate, ITryResolveMetadata resolver)
{
if (typeToInflate is ArrayType arrayType) {
Expand Down
Loading