generic class can't have pointer as a specializing type
Original Reporter info from Mantis: Hixie
-
Reporter name: Ian Hickson
Original Reporter info from Mantis: Hixie
- Reporter name: Ian Hickson
Description:
The specializing type of a generic class can be an Integer, a class, or pretty much any type as far as I can tell, except a pointer type or a string type.
The code below fails with:
Error: Operator is not overloaded: "<undefined type>" = "Pointer"
The same code works fine if you replace all instances of "Pointer" with "Integer" (and "nil" with "0"), but fails if you replace it with "AnsiString" (and "nil" with a constant empty string literal).
Steps to reproduce:
{$MODE OBJFPC} { -*- text -*- }
program tests;
type
generic TTest <PTest> = class
FPointer: PTest;
procedure Foo();
end;
procedure TTest.Foo();
var
Result: Boolean;
begin
Result := FPointer = nil;
end;
type
TPointerTest = specialize TTest <Pointer>;
begin
end.
Additional information:
Compilable test case at http://junkyard.damowmow.com/468
Mantis conversion info:
- Mantis ID: 19548
- Build: trunk compiled 2011-06-05
- Version: 2.5.1
- Fixed in version: 2.6.0
- Fixed in revision: 17829 (#6e1d5e0a)
- Monitored by: » @PascalDragon (Sven Barth)