summaryrefslogtreecommitdiff
path: root/Cython/Compiler/ParseTreeTransforms.py
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2017-09-20 09:12:40 +0200
committerStefan Behnel <stefan_ml@behnel.de>2017-09-20 12:11:24 +0200
commitfcc3461e0077c86e30cc81a2fd78bce60f1be007 (patch)
tree48796374c4a30fbf411be1ec0eaa5e51f4b7cbf6 /Cython/Compiler/ParseTreeTransforms.py
parent625562c9b4764e55c3a1b05751928af6fb17a93c (diff)
downloadcython-fcc3461e0077c86e30cc81a2fd78bce60f1be007.tar.gz
Make vtable order of extension types with fused methods only dependant on the original declaration order (e.g. in the .pxd file).
Previously, fused methods were specialised and expanded on first use, which lead to an arbitrary order in the vtable. Also fixes compile failures when inheriting from base types with fused cdef methods. Fixes #1873.
Diffstat (limited to 'Cython/Compiler/ParseTreeTransforms.py')
-rw-r--r--Cython/Compiler/ParseTreeTransforms.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py
index 61625e842..7ee9861a8 100644
--- a/Cython/Compiler/ParseTreeTransforms.py
+++ b/Cython/Compiler/ParseTreeTransforms.py
@@ -1535,6 +1535,13 @@ class ForwardDeclareTypes(CythonTransform):
def visit_CClassDefNode(self, node):
if node.class_name not in self.module_scope.entries:
node.declare(self.module_scope)
+ # Expand fused methods of .pxd declared types to construct the final vtable order.
+ type = self.module_scope.entries[node.class_name].type
+ if type is not None and type.is_extension_type and not type.is_builtin_type and type.scope:
+ scope = type.scope
+ for entry in scope.cfunc_entries:
+ if entry.type and entry.type.is_fused:
+ entry.type.get_all_specialized_function_types()
return node