Skip to content

Commit

Permalink
fix super lookup for singleton methods
Browse files Browse the repository at this point in the history
  • Loading branch information
timfel committed Feb 14, 2017
1 parent 4103bb0 commit 08f1865
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions spec/tags/language/super_tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ fails:The super keyword searches class methods including modules
fails:The super keyword searches BasicObject from a module for methods defined there
fails:The super keyword searches BasicObject through another module for methods defined there
fails:The super keyword raises a RuntimeError when called with implicit arguments from a method defined with define_method
fails:The super keyword invokes methods from a chain of anonymous modules
fails:The super keyword without explicit arguments that are '_'
fails:The super keyword without explicit arguments that are '_' including any modifications
fails:The super keyword when using keyword arguments passes any given keyword arguments including optional and required ones to the parent
12 changes: 10 additions & 2 deletions topaz/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,11 @@ def SEND_SUPER_BLOCK(self, space, bytecode, frame, pc, meth_idx, num_args):
w_block = None
else:
assert isinstance(w_block, W_ProcObject)
w_res = space.send_super(frame.lexical_scope.w_mod, w_receiver, space.symbol_w(bytecode.consts_w[meth_idx]), args_w, block=w_block)
if frame.lexical_scope is not None:
w_cls = frame.lexical_scope.w_mod
else:
w_cls = space.getclass(w_receiver)
w_res = space.send_super(w_cls, w_receiver, space.symbol_w(bytecode.consts_w[meth_idx]), args_w, block=w_block)
frame.push(w_res)

@jit.unroll_safe
Expand All @@ -605,7 +609,11 @@ def SEND_SUPER_BLOCK_SPLAT(self, space, bytecode, frame, pc, meth_idx, num_args)
w_block = None
else:
assert isinstance(w_block, W_ProcObject)
w_res = space.send_super(frame.lexical_scope.w_mod, w_receiver, space.symbol_w(bytecode.consts_w[meth_idx]), args_w, block=w_block)
if frame.lexical_scope is not None:
w_cls = frame.lexical_scope.w_mod
else:
w_cls = space.getclass(w_receiver)
w_res = space.send_super(w_cls, w_receiver, space.symbol_w(bytecode.consts_w[meth_idx]), args_w, block=w_block)
frame.push(w_res)

def DEFINED_SUPER(self, space, bytecode, frame, pc, meth_idx):
Expand Down

0 comments on commit 08f1865

Please sign in to comment.