fpc/tests/webtbs/tw29546.pp
svenbarth 05174f3e67 Fix for Mantis #29546.
htypechk.pas, tcallcandidates:
  * create_candidate_list: don't check whether the pd is a specialization if the owner is valid; happens if a generic method is used more than once (which should happen here and then :P )

+ added test

git-svn-id: trunk@33037 -
2016-01-31 17:14:44 +00:00

30 lines
558 B
ObjectPascal

{ %NORUN }
program tw29546;
{$mode objfpc}
type
TUtils = class sealed(TObject)
public
generic class function Iif<T>(ACondition: Boolean;
const ATrueValue, AFalseValue: T): T; static;
end;
generic class function TUtils.Iif<T>(ACondition: Boolean;
const ATrueValue, AFalseValue: T): T;
begin
if ACondition then
Result := ATrueValue
else
Result := AFalseValue;
end;
var
S: string;
begin
S := TUtils.specialize Iif<string>(False, 'YES', 'NO');
S := TUtils.specialize Iif<string>(True, 'YES', 'NO');
end.