I came across some weird behavior in Delphi XE4.
I cannot declare a set type in a generic class where the ordinal type is declared inside the same class.
For instance:
TTest<T> = class(TObject) type TEnumType = (eOne, eTwo, eThree); TEnumTypes = set of TEnumType; end;
The above does not compile. The compiler emits the error "E2001: requires an ordinary type."
Not a common class e.g.
TTest = class(TObject) type TEnumType = (eOne, eTwo, eThree); TEnumTypes = set of TEnumType; end;
compiles.
To successfully compile a general class, the ordinal type must be declared outside the class:
TEnumType = (eOne, eTwo, eThree); TTest<T> = class(TObject) type TEnumTypes = set of TEnumType; end;
- Is this behavior a mistake? If so, is it fixed in a later version?
- Does anyone have another workaround? I wanted to declare types inside a class because they are used exclusively in private parts of this class.
source share