So here is a weird thing I was wondering about quite a while. Taking a generic class:
generic TTest<T, U> = class(TObject);
And you want to do a partial specialization, you can do the following:
generic TOneGenericParamSubclass<T> = class(specialize TTwoGenericParams<T, Integer>);
But you can't do the following:
generic TOneGenericParam<T> = specialize TTwoGenericParams<T, Integer>; // Error Identifier not found "T"
For classes this is annoying but nothing more as the subclass method can be used easiely, but for other types this is kinda a dealbreaker, e.g. for functions:
generic TUnaryFunction<TResult, TParam> = function(const AValue: TParam): TResult;
generic TToStringFunction<TData> = specialize TUnaryFunction<String, TData>;
Or for records:
generic TUnion<TFirst, TSecond> = record
// ...
end;
generic TUnaryFunctionRaw<TResult, TParam> = function(const AValue: TParam): TResult;
generic TUnaryFunctionMethod<TResult, TParam> = function(const AValue: TParam): TResult of object;
generic TUnaryFunction<TResult, TParam> =
specialize TUnion<specialize TUnaryFunctionRaw<TResult, TParam>,
specialize TUnaryFunctionMethod<TResult, TParam>>;
This behavior is in the fpc for a long time now, so my question is, is this intentional or a bug? I found this to be really annoying as it makes a lot of things simply not possible. And I do not see a workaround for this