Commit b185d25f authored by Dimitri Tcaciuc's avatar Dimitri Tcaciuc

Fix for a failing case of template reference arguments

with some improvements to previously committed test case
parent d80abcdd
...@@ -600,7 +600,7 @@ class ExprNode(Node): ...@@ -600,7 +600,7 @@ class ExprNode(Node):
if self.check_for_coercion_error(dst_type): if self.check_for_coercion_error(dst_type):
return self return self
if dst_type.is_reference: if dst_type.is_reference and not src_type.is_reference:
dst_type = dst_type.ref_base_type dst_type = dst_type.ref_base_type
if src_type.is_fused or dst_type.is_fused: if src_type.is_fused or dst_type.is_fused:
......
...@@ -8,7 +8,6 @@ missing_baseclass_in_predecl_T262 ...@@ -8,7 +8,6 @@ missing_baseclass_in_predecl_T262
cfunc_call_tuple_args_T408 cfunc_call_tuple_args_T408
compile.cpp_operators compile.cpp_operators
cpp_templated_ctypedef cpp_templated_ctypedef
cpp_template_args
cpp_structs cpp_structs
function_as_method_T494 function_as_method_T494
closure_inside_cdef_T554 closure_inside_cdef_T554
......
cdef extern from "template_args.h":
cdef cppclass Bar [T]:
Bar()
cdef cppclass Foo [T]:
Foo()
void set_bar(Bar[size_t] & bar)
cpdef func():
cdef Foo[int] foo
cdef Bar[size_t] bar
cdef Bar[size_t] & bref = bar
foo.set_bar(bref)
...@@ -3,11 +3,13 @@ ...@@ -3,11 +3,13 @@
template <typename T> template <typename T>
struct Bar { struct Bar {
Bar & ref() { return *this; }
T value;
}; };
template <typename T> template <typename T>
struct Foo { struct Foo {
void set_bar(const Bar[size_t] & bar) {} int bar_value(const Bar<int> & bar) { return bar.value; }
}; };
#endif #endif
# tag: cpp
cdef extern from "cpp_template_ref_args.h":
cdef cppclass Bar[T]:
Bar()
Bar[T] & ref()
T value
cdef cppclass Foo[T]:
Foo()
int bar_value(Bar[int] & bar)
def test_template_ref_arg(int x):
"""
>>> test_template_ref_arg(4)
4
"""
# Templated reference parameters in method
# of templated classes were not properly coalesced.
cdef Foo[size_t] foo
cdef Bar[int] bar
bar.value = x
return foo.bar_value(bar.ref())
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