@@ -48,14 +48,24 @@ def deserialize(cls, data: JsonDict) -> 'Type':
48
48
49
49
50
50
class TypeVarId :
51
- # 1, 2, ... for type-related, -1, ... for function-related
51
+ # A type variable is uniquely identified by its raw id and meta level.
52
+
53
+ # For plain variables (type parameters of generic classes and
54
+ # functions) raw ids are allocated by semantic analysis, using
55
+ # positive ids 1, 2, ... for generic class parameters and negative
56
+ # ids -1, ... for generic function type arguments. This convention
57
+ # is only used to keep type variable ids distinct when allocating
58
+ # them; the type checker makes no distinction between class and
59
+ # function type variables.
60
+
61
+ # Metavariables are allocated unique ids starting from 1.
52
62
raw_id = 0 # type: int
53
63
54
64
# Level of the variable in type inference. Currently either 0 for
55
- # declared types, or 1 for type inference unification variables .
65
+ # declared types, or 1 for type inference metavariables .
56
66
meta_level = 0 # type: int
57
67
58
- # Used for allocating fresh ids
68
+ # Class variable used for allocating fresh ids for metavariables.
59
69
next_raw_id = 1 # type: int
60
70
61
71
def __init__ (self , raw_id : int , meta_level : int = 0 ) -> None :
0 commit comments