Closed Gabriel-Darbord closed 4 months ago
May be I misunderstood the issue, but concretization can be a tree (even if it is rare):
If you have a generic with 2 type parameters (like Map<K,V>
), then you can have a partial concretization where you specify only type (ex: MapStrings<V> extends MAP<String,V>
), and then a complete concretization of this one.
In the scenario you describe, there is an inheritance relationship between two concretizations:
A concretization tree always has a height of at most two, because an entity that is concrete can never also be generic in another concretization relation.
The following never happens:
There is always a single generic entity, and possibly several concrete entities:
The genericEntity
method will always return the generic entity (the root) in a concretization relation.
This is what this method was intended to do, so this closes the issue.
Finding the root entity through multiple relations is more complicated, and most convenience methods don't take concretizations into account, see #718.
The
rootGenericEntity
method was added with the misconception that concretizations form a recursive tree structure. In practice, every ParametricEntity except the root generic entity is a leaf, so the tree has a height of at most two. So the current implementation, which does an iteration, and the namerootGenericEntity
make little sense. I would like to just call itgenericEntity
, but there is currently a relation with that name so this change depends on #706. This method always returns the generic entity, which usually contains the relevant information, such as the source anchor.