mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-05 05:47:37 +01:00
compiler: allow generics as class parents + fixed test
git-svn-id: trunk@16708 -
This commit is contained in:
parent
bd64575add
commit
d55a141d70
@ -527,14 +527,6 @@ 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
|
||||
|
||||
@ -1,20 +1,21 @@
|
||||
program Project1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$apptype console}
|
||||
|
||||
type
|
||||
|
||||
{ TStack }
|
||||
|
||||
generic TStack<T> = class(TObject)
|
||||
public
|
||||
public
|
||||
procedure Clear; virtual;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
{ TIntegerStack }
|
||||
{ TAdvStack }
|
||||
|
||||
TAdvStack = class(specialize TStack<T>)
|
||||
generic TAdvStack<T> = class(specialize TStack<T>)
|
||||
public
|
||||
procedure Clear; override;
|
||||
end;
|
||||
@ -25,7 +26,7 @@ type
|
||||
|
||||
{ TIntegerStack2 }
|
||||
|
||||
TIntegerStack2 = class(specialize TAdvStack<Integer>);
|
||||
TIntegerStack2 = class(specialize TAdvStack<Integer>)
|
||||
public
|
||||
procedure Clear; override;
|
||||
end;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user