From 08f18651b0e32f375bfb5bec73f0165fa56ccbd7 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Tue, 14 Feb 2017 14:43:42 +0100 Subject: [PATCH] fix super lookup for singleton methods --- spec/tags/language/super_tags.txt | 4 ++++ topaz/interpreter.py | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/spec/tags/language/super_tags.txt b/spec/tags/language/super_tags.txt index 8e635a74a..2666f4d14 100644 --- a/spec/tags/language/super_tags.txt +++ b/spec/tags/language/super_tags.txt @@ -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 diff --git a/topaz/interpreter.py b/topaz/interpreter.py index 8227e4efc..8890c8047 100644 --- a/topaz/interpreter.py +++ b/topaz/interpreter.py @@ -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 @@ -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):