From c077adf499dc44c7e1a08bb3b1b00aa18db2e417 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Fri, 25 Oct 2013 19:50:56 +0000 Subject: [PATCH] Fix for Mantis #25132 defcmp.pas, objectdef_is_related: * use "equal_defs" instead of "=", as the former also handles equivalence of specializations + added test git-svn-id: trunk@25848 - --- .gitattributes | 2 ++ compiler/defcmp.pas | 2 +- tests/webtbs/tw25132.pp | 66 +++++++++++++++++++++++++++++++++++++++++ tests/webtbs/uw25132.pp | 29 ++++++++++++++++++ 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw25132.pp create mode 100644 tests/webtbs/uw25132.pp diff --git a/.gitattributes b/.gitattributes index 5fd6f42f69..f81a00824e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13624,6 +13624,7 @@ tests/webtbs/tw25059.pp svneol=native#text/pascal tests/webtbs/tw25077.pp svneol=native#text/pascal tests/webtbs/tw25081.pp svneol=native#text/pascal tests/webtbs/tw25101.pp svneol=native#text/pascal +tests/webtbs/tw25132.pp svneol=native#text/pascal tests/webtbs/tw2514.pp svneol=native#text/plain tests/webtbs/tw25198.pp svneol=native#text/plain tests/webtbs/tw25210.pp svneol=native#text/pascal @@ -14404,6 +14405,7 @@ tests/webtbs/uw25054b.pp svneol=native#text/pascal tests/webtbs/uw25059.pp svneol=native#text/pascal tests/webtbs/uw25059.test.pp svneol=native#text/pascal tests/webtbs/uw25059.withdot.pp svneol=native#text/pascal +tests/webtbs/uw25132.pp svneol=native#text/pascal tests/webtbs/uw2706a.pp svneol=native#text/plain tests/webtbs/uw2706b.pp svneol=native#text/plain tests/webtbs/uw2731.pp svneol=native#text/plain diff --git a/compiler/defcmp.pas b/compiler/defcmp.pas index 0a8fdd3939..20206d281d 100644 --- a/compiler/defcmp.pas +++ b/compiler/defcmp.pas @@ -2336,7 +2336,7 @@ implementation hp:=realself.childof; while assigned(hp) do begin - if hp=otherdef then + if equal_defs(hp,otherdef) then begin result:=true; exit; diff --git a/tests/webtbs/tw25132.pp b/tests/webtbs/tw25132.pp new file mode 100644 index 0000000000..661afa832b --- /dev/null +++ b/tests/webtbs/tw25132.pp @@ -0,0 +1,66 @@ +program tw25132; + +{$IFDEF FPC} + {$MODE DELPHI} +{$ENDIF} + +uses + uw25132; + +type + TAnotherIterator = class(TIterator) + public + function GetValue(): Integer; override; + end; + + TCollection = class(TObject) + private + function CreateAnotherIterator(): TIterator; virtual; + function CreateIterator(): TIterator; virtual; + end; + +{ TAnotherIterator } + +function TAnotherIterator.GetValue(): Integer; +begin + Result := 2; +end; + +{ TCollection} + +function TCollection.CreateAnotherIterator(): TIterator; +begin + Result := TAnotherIterator.Create(); +end; + +function TCollection.CreateIterator(): TIterator; +begin + Result := TCollectionIterator.Create(); +end; + +var + CollectionIterator: TCollectionIterator; + AnotherIterator: TAnotherIterator; +begin + CollectionIterator := TCollectionIterator.Create(); + AnotherIterator := TAnotherIterator.Create(); + + if CollectionIterator.GetValue() = 1 then + WriteLn('Collection iterator: OK') + else + begin + WriteLn('Collection iterator: FAILED'); + Halt(1); + end; + + if AnotherIterator.GetValue() = 2 then + WriteLn('Another iterator: OK') + else + begin + WriteLn('Another iterator: FAILED'); + Halt(1); + end; + + CollectionIterator.Free(); + AnotherIterator.Free(); +end. diff --git a/tests/webtbs/uw25132.pp b/tests/webtbs/uw25132.pp new file mode 100644 index 0000000000..ebb8a0693e --- /dev/null +++ b/tests/webtbs/uw25132.pp @@ -0,0 +1,29 @@ +unit uw25132; + +{$ifdef fpc} + {$mode delphi} +{$endif} + +interface + +type + TIterator = class(TObject) + public + function GetValue(): Integer; virtual; abstract; + end; + + TCollectionIterator = class(TIterator) + public + function GetValue(): Integer; override; + end; + +implementation + +{ TCollectionIterator } + +function TCollectionIterator.GetValue(): Integer; +begin + Result := 1; +end; + +end.