Project

General

Profile

Actions

Bug #2375

closed

protected singleton methods can be called from other instances

Added by shugo (Shugo Maeda) over 14 years ago. Updated about 13 years ago.

Status:
Closed
Target version:
-
ruby -v:
1.9.2dev
Backport:
[ruby-core:26761]

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

protected_singleton_method.diff (842 Bytes) protected_singleton_method.diff a patch to forbid protected singleton calles from other instances shugo (Shugo Maeda), 11/16/2009 02:26 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #4106: 1.9.2 regression - invoking protected singleton methodsRejected12/01/2010Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0