fpc/tests/webtbs/tw20627.pp
svenbarth 5ffba57b51 Add tests for resolved generic bug reports.
Also adjusted test for report 20836 (removed unneeded units and the {$R ...} directive completely and added a "%NORUN" modifier).

git-svn-id: trunk@19817 -
2011-12-11 15:49:22 +00:00

49 lines
1.0 KiB
ObjectPascal

{ based on the file attached to bug 20627, but modified for usage in FPC's
testsuite }
{$MODE delphi}
type
TWrapper<TValue> = class
strict private
FValue: TValue;
public
type
TWrapperState = class
strict private
FValue: TValue;
public
property Value: TValue read FValue write FValue;
function GetValueSize: Integer;
{ The compiler will report that forward declaration
TWrapper$LongInt.TWrapperState.GetValueSize is not resolved. }
end;
public
property Value: TValue read FValue write FValue;
function CaptureState: TWrapperState;
end;
function TWrapper<TValue>.CaptureState: TWrapperState;
begin
Result := TWrapperState.Create;
Result.Value := FValue;
end;
function TWrapper<TValue>.TWrapperState.GetValueSize: Integer;
begin
Result := SizeOf(FValue);
end;
begin
with TWrapper<Integer>.Create do begin
Value := 123;
with CaptureState do begin
if GetValueSize <> SizeOf(Integer) then
Halt(1);
Free;
end;
Free;
end;
end.