From e3e96e3faa1683c8ee832cb6da6f9f96d18b0d77 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 9 Feb 2020 20:13:49 +0900 Subject: Check if bindable against the refined target [Bug #16617] --- test/ruby/test_refinement.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index c6707ff54c..1f2a67eeb2 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -2386,6 +2386,25 @@ class TestRefinement < Test::Unit::TestCase assert_equal(0, Bug13446::GenericEnumerable.new.sum) end + def test_unbound_refine_method + a = EnvUtil.labeled_class("A") do + def foo + self.class + end + end + b = EnvUtil.labeled_class("B") + bar = EnvUtil.labeled_module("R") do + break refine a do + def foo + super + end + end + end + assert_raise(TypeError) do + bar.instance_method(:foo).bind(b.new) + end + end + private def eval_using(mod, s) -- cgit v1.2.3