Commit 44cb2dc6 authored by Xavier Thompson's avatar Xavier Thompson

Add two unit tests to check that inherited methods are hidden by overrides

parent 88812dee
# mode: error
# tag: cpp, cpp11, pthread
# cython: experimental_cpp_class_def=True, language_level=2
cdef cypclass A:
void foo(self, int a):
pass
cdef cypclass B(A):
void foo(self, int a, int b):
pass
def test_hidden_overridden_methods():
cdef B b = B()
# A.foo is hidden by B.foo, regardless of signature
b.foo(1)
_ERRORS = u"""
17:9: Call with wrong number of arguments (expected 2, got 1)
"""
\ No newline at end of file
# mode: run
# tag: cpp, cpp11, pthread
# cython: experimental_cpp_class_def=True, language_level=2
cdef cypclass A nolock:
int a
__init__(self, int a):
self.a = a
A foo(self, int other):
return A(a + other)
cdef cypclass B(A) nolock:
int b
__init__(self, int b):
self.b = 10 + b
B foo(self, int other):
return B(b + other)
def test_hide_override():
"""
>>> test_hide_override()
21
"""
cdef B b1 = B(0)
# This should not result in a 'ambiguous overloaded method' compilation error
cdef B b2 = b1.foo(1)
return b2.b
\ No newline at end of file
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