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 -
This commit is contained in:
svenbarth 2016-01-31 17:14:44 +00:00
parent ed94ca4b24
commit 05174f3e67
3 changed files with 31 additions and 4 deletions

1
.gitattributes vendored
View File

@ -14933,6 +14933,7 @@ tests/webtbs/tw2944.pp svneol=native#text/plain
tests/webtbs/tw2946.pp svneol=native#text/plain
tests/webtbs/tw2949.pp svneol=native#text/plain
tests/webtbs/tw2953.pp svneol=native#text/plain
tests/webtbs/tw29546.pp svneol=native#text/pascal
tests/webtbs/tw2956.pp svneol=native#text/plain
tests/webtbs/tw2958.pp svneol=native#text/plain
tests/webtbs/tw2966.pp svneol=native#text/plain

View File

@ -2472,10 +2472,7 @@ implementation
)
) or
(
(
not pd.is_specialization and
assigned(pd.owner)
) and
assigned(pd.owner) and
(
not (pd.owner.symtabletype in [objectsymtable,recordsymtable]) or
is_visible_for_object(pd,contextstructdef)

29
tests/webtbs/tw29546.pp Normal file
View File

@ -0,0 +1,29 @@
{ %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.