sorbet-runtime 0.5.5933 → 0.5.5943
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/enum.rb +11 -0
- data/lib/types/private/methods/_methods.rb +25 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3b8f8bd01297dd12cefbc3650ac4381c14514644a98716a5dc8f3d68117ee6a
|
4
|
+
data.tar.gz: 501998cb4313a9452df0018b7bfd119550aac6c89701adf2bda6cf11de7cd2e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b55f51a5bdb75aa3ff62f2d589351775b8843156a70c2decade88ed5585ff1022efb60610e10ad637859e74eedc6e65bc564a18a1f94fd3ba3b4f50f214c61b6
|
7
|
+
data.tar.gz: 93d23d07204fb9354ed65cf533ab3ba860f7361130fead01dd935aebe967a7f76794c8e1e44c1c595a38954cf848bf992bc8daefb25cd5b68c4a7857a85912f1
|
data/lib/types/enum.rb
CHANGED
@@ -57,6 +57,17 @@ class T::Enum
|
|
57
57
|
@values
|
58
58
|
end
|
59
59
|
|
60
|
+
# This exists for compatibility with the interface of `Hash` & mostly to support
|
61
|
+
# the HashEachMethods Rubocop.
|
62
|
+
sig {params(blk: T.nilable(T.proc.params(arg0: T.attached_class).void)).returns(T.any(T::Enumerator[T.attached_class], T::Array[T.attached_class]))}
|
63
|
+
def self.each_value(&blk)
|
64
|
+
if blk
|
65
|
+
values.each(&blk)
|
66
|
+
else
|
67
|
+
values.each
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
60
71
|
# Convert from serialized value to enum instance
|
61
72
|
#
|
62
73
|
# Note: It would have been nice to make this method final before people started overriding it.
|
@@ -311,8 +311,12 @@ module T::Private::Methods
|
|
311
311
|
|
312
312
|
def self.build_sig(hook_mod, method_name, original_method, current_declaration, loc)
|
313
313
|
begin
|
314
|
-
# We allow `sig` in the current module's context (normal case) and
|
315
|
-
if hook_mod != current_declaration.mod &&
|
314
|
+
# We allow `sig` in the current module's context (normal case) and
|
315
|
+
if hook_mod != current_declaration.mod &&
|
316
|
+
# inside `class << self`, and
|
317
|
+
hook_mod.singleton_class != current_declaration.mod &&
|
318
|
+
# on `self` at the top level of a file
|
319
|
+
current_declaration.mod != TOP_SELF
|
316
320
|
raise "A method (#{method_name}) is being added on a different class/module (#{hook_mod}) than the " \
|
317
321
|
"last call to `sig` (#{current_declaration.mod}). Make sure each call " \
|
318
322
|
"to `sig` is immediately followed by a method definition on the same " \
|
@@ -462,6 +466,20 @@ module T::Private::Methods
|
|
462
466
|
return if @installed_hooks.include?(mod)
|
463
467
|
@installed_hooks << mod
|
464
468
|
|
469
|
+
if mod == TOP_SELF
|
470
|
+
# self at the top-level of a file is weirdly special in Ruby
|
471
|
+
# The Ruby VM on startup creates an `Object.new` and stashes it.
|
472
|
+
# Unlike when we're using sig inside a module, `self` is actually a
|
473
|
+
# normal object, not an instance of Module.
|
474
|
+
#
|
475
|
+
# Thus we can't ask things like mod.singleton_class? (since that's
|
476
|
+
# defined only on Module, not on Object) and even if we could, the places
|
477
|
+
# where we need to install the hooks are special.
|
478
|
+
mod.extend(SingletonMethodHooks) # def self.foo; end (at top level)
|
479
|
+
Object.extend(MethodHooks) # def foo; end (at top level)
|
480
|
+
return
|
481
|
+
end
|
482
|
+
|
465
483
|
if mod.singleton_class?
|
466
484
|
mod.include(SingletonMethodHooks)
|
467
485
|
else
|
@@ -485,3 +503,8 @@ module T::Private::Methods
|
|
485
503
|
obj.instance_method(name)
|
486
504
|
end
|
487
505
|
end
|
506
|
+
|
507
|
+
# This has to be here, and can't be nested inside `T::Private::Methods`,
|
508
|
+
# because the value of `self` depends on lexical (nesting) scope, and we
|
509
|
+
# specifically need a reference to the file-level self, i.e. `main:Object`
|
510
|
+
T::Private::Methods::TOP_SELF = self
|
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.5943
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 2.7.1
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: subprocess
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.5.3
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.5.3
|
139
153
|
description: Sorbet's runtime type checking component
|
140
154
|
email:
|
141
155
|
executables: []
|