Browse Source

* fix for Mantis #30626: unset current_procinfo so that further specializations don't use a symtable to specialize themselves in that they shouldn't use (cause current_procinfo takes precedence)

git-svn-id: trunk@34916 -
svenbarth 8 years ago
parent
commit
63b0024e4c
3 changed files with 41 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 5 0
      compiler/pgenutil.pas
  3. 35 0
      tests/webtbs/tw30626.pp

+ 1 - 0
.gitattributes

@@ -15245,6 +15245,7 @@ tests/webtbs/tw30537.pp svneol=native#text/pascal
 tests/webtbs/tw30552.pp svneol=native#text/pascal
 tests/webtbs/tw30552.pp svneol=native#text/pascal
 tests/webtbs/tw30570.pp svneol=native#text/plain
 tests/webtbs/tw30570.pp svneol=native#text/plain
 tests/webtbs/tw30572.pp svneol=native#text/plain
 tests/webtbs/tw30572.pp svneol=native#text/plain
+tests/webtbs/tw30626.pp svneol=native#text/pascal
 tests/webtbs/tw3063.pp svneol=native#text/plain
 tests/webtbs/tw3063.pp svneol=native#text/plain
 tests/webtbs/tw3064.pp svneol=native#text/plain
 tests/webtbs/tw3064.pp svneol=native#text/plain
 tests/webtbs/tw30666.pp svneol=native#text/plain
 tests/webtbs/tw30666.pp svneol=native#text/plain

+ 5 - 0
compiler/pgenutil.pas

@@ -713,6 +713,7 @@ uses
         old_current_structdef : tabstractrecorddef;
         old_current_structdef : tabstractrecorddef;
         old_current_specializedef,
         old_current_specializedef,
         old_current_genericdef : tstoreddef;
         old_current_genericdef : tstoreddef;
+        old_current_procinfo : tprocinfo;
         hmodule : tmodule;
         hmodule : tmodule;
         oldcurrent_filepos : tfileposinfo;
         oldcurrent_filepos : tfileposinfo;
         recordbuf : tdynamicarray;
         recordbuf : tdynamicarray;
@@ -908,6 +909,9 @@ uses
                 old_current_specializedef:=nil;
                 old_current_specializedef:=nil;
                 old_current_genericdef:=nil;
                 old_current_genericdef:=nil;
                 old_current_structdef:=nil;
                 old_current_structdef:=nil;
+                old_current_procinfo:=current_procinfo;
+
+                current_procinfo:=nil;
 
 
                 if parse_class_parent then
                 if parse_class_parent then
                   begin
                   begin
@@ -1082,6 +1086,7 @@ uses
                   end;
                   end;
 
 
                 block_type:=old_block_type;
                 block_type:=old_block_type;
+                current_procinfo:=old_current_procinfo;
                 if parse_class_parent then
                 if parse_class_parent then
                   begin
                   begin
                     current_structdef:=old_current_structdef;
                     current_structdef:=old_current_structdef;

+ 35 - 0
tests/webtbs/tw30626.pp

@@ -0,0 +1,35 @@
+{ %NORUN }
+
+program tw30626;
+
+{$mode objfpc}
+
+type
+  generic IBase<T> = interface(IUnknown)
+  end;
+
+  generic TBase<T> = class(TInterfacedObject, specialize IBase<T>)
+  public
+    function Test: specialize IBase<T>;
+  end;
+
+  generic TDerived<T> = class(specialize TBase<T>)
+
+  end;
+
+function TBase.Test: specialize IBase<T>;
+begin
+  result := (specialize TDerived<T>).Create;
+end;
+
+type
+  TIntDerived = specialize TDerived<Integer>;
+
+var
+  t: TIntDerived;
+
+begin
+  t := TIntDerived.Create;
+  t.Test;
+end.
+