-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
Several forms of aliasing should not warn when overwriting an existing entry, but they currently do on JRuby. This leads to warnings like the following:
/home/enebo/work/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/callbacks.rb:68: warning: previous definition of bar __callbacks
/home/enebo/work/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/module/redefine_method.rb:12: warning: method redefined; discarding old __callbacks
/home/enebo/work/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/callbacks.rb:68: warning: previous definition of bar __callbacks
/home/enebo/work/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/module/redefine_method.rb:12: warning: method redefined; discarding old __callbacks=
/home/enebo/work/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/callbacks.rb:68: warning: previous definition of bar __callbacks=
/home/enebo/work/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/module/redefine_method.rb:12: warning: method redefined; discarding old __callbacks?
/home/enebo/work/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/callbacks.rb:68: warning: previous definition of bar __callbacks?
/home/enebo/work/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/module/redefine_method.rb:12: warning: method redefined; discarding old __callbacks
/home/enebo/work/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/callbacks.rb:68: warning: previous definition of bar __callbacks
/home/enebo/work/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/module/redefine_method.rb:12: warning: method redefined; discarding old __callbacks?
A recent patch to master (ec399fa) prevents a warning when aliasing a method to itself, but there are additional flags in CRuby that prevent warning on overwriting a target method:
if (RTEST(ruby_verbose) &&
type != VM_METHOD_TYPE_UNDEF &&
(old_def->alias_count == 0) &&
(!old_def->no_redef_warning) &&
...After the patch, generating a Rails 7 app still generates warnings like this:
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/date/conversions.rb:67: warning: method redefined; discarding old inspect
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/date/calculations.rb:99: warning: method redefined; discarding old +
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/date/calculations.rb:109: warning: method redefined; discarding old -
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/date/calculations.rb:146: warning: method redefined; discarding old <=>
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/time/calculations.rb:61: warning: method redefined; discarding old at
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/time/calculations.rb:289: warning: method redefined; discarding old +
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/time/calculations.rb:299: warning: method redefined; discarding old -
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/time/calculations.rb:309: warning: method redefined; discarding old -
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/time/calculations.rb:324: warning: method redefined; discarding old <=>
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/time/calculations.rb:334: warning: method redefined; discarding old eql?
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/activesupport-7.0.2.3/lib/active_support/core_ext/string/output_safety.rb:25: warning: method redefined; discarding old h
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/nokogiri-1.13.4-java/lib/nokogiri/xml/node.rb:915: warning: method redefined; discarding old attr
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/java_thread_pool_executor.rb:14: warning: method redefined; discarding old to_int
/Users/headius/projects/jruby/lib/ruby/gems/shared/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/java_thread_pool_executor.rb:14: warning: method redefined; discarding old to_f
We do not track alias reference counts nor this no_redef_warning (added very recently) which are both used to avoid warning when adding an alias that overwrites an existing entry.
Relates to #7175 but not a very high priority because this only causes warnings in verbose/debug mode.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels