Commit da819b90 authored by gsamain's avatar gsamain

Declare a default constructor only when there is no other one inherited

(if the class redefines a constructor with a compatible signature,
it will get overridden, so it effectively prevents the default
constructor from spawning when there may be an ambiguity)
parent 73b43166
...@@ -651,15 +651,16 @@ class Scope(object): ...@@ -651,15 +651,16 @@ class Scope(object):
this_type = PyrexTypes.CPtrType(entry.type) if not cypclass else entry.type this_type = PyrexTypes.CPtrType(entry.type) if not cypclass else entry.type
scope.declare_var(name="this", cname="this", type=this_type, pos=entry.pos) scope.declare_var(name="this", cname="this", type=this_type, pos=entry.pos)
if cypclass: if cypclass:
# Declare a shadow default constructor if not scope.lookup_here("<init>"):
wrapper_type = PyrexTypes.CFuncType(entry.type, [], nogil=1) # Declare a shadow default constructor
wrapper_cname = "%s__constructor__%s" % (Naming.func_prefix, name) wrapper_type = PyrexTypes.CFuncType(entry.type, [], nogil=1)
wrapper_name = "<constructor>" wrapper_cname = "%s__constructor__%s" % (Naming.func_prefix, name)
wrapper_entry = scope.declare(wrapper_name, wrapper_cname, wrapper_type, pos, visibility) wrapper_name = "<constructor>"
wrapper_type.entry = wrapper_entry wrapper_entry = scope.declare(wrapper_name, wrapper_cname, wrapper_type, pos, visibility)
wrapper_entry.is_inherited = 1 wrapper_type.entry = wrapper_entry
wrapper_entry.is_cfunction = 1 wrapper_entry.is_inherited = 1
wrapper_entry.func_cname = "%s::%s" % (entry.type.empty_declaration_code(), wrapper_cname) wrapper_entry.is_cfunction = 1
wrapper_entry.func_cname = "%s::%s" % (entry.type.empty_declaration_code(), wrapper_cname)
# Declare the default __alloc__ method # Declare the default __alloc__ method
alloc_type = PyrexTypes.CFuncType(entry.type, [], nogil=1) alloc_type = PyrexTypes.CFuncType(entry.type, [], nogil=1)
......
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