blob: adc5d209b35a4e0e78d93346194c24231ee1fb2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
program tgeneric106;
{$Mode Delphi}
type G<T> = class
var X: T;
// EXPECTED: gets compiled
// ACTUAL: 'Error: Generics without specialization cannot be used as a type for a variable'
class var F: function(const X: T) : G<T> of object;
function Foo(const X: T): G<T>;
end;
function G<T>.Foo(const X: T): G<T>;
begin
result := G<T>.Create;
result.X := X
end;
begin
G<Integer>.F := G<Integer>.Create.Foo;
if G<Integer>.F(42).X <> 42 then
halt(1);
end.
|