Commit bd0bd943 authored by Robert Bradshaw's avatar Robert Bradshaw

Yet more template parameter inference refinement.

parent 7dfa5d63
...@@ -2265,7 +2265,7 @@ class CArrayType(CPointerBaseType): ...@@ -2265,7 +2265,7 @@ class CArrayType(CPointerBaseType):
if isinstance(actual, CArrayType): if isinstance(actual, CArrayType):
return self.base_type.deduce_template_params(actual.base_type) return self.base_type.deduce_template_params(actual.base_type)
else: else:
return None return {}
def can_coerce_to_pyobject(self, env): def can_coerce_to_pyobject(self, env):
return self.base_type.can_coerce_to_pyobject(env) return self.base_type.can_coerce_to_pyobject(env)
...@@ -2403,7 +2403,7 @@ class CPtrType(CPointerBaseType): ...@@ -2403,7 +2403,7 @@ class CPtrType(CPointerBaseType):
if isinstance(actual, CPtrType): if isinstance(actual, CPtrType):
return self.base_type.deduce_template_params(actual.base_type) return self.base_type.deduce_template_params(actual.base_type)
else: else:
return None return {}
def invalid_value(self): def invalid_value(self):
return "1" return "1"
...@@ -3516,7 +3516,7 @@ class CppClassType(CType): ...@@ -3516,7 +3516,7 @@ class CppClassType(CType):
if self == actual: if self == actual:
return {} return {}
elif actual.is_cpp_class: elif actual.is_cpp_class:
self_template_type = self.template_type or self self_template_type = self
while getattr(self_template_type, 'template_type', None): while getattr(self_template_type, 'template_type', None):
self_template_type = self_template_type.template_type self_template_type = self_template_type.template_type
def all_bases(cls): def all_bases(cls):
......
...@@ -15,6 +15,7 @@ cdef extern from "cpp_template_functions_helper.h": ...@@ -15,6 +15,7 @@ cdef extern from "cpp_template_functions_helper.h":
int overloaded(double x) int overloaded(double x)
T overloaded(pair[T, T]) T overloaded(pair[T, T])
U overloaded[U](vector[U]) U overloaded[U](vector[U])
X overloaded[X](char* s, vector[X])
cdef T nested_deduction[T](const T*) cdef T nested_deduction[T](const T*)
pair[T, U] pair_arg[T, U](pair[T, U] a) pair[T, U] pair_arg[T, U](pair[T, U] a)
cdef T* pointer_param[T](T*) cdef T* pointer_param[T](T*)
...@@ -114,5 +115,6 @@ def test_overload_GH1583(): ...@@ -114,5 +115,6 @@ def test_overload_GH1583():
assert a.overloaded(p) == 2 assert a.overloaded(p) == 2
cdef vector[double] v = [0.25, 0.125] cdef vector[double] v = [0.25, 0.125]
assert a.overloaded(v) == 0.25 assert a.overloaded(v) == 0.25
assert a.overloaded("s", v) == 0.25
# GH Issue #1584 # GH Issue #1584
# assert a.overloaded[double](v) == 0.25 # assert a.overloaded[double](v) == 0.25
...@@ -39,6 +39,10 @@ class A { ...@@ -39,6 +39,10 @@ class A {
U overloaded(std::vector<U> v) { U overloaded(std::vector<U> v) {
return v[0]; return v[0];
} }
template <typename U>
U overloaded(char* c, std::vector<U> v) {
return v[0];
}
}; };
template <typename T> template <typename T>
......
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