Skip to content

Commit

Permalink
Fix a few visibility problems. Fixes rubinius#219.
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Phoenix committed Mar 29, 2010
1 parent 9205eab commit 2f79333
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
15 changes: 0 additions & 15 deletions kernel/delta/module.rb
@@ -1,19 +1,4 @@
class Module
#--
# HACK: This should work after after the bootstrap is loaded,
# but it seems to blow things up, so it's only used after
# core is loaded. I think it's because the bootstrap Class#new
# doesn't use a privileged send.
#++

def __method_added__(name)
if name == :initialize
private :initialize
end

method_added(name) if self.respond_to? :method_added
end

def alias_method(new_name, current_name)
new_name = Type.coerce_to_symbol(new_name)
current_name = Type.coerce_to_symbol(current_name)
Expand Down
12 changes: 8 additions & 4 deletions kernel/delta/rubinius.rb
Expand Up @@ -96,7 +96,11 @@ def self.add_defn_method(name, executable, static_scope, vis)
def self.add_method(name, executable, mod, vis)
vis ||= :public

if vis == :module or name == :initialize or name == :initialize_copy
# Don't change the visibility for methods added to singleton
# classes
if Class === mod and mod.__metaclass_object__
visibility = vis
elsif vis == :module or name == :initialize or name == :initialize_copy
visibility = :private
else
visibility = vis
Expand All @@ -117,7 +121,7 @@ def self.add_method(name, executable, mod, vis)
# commonly can't run yet because it requires methods that haven't been
# added yet. (ActionMailer does this)

if mod.kind_of? Class and obj = mod.__metaclass_object__
if Class === mod and obj = mod.__metaclass_object__
if obj.kind_of? Numeric

# Such a weird protocol. If :singleton_method_added exists, allow this.
Expand All @@ -127,11 +131,11 @@ def self.add_method(name, executable, mod, vis)
end
end

if Rubinius.object_respond_to? obj, :singleton_method_added
Rubinius.privately do
obj.singleton_method_added(name)
end
else
if Rubinius.object_respond_to? mod, :method_added
Rubinius.privately do
mod.method_added(name)
end
end
Expand Down

0 comments on commit 2f79333

Please sign in to comment.