sorbet-runtime 0.5.6277 → 0.5.6281

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: 22707230a23f48bfd62933d0a85920876e2ac38dc8b78c3306d205c8247e0c69
4
- data.tar.gz: e5c3afa7f8dc8eb5dab01edd0086062c0597306ddd5a985b4ddde0da5e9c5a9f
3
+ metadata.gz: 63bab72b83acd7259f3cccecbde20697b8f3d9624b7b6f2375794d23160c1be3
4
+ data.tar.gz: 9d07bd57a49cf42ce854cec74195f388a715507ac775fcd51f014a903a095714
5
5
  SHA512:
6
- metadata.gz: cd1d3b58bf2c258db84c6abffedd63c406bc4145f9484265a7ad988eb73dab15f0fb3186b880461ce810eb5cad494fd07fcca381694fc13d9826bd9711bdbd1b
7
- data.tar.gz: d7ea87fcf45c0995cf0d14551ab8ad30441d6fcd43375f27e53b529b129180dd5c9a34b31db56e4994eaa8ce762fb25148fb24540f1b6a280df02e91ab77d6ee
6
+ metadata.gz: b5ea92da25e0cc43609c81c913cca8f9be94552b8a57f3fef35391271c8557c757e934ac20bf22ae02c57463bbf6e5db0f3bd156cc1ec72183731ed8a9bc23b5
7
+ data.tar.gz: 9e06a6cc349624f8f0353c3a3ee607a32e7d49b48ff73aaa4378724944eeb7209b0e9420f7371b8b4e674e58fe4ce386217ebc4bfd8b3e11117c8c53314d6a34
@@ -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.6277
4
+ version: 0.5.6281
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-06 00:00:00.000000000 Z
11
+ date: 2021-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest