sorbet-runtime 0.5.12210 → 0.5.12216
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d32b12d9ff3678030a22fa53f5543c41c44bd2c937da836e68b509a2e78e8aa
|
4
|
+
data.tar.gz: 696ca2d859d39882a9c25482c8f38272e915c81d5409e1442a14a46535ce31f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccc9012710e93b58447df837349c397a5b2ef7a0388d31f7d15c4384ac13b4d063c4f180e378544236194d394a972f23fbd2652f6bec20bdfb6347a125b2edf1
|
7
|
+
data.tar.gz: e678c24ccf583366c8170b91c7bd6520ac8ce354c95ac927b5b706fc25c6e5253375056256c69419351464e995588e3c71dc46a94fbcfb3b1e0b8e216858c498
|
@@ -589,6 +589,22 @@ module T::Private::Methods
|
|
589
589
|
mod.extend(SingletonMethodHooks)
|
590
590
|
end
|
591
591
|
|
592
|
+
# `name` must be an instance method (for class methods, pass in mod.singleton_class)
|
593
|
+
def self.visibility_method_name(mod, name)
|
594
|
+
if mod.public_method_defined?(name)
|
595
|
+
:public
|
596
|
+
elsif mod.protected_method_defined?(name)
|
597
|
+
:protected
|
598
|
+
elsif mod.private_method_defined?(name)
|
599
|
+
:private
|
600
|
+
else
|
601
|
+
# Raises a NameError formatted like the Ruby VM would (the exact text formatting
|
602
|
+
# of these errors changed across Ruby VM versions, in ways that would sometimes
|
603
|
+
# cause tests to fail if they were dependent on hard coding errors).
|
604
|
+
mod.method(name)
|
605
|
+
end
|
606
|
+
end
|
607
|
+
|
592
608
|
# use this directly if you don't want/need to box up the method into an object to pass to method_to_key.
|
593
609
|
private_class_method def self.method_owner_and_name_to_key(owner, name)
|
594
610
|
"#{owner.object_id}##{name}"
|
@@ -12,7 +12,7 @@ module T::Private::Methods::CallValidation
|
|
12
12
|
# @param method_sig [T::Private::Methods::Signature]
|
13
13
|
# @return [UnboundMethod] the new wrapper method (or the original one if we didn't wrap it)
|
14
14
|
def self.wrap_method_if_needed(mod, method_sig, original_method)
|
15
|
-
original_visibility = visibility_method_name(mod, method_sig.method_name)
|
15
|
+
original_visibility = T::Private::Methods.visibility_method_name(mod, method_sig.method_name)
|
16
16
|
if method_sig.mode == T::Private::Methods::Modes.abstract
|
17
17
|
create_abstract_wrapper(mod, method_sig, original_method, original_visibility)
|
18
18
|
# Do nothing in this case; this method was not wrapped in _on_method_added.
|
@@ -330,19 +330,6 @@ module T::Private::Methods::CallValidation
|
|
330
330
|
location: caller_loc
|
331
331
|
)
|
332
332
|
end
|
333
|
-
|
334
|
-
# `name` must be an instance method (for class methods, pass in mod.singleton_class)
|
335
|
-
private_class_method def self.visibility_method_name(mod, name)
|
336
|
-
if mod.public_method_defined?(name)
|
337
|
-
:public
|
338
|
-
elsif mod.protected_method_defined?(name)
|
339
|
-
:protected
|
340
|
-
elsif mod.private_method_defined?(name)
|
341
|
-
:private
|
342
|
-
else
|
343
|
-
mod.method(name) # Raises
|
344
|
-
end
|
345
|
-
end
|
346
333
|
end
|
347
334
|
|
348
335
|
if T::Configuration::AT_LEAST_RUBY_2_7
|
@@ -89,6 +89,7 @@ module T::Private::Methods::SignatureValidation
|
|
89
89
|
validate_override_mode(signature, super_signature)
|
90
90
|
validate_override_shape(signature, super_signature)
|
91
91
|
validate_override_types(signature, super_signature)
|
92
|
+
validate_override_visibility(signature, super_signature)
|
92
93
|
end
|
93
94
|
else
|
94
95
|
validate_non_override_mode(signature)
|
@@ -276,6 +277,38 @@ module T::Private::Methods::SignatureValidation
|
|
276
277
|
end
|
277
278
|
end
|
278
279
|
|
280
|
+
def self.validate_override_visibility(signature, super_signature)
|
281
|
+
return if super_signature.mode == Modes.untyped
|
282
|
+
# This departs from the behavior of other `validate_override_whatever` functions in that it
|
283
|
+
# only comes into effect when the child signature explicitly says the word `override`. This was
|
284
|
+
# done because the primary method for silencing these errors (`allow_incompatible: :visibility`)
|
285
|
+
# requires an `override` node to attach to. Once we have static override checking for implicitly
|
286
|
+
# overridden methods, we can remove this.
|
287
|
+
return unless [Modes.override, Modes.overridable_override].include?(signature.mode)
|
288
|
+
return if [:visibility, true].include?(signature.override_allow_incompatible)
|
289
|
+
method = signature.method
|
290
|
+
super_method = super_signature.method
|
291
|
+
mode_noun = super_signature.mode == Modes.abstract ? 'implementation' : 'override'
|
292
|
+
vis = method_visibility(method)
|
293
|
+
super_vis = method_visibility(super_method)
|
294
|
+
|
295
|
+
if visibility_strength(vis) > visibility_strength(super_vis)
|
296
|
+
raise "Incompatible visibility for #{mode_noun} of method #{method.name}\n" \
|
297
|
+
"* Base: #{super_vis} (in #{method_loc_str(super_method)})\n" \
|
298
|
+
"* #{mode_noun.capitalize}: #{vis} (in #{method_loc_str(method)})\n" \
|
299
|
+
"(The override must be at least as permissive as the supermethod)" \
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
private_class_method def self.method_visibility(method)
|
304
|
+
T::Private::Methods.visibility_method_name(method.owner, method.name)
|
305
|
+
end
|
306
|
+
|
307
|
+
# Higher = more restrictive.
|
308
|
+
private_class_method def self.visibility_strength(vis)
|
309
|
+
%i[public protected private].find_index(vis)
|
310
|
+
end
|
311
|
+
|
279
312
|
private_class_method def self.base_override_loc_str(signature, super_signature)
|
280
313
|
mode_noun = super_signature.mode == Modes.abstract ? 'Implementation' : 'Override'
|
281
314
|
"\n * Base definition: in #{method_loc_str(super_signature.method)}" \
|
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.12216
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|