sorbet-runtime 0.5.6274 → 0.5.6287

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: 78301761b82f74a342afe20b3d6eb1478d8b15aa26a1470178d57cf551df23f3
4
- data.tar.gz: eceddf50388a33faaba018af4a38d272054f5887639a9c9ff3b4ac78ce1d0462
3
+ metadata.gz: 6a5a97f9ecd136a9941336c8871bc026409d0f3a30a66fd5dffe302fe33ed771
4
+ data.tar.gz: c89dff5bf909656c90b0e2073efcd539116f4fafe301a18a7b2e0ebb9baa2af8
5
5
  SHA512:
6
- metadata.gz: 374a9edfce3ded25ae09cbdcbfd8576482644386e93b4e4c591ac5f8a5e19b5fd05efca165fdffd46b5de5e5de09fdb3bf5634d71f0cbf2797be61f4722be06c
7
- data.tar.gz: aeb300bea46d8a199405befc3d41b1f3ec7b4286d671b8c645a24d1c0a1b3c4a4499e142577eb7dcb17171cad39ad42c567e4b52fb3fc5d2e59933e9156cec64
6
+ metadata.gz: 508ec9ac79c59a78eb37c15607a38c942dc3c0aa626911c0f53d4f410be3775a140c8abc1ff5fb1a548e35d01517243b5037e55a4d1483104ca08013c963c52e
7
+ data.tar.gz: b9c04799ab15c06ec2b8026ff90969d4f9c229a50cccac7f86f63221704c965b562c3efcdecac36480cfd008c0c422e522a2d53652b848d655c58e59b893fb4b
@@ -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.6274
4
+ version: 0.5.6287
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-04 00:00:00.000000000 Z
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest