Right now, it really just is a series of hacks for specific cases.
I think we should split it out in algo/genericInference (or something similar), with the following API:
extractTypeArg: func (typeArg: String, refType, type: Type) -> Type (assuming type is fully resolved, null means there is no typeArg match)
inferTypeArg: func (typeArg: String, refTypes, types: ArrayList<Type>) -> Type (iterates over types, extracts their candidates, if any, then returns their common root)
Where a refType is a type the typeArg appears in unspecialized (for a function, it is the signature type), while a type is the corresponding type with the specialized typeArg.
Right now, it really just is a series of hacks for specific cases.
I think we should split it out in algo/genericInference (or something similar), with the following API:
extractTypeArg: func (typeArg: String, refType, type: Type) -> Type
(assuming type is fully resolved, null means there is no typeArg match)inferTypeArg: func (typeArg: String, refTypes, types: ArrayList<Type>) -> Type
(iterates over types, extracts their candidates, if any, then returns their common root)Where a refType is a type the typeArg appears in unspecialized (for a function, it is the signature type), while a type is the corresponding type with the specialized typeArg.