Funicular-Switch icon indicating copy to clipboard operation
Funicular-Switch copied to clipboard

Generic union type with non nested derived types

Open park-jasper opened this issue 6 months ago • 1 comments

When a union type is generic, and a derived type is declared not as a nested type, then the type parameter T is not considered to be equal between the base and the derived type since it is declared separately, and the generator whould not recognise the derived types as such. This PR fixes that. Factory methods are not generated if the non-nested definition restricts the generic type argument to a specific type or if the type parameter has a different name (which could still be supported if we remember a mapping of the parameter names and exchange the parameter types)

park-jasper avatar Jul 11 '25 14:07 park-jasper

Thinking about this a bit more, I dont think it makes sense for a case to be less generic (e.g. deriving form the base with a fixed type), just as it does not make sense for the case to be more generic (having an additional generic parameter). So I am not sure if this PR is going to have the intended effect, I may have to think about this before it can be merged

park-jasper avatar Jul 14 '25 08:07 park-jasper