@@ -66,10 +66,10 @@ Kind ParamKind
6666 }
6767
6868 public static Parameter Create ( Context cx , IParameterSymbol param , IEntity parent , Parameter original = null ) =>
69- ParameterFactory . Instance . CreateEntity ( cx , param , parent , original ) ;
69+ ParameterFactory . Instance . CreateEntity ( cx , param , ( param , parent , original ) ) ;
7070
7171 public static Parameter Create ( Context cx , IParameterSymbol param ) =>
72- ParameterFactory . Instance . CreateEntity ( cx , param , null , null ) ;
72+ ParameterFactory . Instance . CreateEntity ( cx , param , ( param , null , null ) ) ;
7373
7474 public override void WriteId ( TextWriter trapFile )
7575 {
@@ -202,7 +202,8 @@ public override bool Equals(object obj)
202202 return obj != null && obj . GetType ( ) == typeof ( VarargsType ) ;
203203 }
204204
205- public static VarargsType Create ( Context cx ) => VarargsTypeFactory . Instance . CreateNullableEntity ( cx , null ) ;
205+ static readonly object cacheKey = new object ( ) ;
206+ public static VarargsType Create ( Context cx ) => VarargsTypeFactory . Instance . CreateEntity ( cx , cacheKey , null ) ;
206207
207208 class VarargsTypeFactory : ICachedEntityFactory < string , VarargsType >
208209 {
@@ -237,7 +238,8 @@ public override bool Equals(object obj)
237238 return obj != null && obj . GetType ( ) == typeof ( VarargsParam ) ;
238239 }
239240
240- public static VarargsParam Create ( Context cx , Method method ) => VarargsParamFactory . Instance . CreateEntity ( cx , method ) ;
241+ static readonly object cacheKey = new object ( ) ;
242+ public static VarargsParam Create ( Context cx , Method method ) => VarargsParamFactory . Instance . CreateEntity ( cx , cacheKey , method ) ;
241243
242244 class VarargsParamFactory : ICachedEntityFactory < Method , VarargsParam >
243245 {
@@ -264,19 +266,27 @@ public override void Populate(TextWriter trapFile)
264266 trapFile . param_location ( this , Original . Location ) ;
265267 }
266268
267- public override int GetHashCode ( ) => symbol . GetHashCode ( ) + 31 * ConstructedType . GetHashCode ( ) ;
268-
269- public override bool Equals ( object obj )
269+ sealed class ConstructedExtensionParameterCacheKey
270270 {
271- var other = obj as ConstructedExtensionParameter ;
272- if ( other == null || other . GetType ( ) != typeof ( ConstructedExtensionParameter ) )
273- return false ;
271+ public readonly IParameterSymbol Parameter ;
272+ public readonly ITypeSymbol ConstructedType ;
273+ public ConstructedExtensionParameterCacheKey ( IParameterSymbol parameter , ITypeSymbol constructedType )
274+ {
275+ Parameter = parameter ;
276+ ConstructedType = constructedType ;
277+ }
278+
279+ public override int GetHashCode ( ) =>
280+ ( Parameter , ConstructedType ) . GetHashCode ( ) ;
274281
275- return SymbolEqualityComparer . Default . Equals ( symbol , other . symbol ) && SymbolEqualityComparer . Default . Equals ( ConstructedType , other . ConstructedType ) ;
282+ public override bool Equals ( object obj ) =>
283+ obj is ConstructedExtensionParameterCacheKey k &&
284+ SymbolEqualityComparer . Default . Equals ( k . Parameter , Parameter ) &&
285+ SymbolEqualityComparer . Default . Equals ( k . ConstructedType , ConstructedType ) ;
276286 }
277287
278288 public static ConstructedExtensionParameter Create ( Context cx , Method method , Parameter parameter ) =>
279- ExtensionParamFactory . Instance . CreateEntity ( cx , ( method , parameter ) ) ;
289+ ExtensionParamFactory . Instance . CreateEntity ( cx , new ConstructedExtensionParameterCacheKey ( parameter . symbol , method . symbol . ReceiverType ) , ( method , parameter ) ) ;
280290
281291 class ExtensionParamFactory : ICachedEntityFactory < ( Method , Parameter ) , ConstructedExtensionParameter >
282292 {
0 commit comments