浏览代码

Contrary to popular believe the VMT for a generic needs to be at least generated so that check for inherited methods can be done correctly. This does however not mean that the VMT is written to the object file which is handled at a completely different place. Fixes Mantis #26193.

pdecl.pas, types_dec:
  * invoke the VMT builder for generic classes as well

+ added test

git-svn-id: trunk@27869 -
svenbarth 11 年之前
父节点
当前提交
9ab5affd55
共有 3 个文件被更改,包括 25 次插入2 次删除
  1. 1 0
      .gitattributes
  2. 1 2
      compiler/pdecl.pas
  3. 23 0
      tests/webtbf/tw26193.pp

+ 1 - 0
.gitattributes

@@ -12747,6 +12747,7 @@ tests/webtbf/tw25861.pp svneol=native#text/plain
 tests/webtbf/tw25862.pp svneol=native#text/plain
 tests/webtbf/tw25915.pp svneol=native#text/pascal
 tests/webtbf/tw25951.pp svneol=native#text/pascal
+tests/webtbf/tw26193.pp svneol=native#text/pascal
 tests/webtbf/tw2657.pp svneol=native#text/plain
 tests/webtbf/tw2670.pp svneol=native#text/plain
 tests/webtbf/tw2719.pp svneol=native#text/plain

+ 1 - 2
compiler/pdecl.pas

@@ -798,8 +798,7 @@ implementation
 
                     { Build VMT indexes, skip for type renaming and forward classes }
                     if (hdef.typesym=newtype) and
-                       not(oo_is_forward in tobjectdef(hdef).objectoptions) and
-                       not(df_generic in hdef.defoptions) then
+                       not(oo_is_forward in tobjectdef(hdef).objectoptions) then
                       begin
                         vmtbuilder:=TVMTBuilder.Create(tobjectdef(hdef));
                         vmtbuilder.generate_vmt;

+ 23 - 0
tests/webtbf/tw26193.pp

@@ -0,0 +1,23 @@
+{ %FAIL }
+
+program tw26193;
+
+{$mode delphi}
+
+type
+  TA<T> = class
+    function Foo: Boolean; virtual; abstract;
+  end;
+
+  TB<T> = class(TA<byte>)
+    // Missing (!) error: There is no method in an ancestor class to be overridden: "Foo;"
+    procedure Foo; override;
+  end;
+
+procedure TB<T>.Foo;
+begin
+end;
+
+begin
+end.
+