@@ -74,24 +74,30 @@ public nanoGenericParamTable(
74
74
nanoTablesContext context )
75
75
: base ( items , new GenericParameterComparer ( ) , context )
76
76
{
77
- foreach ( var gp in items )
77
+ foreach ( GenericParameter gp in items )
78
78
{
79
79
MethodDefinition methodWithGenericParam = _context . MethodDefinitionTable . Items . SingleOrDefault ( m => m . GenericParameters . Contains ( gp ) ) ;
80
80
81
81
if ( methodWithGenericParam != null )
82
82
{
83
83
// get the first method specification that matches this type AND name
84
- var instanceMethod = _context . MethodSpecificationTable . Items . FirstOrDefault (
84
+ GenericInstanceMethod instanceMethod = _context . MethodSpecificationTable . Items . FirstOrDefault (
85
85
mr => mr . DeclaringType . GetElementType ( ) == methodWithGenericParam . DeclaringType &&
86
86
mr . Name == methodWithGenericParam . Name ) as GenericInstanceMethod ;
87
87
88
- Debug . Assert (
89
- instanceMethod != null ,
90
- $ "Couldn't find a method specification for type { methodWithGenericParam . DeclaringType } when processing generic parameter { gp } .") ;
91
-
92
- _typeForGenericParam . Add (
93
- gp ,
94
- instanceMethod . GenericArguments . ElementAt ( gp . Position ) ) ;
88
+ if ( instanceMethod == null )
89
+ {
90
+ // No instantiation was ever emitted in the IL, treat the parameter as an "open generic"
91
+ _typeForGenericParam . Add ( gp , gp ) ;
92
+ }
93
+ else
94
+ {
95
+ // found a closed instantiation, so pick the real type argument
96
+ _typeForGenericParam . Add (
97
+ gp ,
98
+ instanceMethod . GenericArguments . ElementAt ( gp . Position )
99
+ ) ;
100
+ }
95
101
}
96
102
else
97
103
{
0 commit comments