Browse Source

* don't allow generics as parent classes

git-svn-id: trunk@8144 -
peter 18 years ago
parent
commit
ad4846a50e
3 changed files with 22 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 8 0
      compiler/pdecobj.pas
  3. 13 0
      tests/webtbf/tw8591.pp

+ 1 - 0
.gitattributes

@@ -7391,6 +7391,7 @@ tests/webtbf/tw8465a.pp svneol=native#text/plain
 tests/webtbf/tw8528.pp svneol=native#text/plain
 tests/webtbf/tw8583.pp svneol=native#text/plain
 tests/webtbf/tw8588.pp svneol=native#text/plain
+tests/webtbf/tw8591.pp -text
 tests/webtbf/tw8738.pas svneol=native#text/plain
 tests/webtbf/tw8777a.pp svneol=native#text/plain
 tests/webtbf/tw8777b.pp svneol=native#text/plain

+ 8 - 0
compiler/pdecobj.pas

@@ -439,6 +439,14 @@ implementation
               hasparentdefined:=true;
             end;
 
+          { no generic as parents }
+          if assigned(childof) and
+             (df_generic in childof.defoptions) then
+            begin
+              Message(parser_e_no_generics_as_types);
+              childof:=nil;
+            end;
+
           { if no parent class, then a class get tobject as parent }
           if not assigned(childof) then
             begin

+ 13 - 0
tests/webtbf/tw8591.pp

@@ -0,0 +1,13 @@
+{ %fail }
+
+{$mode objfpc}
+
+type
+  generic TG1<T> = class
+  end;
+
+  generic TG2<T> = class(TG1)
+  end;
+
+begin
+end.