Class TypeInterning
equals/hashCode methods, also methods
called internEquals/internHashCode. This directly applies to the Type
hierarchy. If the equality/hash code is structural, it is likely that types which use these special
types should themselves also be special (if they are subject to the interning process, of course).
This applies to MethodInternal, FieldInternal and RecordComponentInternal.
The reason why the Type hierarchy needs a different equality and hash code for interning
is type variable references. To maintain structural equality/hash code for external users (that is,
the common equals and hashCode methods), type variable references equality/hash
code must only consider the type variable name (and annotations). This is not suitable for
the interning purpose, because two type variable references may have the same name and annotations,
yet point to different type variables (e.g. because those type variables have different annotations).
We could possibly implement a "deep" structural equality and hash code for type variable references that would take into account the type variable the reference points to, but that still wouldn't be enough. When interning, types must be interned "from the inside", which means that when a type variable reference is being interned, the "target" type variable is not interned yet (possibly even not yet set) and can change later. This is one of the reasons why type variable references are mutable, and that in turn requires that their equality and hash code for interning purposes are based on identity.
Note that type variable references are only mutated during indexing. After an Index is complete,
type variable references must be considered "frozen".
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static booleanarrayEquals(Type[] a, Type[] b) (package private) static intarrayHashCode(Type[] array)
-
Constructor Details
-
TypeInterning
TypeInterning()
-
-
Method Details
-
arrayEquals
-
arrayHashCode
-