Commit 704ba4da authored by Robert Bradshaw's avatar Robert Bradshaw

Ensure signature extensions reflected in the pxd if needed.

This fixes #1732.
parent 0ead474c
......@@ -2088,6 +2088,11 @@ class CClassScope(ClassScope):
# Fix with_gil vs nogil.
entry.type = entry.type.with_with_gil(type.with_gil)
elif type.compatible_signature_with(entry.type, as_cmethod = 1) and type.nogil == entry.type.nogil:
if self.defined and not in_pxd:
error(pos,
"Compatible but non-identical C method '%s' not redeclared "
"in definition part of extension type" % name)
error(entry.pos, "Previous declaration is here")
entry = self.add_cfunction(name, type, pos, cname, visibility='ignore', modifiers=modifiers)
else:
error(pos, "Signature not compatible with previous declaration")
......
......@@ -8,7 +8,32 @@ cdef class D(C):
cdef void f(self, int x):
pass
# These are declared in the pxd.
cdef class Base(object):
cdef f(self):
pass
cdef class MissingRedeclaration(Base):
# Not declared (so assumed cdef) in the pxd.
cpdef f(self):
pass
cdef class BadRedeclaration(Base):
# Declared as cdef in the pxd.
cpdef f(self):
pass
cdef class UnneededRedeclaration(Base):
# This is OK, as it's not declared in the pxd.
cpdef f(self):
pass
_ERRORS = u"""
8: 9: Signature not compatible with previous declaration
4: 9: Previous declaration is here
18:8: Compatible but non-identical C method 'f' not redeclared in definition part of extension type
2:9: Previous declaration is here
23:8: Compatible but non-identical C method 'f' not redeclared in definition part of extension type
2:9: Previous declaration is here
"""
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