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 +4 -4
- data/lib/types/private/methods/_methods.rb +36 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a5a97f9ecd136a9941336c8871bc026409d0f3a30a66fd5dffe302fe33ed771
|
4
|
+
data.tar.gz: c89dff5bf909656c90b0e2073efcd539116f4fafe301a18a7b2e0ebb9baa2af8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
116
|
-
|
117
|
-
|
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.
|
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-
|
11
|
+
date: 2021-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|