@@ -25,7 +25,6 @@ namespace Microsoft.Python.Analysis.Types {
25
25
internal partial class PythonClassType {
26
26
private readonly ReentrancyGuard < IPythonClassType > _genericSpecializationGuard = new ReentrancyGuard < IPythonClassType > ( ) ;
27
27
private readonly ReentrancyGuard < IPythonClassType > _genericResolutionGuard = new ReentrancyGuard < IPythonClassType > ( ) ;
28
- private readonly object _genericParameterLock = new object ( ) ;
29
28
30
29
private bool _isGeneric ;
31
30
private Dictionary < string , PythonClassType > _specificTypeCache ;
@@ -60,7 +59,7 @@ internal partial class PythonClassType {
60
59
/// B[int] inherits from A[int, str]
61
60
/// </summary>
62
61
public IPythonType CreateSpecificType ( IArgumentSet args ) {
63
- lock ( _genericParameterLock ) {
62
+ lock ( _membersLock ) {
64
63
var newGenericTypeParameters = GetTypeParameters ( ) ;
65
64
var newBases = new List < IPythonType > ( ) ;
66
65
@@ -161,18 +160,18 @@ private IGenericTypeParameter[] GetTypeParameters() {
161
160
}
162
161
}
163
162
}
164
-
165
163
return fromBases . ToArray ( ) ;
166
164
}
167
165
168
166
/// <summary>
169
167
/// Given an argument set, returns a dictionary mapping generic type parameter to the supplied specific
170
168
/// type from arguments.
171
169
/// </summary>
172
- private IReadOnlyDictionary < IGenericTypeParameter , IPythonType > GetSpecificTypes ( IArgumentSet args ,
173
- IGenericTypeParameter [ ] genericTypeParameters ,
174
- List < IPythonType > newBases ) {
175
-
170
+ private IReadOnlyDictionary < IGenericTypeParameter , IPythonType > GetSpecificTypes (
171
+ IArgumentSet args ,
172
+ IReadOnlyList < IGenericTypeParameter > genericTypeParameters ,
173
+ ICollection < IPythonType > newBases
174
+ ) {
176
175
// For now, map each type parameter to itself, and we can fill in the value as we go
177
176
var genericTypeToSpecificType = genericTypeParameters . ToDictionary ( gtp => gtp , gtp => gtp as IPythonType ) ;
178
177
@@ -240,7 +239,7 @@ private IReadOnlyDictionary<IGenericTypeParameter, IPythonType> GetSpecificTypes
240
239
if ( arg . Value is IMember member ) {
241
240
var type = member . GetPythonType ( ) ;
242
241
if ( ! type . IsUnknown ( ) ) {
243
- var gtd = gtIndex < genericTypeParameters . Length ? genericTypeParameters [ gtIndex ] : null ;
242
+ var gtd = gtIndex < genericTypeParameters . Count ? genericTypeParameters [ gtIndex ] : null ;
244
243
if ( gtd != null && genericTypeToSpecificType . TryGetValue ( gtd , out var s ) && s is IGenericTypeParameter ) {
245
244
genericTypeToSpecificType [ gtd ] = type ;
246
245
}
@@ -304,7 +303,7 @@ private void StoreGenericParameters(
304
303
/// <param name="gt">Generic type (Generic[T1, T2, ...], A[T1, T2, ..], etc.).</param>
305
304
/// <param name="argumentValue">Argument value passed to the class constructor.</param>
306
305
/// <param name="specificTypes">Dictionary or name (T1) to specific type to populate.</param>
307
- private void GetSpecificTypeFromArgumentValue ( IGenericType gt , object argumentValue , IDictionary < IGenericTypeParameter , IPythonType > specificTypes ) {
306
+ private static void GetSpecificTypeFromArgumentValue ( IGenericType gt , object argumentValue , IDictionary < IGenericTypeParameter , IPythonType > specificTypes ) {
308
307
switch ( argumentValue ) {
309
308
case IPythonDictionary dict when gt . Parameters . Count == 2 :
310
309
var keyType = dict . Keys . FirstOrDefault ( ) ? . GetPythonType ( ) ;
0 commit comments