@@ -181,7 +181,7 @@ void MapInterfaceMethodsInTypeHierarchy (TypeDefinition type)
181
181
}
182
182
183
183
// Look for a default implementation last.
184
- FindAndAddDefaultInterfaceImplementations ( type , resolvedInterfaceMethod ) ;
184
+ FindAndAddDefaultInterfaceImplementations ( type , type , resolvedInterfaceMethod ) ;
185
185
}
186
186
}
187
187
}
@@ -279,26 +279,33 @@ void AnnotateMethods (MethodDefinition @base, MethodDefinition @override, Interf
279
279
return context . TryResolve ( type ) ? . BaseType ;
280
280
}
281
281
282
- // Returns a list of default implementations of the given interface method on this type.
283
- // Note that this returns a list to potentially cover the diamond case (more than one
284
- // most specific implementation of the given interface methods). ILLink needs to preserve
285
- // all the implementations so that the proper exception can be thrown at runtime.
286
- void FindAndAddDefaultInterfaceImplementations ( TypeDefinition type , MethodDefinition interfaceMethod )
282
+ /// <summary>
283
+ /// Returns a list of default implementations of the given interface method on this type.
284
+ /// Note that this returns a list to potentially cover the diamond case (more than one
285
+ /// most specific implementation of the given interface methods). ILLink needs to preserve
286
+ /// all the implementations so that the proper exception can be thrown at runtime.
287
+ /// </summary>
288
+ /// <param name="type">The type that implements (directly or via a base interface) the declaring interface of <paramref name="interfaceMethod"/></param>
289
+ /// <param name="interfaceMethod">The method to find a default implementation for</param>
290
+ /// <param name="implOfInterface">
291
+ /// The InterfaceImplementation on <paramref name="type"/> that points to the DeclaringType of <paramref name="interfaceMethod"/>.
292
+ /// </param>
293
+ void FindAndAddDefaultInterfaceImplementations ( TypeDefinition typeThatImplementsInterface , TypeDefinition typeThatMayHaveDIM , MethodDefinition interfaceMethodToBeImplemented )
287
294
{
288
295
// Go over all interfaces, trying to find a method that is an explicit MethodImpl of the
289
296
// interface method in question.
290
297
291
- foreach ( var interfaceImpl in type . Interfaces ) {
298
+ foreach ( var interfaceImpl in typeThatMayHaveDIM . Interfaces ) {
292
299
var potentialImplInterface = context . TryResolve ( interfaceImpl . InterfaceType ) ;
293
300
if ( potentialImplInterface == null )
294
301
continue ;
295
302
296
303
bool foundImpl = false ;
297
304
298
305
foreach ( var potentialImplMethod in potentialImplInterface . Methods ) {
299
- if ( potentialImplMethod == interfaceMethod &&
306
+ if ( potentialImplMethod == interfaceMethodToBeImplemented &&
300
307
! potentialImplMethod . IsAbstract ) {
301
- AddDefaultInterfaceImplementation ( interfaceMethod , type , ( interfaceImpl , potentialImplMethod ) ) ;
308
+ AddDefaultInterfaceImplementation ( interfaceMethodToBeImplemented , typeThatImplementsInterface , ( interfaceImpl , potentialImplMethod ) ) ;
302
309
foundImpl = true ;
303
310
break ;
304
311
}
@@ -308,8 +315,8 @@ void FindAndAddDefaultInterfaceImplementations (TypeDefinition type, MethodDefin
308
315
309
316
// This method is an override of something. Let's see if it's the method we are looking for.
310
317
foreach ( var @override in potentialImplMethod . Overrides ) {
311
- if ( context . TryResolve ( @override ) == interfaceMethod ) {
312
- AddDefaultInterfaceImplementation ( interfaceMethod , type , ( interfaceImpl , @ potentialImplMethod) ) ;
318
+ if ( context . TryResolve ( @override ) == interfaceMethodToBeImplemented ) {
319
+ AddDefaultInterfaceImplementation ( interfaceMethodToBeImplemented , typeThatImplementsInterface , ( interfaceImpl , potentialImplMethod ) ) ;
313
320
foundImpl = true ;
314
321
break ;
315
322
}
@@ -323,7 +330,7 @@ void FindAndAddDefaultInterfaceImplementations (TypeDefinition type, MethodDefin
323
330
// We haven't found a MethodImpl on the current interface, but one of the interfaces
324
331
// this interface requires could still provide it.
325
332
if ( ! foundImpl ) {
326
- FindAndAddDefaultInterfaceImplementations ( potentialImplInterface , interfaceMethod ) ;
333
+ FindAndAddDefaultInterfaceImplementations ( typeThatImplementsInterface , potentialImplInterface , interfaceMethodToBeImplemented ) ;
327
334
}
328
335
}
329
336
}
0 commit comments