sorbet-runtime 0.5.6262 → 0.5.6284

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 120b55b23f68b8c30bdbcf57ee7321dc146fd332cc68f61779dc28ab66994e59
4
- data.tar.gz: d2521efb553ac1495ab93bdf837365026f68a3281886572e8f9c6e316d8404a4
3
+ metadata.gz: 6fcd72ce0fcc51b13ea9e667d240dd86696b76a588a5d1753722f8a22cc9ded2
4
+ data.tar.gz: 23648c896fd5c43550213fb21e357530358984f43e731bff602f5b6f2347c951
5
5
  SHA512:
6
- metadata.gz: 66c4b082d3fa1d150ca1cc59bd8e5ead17ff5661c53f059630085a37b7df0d880b4305183d352495f0a2fb8dc646361c457f134083ea466f320f4c2e2aabbaea
7
- data.tar.gz: 4b1765c13fb06a849456d5a848fac0623481dd158191a323deb69d19190accfc2189896d2b5a56d57ce9c42ac3cdb5f64c374931f715104ffa0ba400ebbc737e
6
+ metadata.gz: 22e34e2e281592145bf0e077dcc256e74927f4bd246793c95d83d07bedd0a6f998adf455ede9a1cd5521eda3accad98f44d2d59af75a5fdd8fa85f2bf3e94a3d
7
+ data.tar.gz: 82a0807de86e66e8c7edbfde19f4ec0a843c55a7e91ea6818cf46817d16051d109a2a56b970a892224bd774880ed615666d0c3b8354811672e09fa391b5b6dcf
@@ -34,7 +34,7 @@ module T::Private::Methods
34
34
 
35
35
  if T::Private::DeclState.current.active_declaration
36
36
  T::Private::DeclState.current.reset!
37
- raise "You called sig twice without declaring a method inbetween"
37
+ raise "You called sig twice without declaring a method in between"
38
38
  end
39
39
 
40
40
  if !arg.nil? && arg != :final
@@ -112,10 +112,32 @@ module T::Private::Methods
112
112
  ancestor.private_method_defined?(method_name) ||
113
113
  ancestor.protected_method_defined?(method_name)) &&
114
114
  final_method?(method_owner_and_name_to_key(ancestor, method_name))
115
- raise(
116
- "The method `#{method_name}` on #{ancestor} was declared as final and cannot be " +
117
- (target == ancestor ? "redefined" : "overridden in #{target}")
118
- )
115
+ definition_file, definition_line = T::Private::Methods.signature_for_method(ancestor.instance_method(method_name)).method.source_location
116
+ is_redefined = target == ancestor
117
+ caller_loc = caller_locations&.find {|l| !l.to_s.match?(%r{sorbet-runtime[^/]*/lib/}) }
118
+ extra_info = "\n"
119
+ if caller_loc
120
+ extra_info = (is_redefined ? "Redefined" : "Overridden") + " here: #{caller_loc.path}:#{caller_loc.lineno}\n"
121
+ end
122
+
123
+ error_message = "The method `#{method_name}` on #{ancestor} was declared as final and cannot be " +
124
+ (is_redefined ? "redefined" : "overridden in #{target}")
125
+ pretty_message = "#{error_message}\n" \
126
+ "Made final here: #{definition_file}:#{definition_line}\n" \
127
+ "#{extra_info}"
128
+
129
+ begin
130
+ raise pretty_message
131
+ rescue => e
132
+ # sig_validation_error_handler raises by default; on the off chance that
133
+ # it doesn't raise, we need to ensure that the rest of signature building
134
+ # sees a consistent state. This sig failed to validate, so we should get
135
+ # rid of it. If we don't do this, errors of the form "You called sig
136
+ # twice without declaring a method in between" will non-deterministically
137
+ # crop up in tests.
138
+ T::Private::DeclState.current.reset!
139
+ T::Configuration.sig_validation_error_handler(e, {})
140
+ end
119
141
  end
120
142
  end
121
143
  end
@@ -152,6 +174,9 @@ module T::Private::Methods
152
174
  end
153
175
  _check_final_ancestors(mod, mod.ancestors, [method_name])
154
176
 
177
+ # We need to fetch the active declaration again, as _check_final_ancestors
178
+ # may have reset it (see the comment in that method for details).
179
+ current_declaration = T::Private::DeclState.current.active_declaration
155
180
  if current_declaration.nil?
156
181
  return
157
182
  end
@@ -449,6 +474,12 @@ module T::Private::Methods
449
474
  return
450
475
  end
451
476
 
477
+ # See https://github.com/sorbet/sorbet/pull/3964 for an explanation of why this
478
+ # check (which theoretically should not be needed) is actually needed.
479
+ if !mod.is_a?(Module)
480
+ return
481
+ end
482
+
452
483
  if mod.singleton_class?
453
484
  mod.include(SingletonMethodHooks)
454
485
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorbet-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6262
4
+ version: 0.5.6284
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-02 00:00:00.000000000 Z
11
+ date: 2021-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest