瀏覽代碼

* fix for Mantis #22192: handle the case that a specialization has the same name as the generic it's based on as in that case the typedef of the symbol is an errordef; therefor we need to use the symbol's real name
+ added test

git-svn-id: trunk@34530 -

svenbarth 9 年之前
父節點
當前提交
50f2aab0ef
共有 3 個文件被更改,包括 17 次插入1 次删除
  1. 1 0
      .gitattributes
  2. 6 1
      compiler/pexpr.pas
  3. 10 0
      tests/webtbs/tw22192.pp

+ 1 - 0
.gitattributes

@@ -14740,6 +14740,7 @@ tests/webtbs/tw22154.pp svneol=native#text/pascal
 tests/webtbs/tw22155.pp svneol=native#text/plain
 tests/webtbs/tw22160a1.pp svneol=native#text/pascal
 tests/webtbs/tw22160b1.pp svneol=native#text/pascal
+tests/webtbs/tw22192.pp svneol=native#text/pascal
 tests/webtbs/tw2220.pp svneol=native#text/plain
 tests/webtbs/tw22225.pp svneol=native#text/pascal
 tests/webtbs/tw2226.pp svneol=native#text/plain

+ 6 - 1
compiler/pexpr.pas

@@ -1409,6 +1409,7 @@ implementation
     function handle_specialize_inline_specialization(var srsym:tsym;out srsymtable:tsymtable;out spezcontext:tspecializationcontext):boolean;
       var
         spezdef : tdef;
+        symname : tsymstr;
       begin
         result:=false;
         spezcontext:=nil;
@@ -1424,7 +1425,11 @@ implementation
                 spezdef:=ttypesym(srsym).typedef
               else
                 spezdef:=tdef(tprocsym(srsym).procdeflist[0]);
-              spezdef:=generate_specialization_phase1(spezcontext,spezdef);
+              if (spezdef.typ=errordef) and (sp_generic_dummy in srsym.symoptions) then
+                symname:=srsym.RealName
+              else
+                symname:='';
+              spezdef:=generate_specialization_phase1(spezcontext,spezdef,symname);
               case spezdef.typ of
                 errordef:
                   begin

+ 10 - 0
tests/webtbs/tw22192.pp

@@ -0,0 +1,10 @@
+{ %NORUN }
+
+{$MODE DELPHI}
+
+ type
+   TWrapper<T> = record end;
+   TWrapper = TWrapper<Byte>;
+
+ begin
+ end.