Commit 78b1c068 authored by Robert Bradshaw's avatar Robert Bradshaw

Don't inherit template parameters as types.

parent e8a178e8
...@@ -593,7 +593,7 @@ class Scope(object): ...@@ -593,7 +593,7 @@ class Scope(object):
error(pos, "Cannot inherit from incomplete type") error(pos, "Cannot inherit from incomplete type")
else: else:
declare_inherited_attributes(entry, base_class.base_classes) declare_inherited_attributes(entry, base_class.base_classes)
entry.type.scope.declare_inherited_cpp_attributes(base_class.scope) entry.type.scope.declare_inherited_cpp_attributes(base_class)
if scope: if scope:
declare_inherited_attributes(entry, base_classes) declare_inherited_attributes(entry, base_classes)
scope.declare_var(name="this", cname="this", type=PyrexTypes.CPtrType(entry.type), pos=entry.pos) scope.declare_var(name="this", cname="this", type=PyrexTypes.CPtrType(entry.type), pos=entry.pos)
...@@ -2276,7 +2276,15 @@ class CppClassScope(Scope): ...@@ -2276,7 +2276,15 @@ class CppClassScope(Scope):
type.entry = entry type.entry = entry
return entry return entry
def declare_inherited_cpp_attributes(self, base_scope): def declare_inherited_cpp_attributes(self, base_class):
base_scope = base_class.scope
template_type = base_class
while getattr(template_type, 'template_type', None):
template_type = template_type.template_type
if getattr(template_type, 'templates', None):
base_templates = [T.name for T in template_type.templates]
else:
base_templates = ()
# Declare entries for all the C++ attributes of an # Declare entries for all the C++ attributes of an
# inherited type, with cnames modified appropriately # inherited type, with cnames modified appropriately
# to work with this type. # to work with this type.
...@@ -2300,10 +2308,11 @@ class CppClassScope(Scope): ...@@ -2300,10 +2308,11 @@ class CppClassScope(Scope):
utility_code=base_entry.utility_code) utility_code=base_entry.utility_code)
entry.is_inherited = 1 entry.is_inherited = 1
for base_entry in base_scope.type_entries: for base_entry in base_scope.type_entries:
entry = self.declare_type(base_entry.name, base_entry.type, if base_entry.name not in base_templates:
base_entry.pos, base_entry.cname, entry = self.declare_type(base_entry.name, base_entry.type,
base_entry.visibility) base_entry.pos, base_entry.cname,
entry.is_inherited = 1 base_entry.visibility)
entry.is_inherited = 1
def specialize(self, values, type_entry): def specialize(self, values, type_entry):
scope = CppClassScope(self.name, self.outer_scope) scope = CppClassScope(self.name, self.outer_scope)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment