sorbet-runtime 0.5.5935 → 0.5.5944

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: 65574adf5815ae5f4d9b1b84bc57b3d5c03a20158899092080d84046c272d3f1
4
- data.tar.gz: 9d9a18876e1ff249786972959ee4dab6a3e5c3eb638c7d8686315429d0b60c38
3
+ metadata.gz: '080a7532b091399cd88d173ec4a413d7256f9c473f7f2ef4c06ce66e2d00fc48'
4
+ data.tar.gz: 872bcea95c7823ba9ea28857cd30929ee0e865c3ca86859f6f220dd324c44f05
5
5
  SHA512:
6
- metadata.gz: 4b955633f3066864c897bb67ef74bc27fc7eef5b85e1af5447c50ca522fd4f4d7e01a7f7b3f872768ff0707a59af97f1fd396d81fc3a72cc82abc24e512309d4
7
- data.tar.gz: f03bb89469daf5e53d89343eb05274427582f39620f0ae90e24a50264a314caeb13e2ff1de1584772875ab6860186fe8990b007df8f562a28f6b1984181068cd
6
+ metadata.gz: 5a0b84c94036fa34184daba05100d58de4a476a24858f0cf6b9d8c5eeb620ecb7c062ae5daf6ec81f4c57bd02f119dc19e058d59d0fd78d14674c255d8c97495
7
+ data.tar.gz: 58f859ae9162ab75b0005a70b8303a0d1ebe2b0acb111cb52395604b243e6a7d6c845199fa9cbf3703de3c72351016dde23669f512a6ec853db41f2723ed8a3c
@@ -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 inside `class << self`
315
- if hook_mod != current_declaration.mod && hook_mod.singleton_class != 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.5935
4
+ version: 0.5.5944
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-06 00:00:00.000000000 Z
11
+ date: 2020-10-14 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: []