Commit 9141e7a5 authored by Vadim Pushtaev's avatar Vadim Pushtaev Committed by GitHub

Allow using nested C++ types of typedefs (GH-4039)

Closes https://github.com/cython/cython/issues/2233
parent ff1f703b
......@@ -1044,7 +1044,10 @@ class CSimpleBaseTypeNode(CBaseTypeNode):
scope = env
for item in self.module_path:
entry = scope.lookup(item)
if entry is not None and entry.is_cpp_class:
if entry is not None and (
entry.is_cpp_class or
entry.is_type and entry.type.is_cpp_class
):
scope = entry.type.scope
else:
scope = None
......
......@@ -26,6 +26,10 @@ cdef extern from "cpp_nested_classes_support.h":
pass
ctypedef A AliasA1
ctypedef AliasA1 AliasA2
def test_nested_classes():
"""
>>> test_nested_classes()
......@@ -47,6 +51,20 @@ def test_nested_typedef(py_x):
cdef A.my_int x = py_x
assert A.negate(x) == -py_x
def test_typedef_for_nested(py_x):
"""
>>> test_typedef_for_nested(5)
"""
cdef AliasA1.my_int x = py_x
assert A.negate(x) == -py_x
def test_typedef_for_nested_deep(py_x):
"""
>>> test_typedef_for_nested_deep(5)
"""
cdef AliasA2.my_int x = py_x
assert A.negate(x) == -py_x
def test_typed_nested_typedef(x):
"""
>>> test_typed_nested_typedef(4)
......
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