Created
May 19, 2014 09:50
-
-
Save ritalin/91228af470e948ffd02c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program RecGenerics; | |
uses | |
System.SysUtils; | |
type | |
IHogeClass<T> = interface; | |
TTest<T> = record | |
Value: T; | |
function Hoge: IHogeClass<TArray<T>>; | |
end; | |
IHogeClass<T> = interface | |
function Test: TTest<T>; | |
end; | |
THogeClass<T> = class(TInterfacedObject, IHogeClass<T>) | |
function Test: TTest<T>; | |
end; | |
function Test1: TTest<Integer>; | |
begin | |
Result.Value := 1; | |
end; | |
function Test2: TTest<TArray<Integer>>; | |
begin | |
SetLength(Result.Value, 1); | |
Result.Value[0] := 2; | |
end; | |
{ THogeClass<T> } | |
function THogeClass<T>.Test: TTest<TArray<T>>; | |
begin | |
end; | |
{ TTest<T> } | |
function TTest<T>.Hoge: IHogeClass<TArray<T>>; | |
begin | |
end; | |
begin | |
Writeln('test1 = ', Test1.Value); | |
Writeln('test2 = ', Test2.Value[0]); | |
Readln; | |
end. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment