a type in a generic which is inherited by another generic
Original Reporter info from Mantis: blochee
-
Reporter name: Raheman
Original Reporter info from Mantis: blochee
- Reporter name: Raheman
Description:
When you define a type T in a generic A then a generic B inheriting generic A will not be able to use T. The compiler will output error:
testing_ground.lpr(15,39) Error: Generics without specialization cannot be used as a type for a variable
But then, if you try to redefine T in B then you get the error:
testing_ground.lpr(15,31) Error: Duplicate identifier "specialized_TNode"
So, either fix it so that B can use T or then allow B to redefine T.
Steps to reproduce:
To get the first error:
type
generic TNode<data_type> = class // anything can go in this class
end;
generic TLinkedList<data_type> = class
type
specialized_TNode = specialize TNode<data_type>;
public
node : specialized_TNode;
end;
generic TExtendedLinkedList<data_type> = class (specialize TLinkedList<data_type>)
public
last_node : specialized_TNode;
end;
end.
To get the second error:
type
generic TNode<data_type> = class // anything can go in this class
end;
generic TLinkedList<data_type> = class
type
specialized_TNode = specialize TNode<data_type>;
public
node : specialized_TNode;
end;
generic TExtendedLinkedList<data_type> = class (specialize TLinkedList<data_type>)
type
specialized_TNode = specialize TNode<data_type>;
public
last_node : specialized_TNode;
end;
end.
Additional information:
This is my first bug report! Don't be to hard on me.
Mantis conversion info:
- Mantis ID: 26123
- OS: Ubuntu
- OS Build: 12.04.4 LTS
- Build: ?
- Platform: Lazarus 1.2.2
- Version: 2.7.1
- Fixed in version: 3.0.0
- Fixed in revision: 27877 (#49a9f4c1)