55
66namespace Internal . TypeSystem
77{
8- public struct MethodImplRecord
9- {
10- public MethodDesc Decl ;
11- public MethodDesc Body ;
12- }
13-
14- // MethodImpl api surface for types.
15- public partial class MetadataType
16- {
17- /// <summary>
18- /// Compute an array of all MethodImpls that pertain to overriding virtual (non-interface methods) on this type.
19- /// May be expensive.
20- /// </summary>
21- protected abstract MethodImplRecord [ ] ComputeVirtualMethodImplsForType ( ) ;
22-
23- private MethodImplRecord [ ] _allVirtualMethodImplsForType ;
24- /// <summary>
25- /// Get an array of all MethodImpls that pertain to overriding virtual (non-interface methods) on this type.
26- /// Expected to cache results so this api can be used repeatedly.
27- /// </summary>
28- public MethodImplRecord [ ] VirtualMethodImplsForType
29- {
30- get
31- {
32- if ( _allVirtualMethodImplsForType == null )
33- {
34- _allVirtualMethodImplsForType = ComputeVirtualMethodImplsForType ( ) ;
35- }
36-
37- return _allVirtualMethodImplsForType ;
38- }
39- }
40-
41- /// <summary>
42- /// Get an array of MethodImpls where the Decl method matches by name with the specified name.
43- /// </summary>
44- /// <param name="name"></param>
45- /// <returns></returns>
46- public abstract MethodImplRecord [ ] FindMethodsImplWithMatchingDeclName ( string name ) ;
47- }
48-
498 // Implementation of MethodImpl api surface implemented without metadata access.
509 public partial class InstantiatedType
5110 {
@@ -63,7 +22,16 @@ private MethodImplRecord[] InstantiateMethodImpls(MethodImplRecord[] uninstMetho
6322
6423 for ( int i = 0 ; i < uninstMethodImpls . Length ; i ++ )
6524 {
66- instMethodImpls [ i ] . Decl = _typeDef . Context . GetMethodForInstantiatedType ( uninstMethodImpls [ i ] . Decl , this ) ;
25+ var implTypeInstantiated = uninstMethodImpls [ i ] . Decl . OwningType . InstantiateSignature ( this . Instantiation , new Instantiation ( ) ) ;
26+ if ( implTypeInstantiated is InstantiatedType )
27+ {
28+ instMethodImpls [ i ] . Decl = _typeDef . Context . GetMethodForInstantiatedType ( uninstMethodImpls [ i ] . Decl . GetTypicalMethodDefinition ( ) , ( InstantiatedType ) implTypeInstantiated ) ;
29+ }
30+ else
31+ {
32+ instMethodImpls [ i ] . Decl = uninstMethodImpls [ i ] . Decl ;
33+ }
34+
6735 instMethodImpls [ i ] . Body = _typeDef . Context . GetMethodForInstantiatedType ( uninstMethodImpls [ i ] . Body , this ) ;
6836 }
6937
0 commit comments