diff options
author | Edouard CHIN <edouard.chin@shopify.com> | 2019-07-22 15:27:17 +0200 |
---|---|---|
committer | Edouard CHIN <edouard.chin@shopify.com> | 2019-07-22 15:27:17 +0200 |
commit | 426d2f2502780635ca56c09a5aeb0829dd9212ee (patch) | |
tree | 4d913d38a0ac553d0c1974f378d8f50e593f8e53 /railties/lib/rails | |
parent | 9ad806887096be1f60019a6b301a4c84aa1d8e65 (diff) | |
download | rails-426d2f2502780635ca56c09a5aeb0829dd9212ee.tar.gz rails-426d2f2502780635ca56c09a5aeb0829dd9212ee.tar.bz2 rails-426d2f2502780635ca56c09a5aeb0829dd9212ee.zip |
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"
```
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/source_annotation_extractor.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index 9ce22b96a6..77a99036ec 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -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") |