Преглед изворни кода

* partial fix for Mantis #30831 (partial, because no exception has been encountered yet): when checking whether the left node of a vmtaddrnode is a generic, don't rely on df_generic, but instead use is_generic which checks for a true generic (the other will also be true if it's merely a structured type declared (or specialized) inside another generic)
+ added test

git-svn-id: trunk@34915 -

svenbarth пре 8 година
родитељ
комит
0e7a9ad375
3 измењених фајлова са 39 додато и 1 уклоњено
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/nmem.pas
  3. 37 0
      tests/webtbs/tw30831.pp

+ 1 - 0
.gitattributes

@@ -15252,6 +15252,7 @@ tests/webtbs/tw30706.pp svneol=native#text/plain
 tests/webtbs/tw3073.pp svneol=native#text/plain
 tests/webtbs/tw3082.pp svneol=native#text/plain
 tests/webtbs/tw3083.pp svneol=native#text/plain
+tests/webtbs/tw30831.pp svneol=native#text/pascal
 tests/webtbs/tw30832.pp svneol=native#text/pascal
 tests/webtbs/tw30889.pp svneol=native#text/pascal
 tests/webtbs/tw30923.pp svneol=native#text/pascal

+ 1 - 1
compiler/nmem.pas

@@ -193,7 +193,7 @@ implementation
                   (left.resultdef.typ=recorddef)) then
                 begin
                   { access to the classtype while specializing? }
-                  if (df_generic in left.resultdef.defoptions) then
+                  if tstoreddef(left.resultdef).is_generic then
                     begin
                       defaultresultdef:=true;
                       if assigned(current_structdef) then

+ 37 - 0
tests/webtbs/tw30831.pp

@@ -0,0 +1,37 @@
+{ %NORUN }
+
+program tw30831;
+
+{$mode objfpc}
+
+type
+  generic TTest<T> = class
+  public
+    procedure Test1(const aTest: T);
+    procedure Test2(const aTest: T);
+  end;
+
+procedure TTest.Test1(const aTest: T);
+begin
+  WriteLn('Test1 ', aTest);
+end;
+
+procedure TTest.Test2(const aTest: T);
+begin
+  WriteLn('Test2 ', aTest);
+end;
+
+generic procedure Test<T>();
+begin
+  with specialize TTest<T>.Create do begin
+    Test1(1);
+    Test2(9);
+    Free;
+  end;
+end;
+
+begin
+  specialize Test<Integer>();
+  ReadLn;
+end.
+