Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not clear deprecated initializer dependencies if using classic autoloader #36395

Merged
merged 1 commit into from Jun 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions railties/lib/rails/application/finisher.rb
Expand Up @@ -39,8 +39,14 @@ module Finisher
example = autoloaded.first
example_klass = example.constantize.class

ActiveSupport::DescendantsTracker.clear
ActiveSupport::Dependencies.clear
if config.autoloader == :zeitwerk
ActiveSupport::DescendantsTracker.clear
ActiveSupport::Dependencies.clear

unload_message = "#{these} autoloaded #{constants} #{have} been unloaded."
else
unload_message = "`config.autoloader` is set to `#{config.autoloader}`. #{these} autoloaded #{constants} would have been unloaded if `config.autoloader` had been set to `:zeitwerk`."
end

ActiveSupport::Deprecation.warn(<<~WARNING)
Initialization autoloaded the #{constants} #{enum}.
Expand All @@ -52,7 +58,7 @@ module Finisher
initialization does not run again. So, if you reload #{example}, for example,
the expected changes won't be reflected in that stale #{example_klass} object.

#{these} autoloaded #{constants} #{have} been unloaded.
#{unload_message}

Please, check the "Autoloading and Reloading Constants" guide for solutions.
WARNING
Expand Down