diff --git a/.gitattributes b/.gitattributes index 9e4d179807..d8a5124a1d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12808,6 +12808,7 @@ tests/webtbs/tw21443.pp svneol=native#text/plain tests/webtbs/tw2145.pp svneol=native#text/plain tests/webtbs/tw21457.pp svneol=native#text/pascal tests/webtbs/tw21472.pp svneol=native#text/pascal +tests/webtbs/tw21538.pp svneol=native#text/pascal tests/webtbs/tw21550.pp svneol=native#text/pascal tests/webtbs/tw21551.pp svneol=native#text/plain tests/webtbs/tw2158.pp svneol=native#text/plain @@ -13666,6 +13667,7 @@ tests/webtbs/uw2040.pp svneol=native#text/plain tests/webtbs/uw20909a.pas svneol=native#text/pascal tests/webtbs/uw20909b.pas svneol=native#text/pascal tests/webtbs/uw20940.pp svneol=native#text/pascal +tests/webtbs/uw21538.pp svneol=native#text/pascal tests/webtbs/uw21808a.pp svneol=native#text/plain tests/webtbs/uw21808b.pp svneol=native#text/plain tests/webtbs/uw22160a2.pp svneol=native#text/pascal diff --git a/compiler/defcmp.pas b/compiler/defcmp.pas index 6c26ed8a1f..77d303c9cc 100644 --- a/compiler/defcmp.pas +++ b/compiler/defcmp.pas @@ -204,6 +204,8 @@ implementation hct : tconverttype; hobjdef : tobjectdef; hpd : tprocdef; + i : longint; + diff : boolean; begin eq:=te_incompatible; doconv:=tc_not_possible; @@ -262,6 +264,33 @@ implementation end; end; + { two specializations are considered equal if they specialize the same + generic with the same types } + if (df_specialization in def_from.defoptions) and + (df_specialization in def_to.defoptions) and + (tstoreddef(def_from).genericdef=tstoreddef(def_to).genericdef) then + begin + if tstoreddef(def_from).genericparas.count<>tstoreddef(def_to).genericparas.count then + internalerror(2012091301); + diff:=false; + for i:=0 to tstoreddef(def_from).genericparas.count-1 do + begin + if tstoreddef(def_from).genericparas.nameofindex(i)<>tstoreddef(def_to).genericparas.nameofindex(i) then + internalerror(2012091302); + if tstoreddef(def_from).genericparas[i]<>tstoreddef(def_to).genericparas[i] then + diff:=true; + if diff then + break; + end; + if not diff then + begin + doconv:=tc_equal; + { the definitions are not exactly the same, but only equal } + compare_defs_ext:=te_equal; + exit; + end; + end; + { we walk the wanted (def_to) types and check then the def_from types if there is a conversion possible } case def_to.typ of diff --git a/tests/webtbs/tw21538.pp b/tests/webtbs/tw21538.pp new file mode 100644 index 0000000000..541a735804 --- /dev/null +++ b/tests/webtbs/tw21538.pp @@ -0,0 +1,19 @@ +unit tw21538; + +{$IFDEF FPC} + {$MODE DELPHI} +{$ENDIF} + +interface + +uses uw21538; + +var + ZZ: TWrapper; + +implementation + +initialization + ZZ := Z; + +end. diff --git a/tests/webtbs/uw21538.pp b/tests/webtbs/uw21538.pp new file mode 100644 index 0000000000..70a141e6e7 --- /dev/null +++ b/tests/webtbs/uw21538.pp @@ -0,0 +1,17 @@ +unit uw21538; + +{$IFDEF FPC} + {$MODE DELPHI} +{$ENDIF} + +interface + +type + TWrapper = record end; + +var + Z: TWrapper; + +implementation + +end.