summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorda-woods <dw-git@d-woods.co.uk>2019-10-24 11:33:25 +0100
committerda-woods <dw-git@d-woods.co.uk>2019-10-24 11:33:25 +0100
commit073f25c155d0266c97cc88a1d713924ea4e48973 (patch)
tree1c6469f57effaef87646bcb12c1796a96ea56820
parent1b5b0a514d5e51e85a90dd891190f81d646ff47c (diff)
downloadcython-073f25c155d0266c97cc88a1d713924ea4e48973.tar.gz
Bring attribute.fused types in line
-rw-r--r--Cython/Compiler/ExprNodes.py14
-rw-r--r--tests/run/fused_cpp.pyx11
2 files changed, 21 insertions, 4 deletions
diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py
index d9b754daa..22eabb5ab 100644
--- a/Cython/Compiler/ExprNodes.py
+++ b/Cython/Compiler/ExprNodes.py
@@ -6907,14 +6907,20 @@ class AttributeNode(ExprNode):
return None
def analyse_as_type(self, env):
+ tp = None
module_scope = self.obj.analyse_as_module(env)
if module_scope:
- return module_scope.lookup_type(self.attribute)
- if not self.obj.is_string_literal:
+ tp = module_scope.lookup_type(self.attribute)
+ elif not self.obj.is_string_literal:
base_type = self.obj.analyse_as_type(env)
if base_type and hasattr(base_type, 'scope') and base_type.scope is not None:
- return base_type.scope.lookup_type(self.attribute)
- return None
+ tp = base_type.scope.lookup_type(self.attribute)
+ if tp and tp.is_fused and env.fused_to_specific:
+ try:
+ tp = tp.specialize(env.fused_to_specific)
+ except KeyError:
+ pass # just use unspecialized type
+ return tp
def analyse_as_extension_type(self, env):
# Try to interpret this as a reference to an extension type
diff --git a/tests/run/fused_cpp.pyx b/tests/run/fused_cpp.pyx
index ff361e769..9f3bb5104 100644
--- a/tests/run/fused_cpp.pyx
+++ b/tests/run/fused_cpp.pyx
@@ -30,3 +30,14 @@ def typeid_call(C x):
"""
cdef const type_info* a = &typeid(C)
return a[0] == tidint[0]
+
+cimport cython
+
+def typeid_call2(cython.integral x):
+ """
+ For GH issue 3203
+ >>> typeid_call2[int](1)
+ True
+ """
+ cdef const type_info* a = &typeid(cython.integral)
+ return a[0] == tidint[0]