1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Move the deprecation call after the new class has been defined:

- If we create the deprecation before the new class is defined this
  creates an issue in case you use a `TracePoint`. The
  `Tracepoint#return_value` will try to get the new class constant
  resulting in a uninitialized constant Rails::SourceAnnotationExtractor

  The problem can be reproduced like this:

  ```ruby
  @defined = Set.new

  ANONYMOUS_CLASS_DEFINITION_TRACEPOINT = TracePoint.new(:c_return) do |tp|
    next unless @defined.add?(tp.return_value)
  end

  ANONYMOUS_CLASS_DEFINITION_TRACEPOINT.enable

  require 'rails'
  require "rails/source_annotation_extractor"
  ```
This commit is contained in:
Edouard CHIN 2019-07-22 15:27:17 +02:00
parent 9ad8068870
commit 426d2f2502

View file

@ -2,11 +2,6 @@
require "active_support/deprecation"
# Remove this deprecated class in the next minor version
#:nodoc:
SourceAnnotationExtractor = ActiveSupport::Deprecation::DeprecatedConstantProxy.
new("SourceAnnotationExtractor", "Rails::SourceAnnotationExtractor")
module Rails
# Implements the logic behind <tt>Rails::Command::NotesCommand</tt>. See <tt>rails notes --help</tt> for usage information.
#
@ -160,3 +155,8 @@ module Rails
end
end
end
# Remove this deprecated class in the next minor version
#:nodoc:
SourceAnnotationExtractor = ActiveSupport::Deprecation::DeprecatedConstantProxy.
new("SourceAnnotationExtractor", "Rails::SourceAnnotationExtractor")