def aggressive_spanning_type(types, might_overflow):
result_type = reduce(find_spanning_type, types)
+ if result_type.is_reference:
+ result_type = result_type.ref_base_type
return result_type
def safe_spanning_type(types, might_overflow):
result_type = reduce(find_spanning_type, types)
+ if result_type.is_reference:
+ result_type = result_type.ref_base_type
if result_type.is_pyobject:
# any specific Python type is always safe to infer
return result_type
+cimport cython
+
+
cdef extern from "cpp_references_helper.h":
cdef int& ref_func(int&)
cdef int ref_var_value
cdef int& ref_var
+
def test_ref_func(int x):
"""
>>> test_ref_func(2)
"""
cdef double d = ref_func(x)
return d
+
+@cython.infer_types(True)
+def test_ref_inference(int x):
+ """
+ >>> test_ref_inference(23)
+ 23
+ >>> test_ref_inference(29)
+ 29
+ """
+ z = ref_func(x)
+ assert cython.typeof(z) == "int", cython.typeof(z)
+ return z