Commit c62dbb2b authored by gsamain's avatar gsamain Committed by Xavier Thompson

Cpp: Correct CppClassScope to allow method overloading with different signature

parent 2549997d
...@@ -2518,15 +2518,17 @@ class CppClassScope(Scope): ...@@ -2518,15 +2518,17 @@ class CppClassScope(Scope):
cname = name cname = name
entry = self.lookup_here(name) entry = self.lookup_here(name)
if defining and entry is not None: if defining and entry is not None:
if entry.type.same_as(type): if type.is_cfunction:
entry = self.declare(name, cname, type, pos, visibility)
elif entry.type.same_as(type):
# Fix with_gil vs nogil. # Fix with_gil vs nogil.
entry.type = entry.type.with_with_gil(type.with_gil) entry.type = entry.type.with_with_gil(type.with_gil)
elif type.is_cfunction and type.compatible_signature_with(entry.type):
entry.type = type
else: else:
error(pos, "Function signature does not match previous declaration") error(pos, "Function signature does not match previous declaration")
else: else:
entry = self.declare(name, cname, type, pos, visibility) entry = self.declare(name, cname, type, pos, visibility)
if type.is_cfunction and not defining:
entry.is_inherited = 1
entry.is_variable = 1 entry.is_variable = 1
entry.is_cfunction = type.is_cfunction entry.is_cfunction = type.is_cfunction
if type.is_cfunction and self.type: if type.is_cfunction and self.type:
...@@ -2564,7 +2566,8 @@ class CppClassScope(Scope): ...@@ -2564,7 +2566,8 @@ class CppClassScope(Scope):
if base_entry and not base_entry.type.nogil: if base_entry and not base_entry.type.nogil:
error(pos, "Constructor cannot be called without GIL unless all base constructors can also be called without GIL") error(pos, "Constructor cannot be called without GIL unless all base constructors can also be called without GIL")
error(base_entry.pos, "Base constructor defined here.") error(base_entry.pos, "Base constructor defined here.")
prev_entry = self.lookup_here(name) # The previous entries management is now done directly in Scope.declare
#prev_entry = self.lookup_here(name)
entry = self.declare_var(name, type, pos, entry = self.declare_var(name, type, pos,
defining=defining, defining=defining,
cname=cname, visibility=visibility) cname=cname, visibility=visibility)
......
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