moosetechnology / Famix

An abstract representation of source code. Famix is generic and can describe applications in multiple programming languages.
MIT License
12 stars 22 forks source link

Parametric types and polymorphism #718

Open Gabriel-Darbord opened 5 months ago

Gabriel-Darbord commented 5 months ago

Before parametrics, we had the ParameterizedType representing a concrete type, and the ParameterizableClass representing a generic type. The problem was that the ParameterizedType was missing most of its relevant information, such as attributes, methods, etc., which also breaks most convenience methods like inheritedAttributes. So we had to do this check every time to get the type with the actual information:

aType isParameterizedType ifTrue: [ aType parameterizableClass ] ifFalse: [ aType ]

Now, with parametrics, a ParametricEntity can take on both roles, being either concrete and missing relevant information, or generic and with information, resulting in having to do the equivalent check every time:

aType isParametricEntity ifTrue: [ aType genericEntity ] ifFalse: [ aType ]

I would like to have a unary method in FamixTType that does this check for us so we don't have to rewrite the same snippet each and every time we manipulate types. However, this conflicts with languages that do not use ParametricEntity, such as Smalltalk. This can be fixed by adding the testing method isParametricEntity to the root entity, but this leaves a bad taste...

I'm not sure how to call this method yet, here are some ideas: