Actions
Bug #2375
closedprotected singleton methods can be called from other instances
Bug #2375:
protected singleton methods can be called from other instances
Description
=begin
It seems that protected singleton methods of an object can be called from other instances of the class of the object.
class Foo
end
FOO = Foo.new
class << FOO
protected
def bar
puts "bar"
end
end
class Foo
def baz
FOO.bar
end
end
FOO.baz
Foo.new.baz # CRuby does not raise NoMethodError, but IronRuby does.
On IronRuby, Foo.new.baz raies NoMethodError, and I guess it's more reasonable than the behavior of CRuby. I have attached a patch.
However, I haven't been able to find any use cases of protected singleton methods.
=end
Files
Actions