Commit bc831681 authored by Xavier Thompson's avatar Xavier Thompson

Type 'self' as const inside const cypclass methods

parent baae5864
...@@ -581,10 +581,8 @@ class CypclassLockTransform(Visitor.EnvTransform): ...@@ -581,10 +581,8 @@ class CypclassLockTransform(Visitor.EnvTransform):
cyp_class_args = (e for e in node.local_scope.arg_entries if e.type.is_cyp_class) cyp_class_args = (e for e in node.local_scope.arg_entries if e.type.is_cyp_class)
arg_locks = [] arg_locks = []
for arg in cyp_class_args: for arg in cyp_class_args:
is_rlocked = arg.type.is_const or arg.is_self_arg and node.entry.type.is_const_method
arg_id = arg
# Mark each cypclass arguments as locked within the function body # Mark each cypclass arguments as locked within the function body
arg_locks.append(self.stacklock(arg_id, "rlocked" if is_rlocked else "wlocked")) arg_locks.append(self.stacklock(arg, "rlocked" if arg.type.is_const else "wlocked"))
with_body = lambda: self.visit(node.body) with_body = lambda: self.visit(node.body)
self.with_nested_stacklocks(iter(arg_locks), with_body) self.with_nested_stacklocks(iter(arg_locks), with_body)
return node return node
......
...@@ -2711,6 +2711,8 @@ class CFuncDefNode(FuncDefNode): ...@@ -2711,6 +2711,8 @@ class CFuncDefNode(FuncDefNode):
if declarator.skipped_self: if declarator.skipped_self:
_name, _type, _pos, _ = declarator.skipped_self _name, _type, _pos, _ = declarator.skipped_self
_cname = "this" _cname = "this"
if self.is_const_method:
_type = PyrexTypes.CConstType(_type)
entry = self.local_scope.declare(_name, _cname, _type, _pos, 'private') entry = self.local_scope.declare(_name, _cname, _type, _pos, 'private')
entry.is_variable = 1 entry.is_variable = 1
entry.is_self_arg = 1 entry.is_self_arg = 1
......
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