sorbet-runtime 0.5.5937 → 0.5.5947

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: 5454eb320d7222eb9238c489de4b21bc5ecc39b2b86a6ff6c750f5e22a571b16
4
- data.tar.gz: d75c5a1bfcf183e70bfe15129f08a66ecc3edf7faca88647e007ff91581c940c
3
+ metadata.gz: 79d9e2b12595ff5d144f7f07113c45abc79ea24209e513fd1da66ca37797c681
4
+ data.tar.gz: 70483aa080d2f7bd0b137cf202cc9991db8d29230b6ecef2422caf87689210a5
5
5
  SHA512:
6
- metadata.gz: d48a6f79d0e445ee25e57e031cc3c24ff39e7b3a85d0d2930226d2f5090d66a006fec347425fd528fda5c9323fe0d7384340b131d06eca45a3914de19a2b8f52
7
- data.tar.gz: e29d640cc39e122b5cf2ee5f9ccbb6266db58e148d72e9d09310fd70846756b159cb741393e6444527e2eb4987fca149acef2a040618644d5450f6cbb8246b41
6
+ metadata.gz: b73c7d090d6f14aecea326821550f5082402009e794836758d6263f36068a4f8593ada7dd57b00474a078d1c03fdd56337b913ef56a2cf4294cca7377cc1366c
7
+ data.tar.gz: 703295945449b6d30184a9f4192ba6768cb74486c071dcd4a839ab5fdd9cfe0279b72f12b59971f4d4214690710f94d450f6e7a483e785dd5ecfc4568fe36517
@@ -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.5937
4
+ version: 0.5.5947
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-07 00:00:00.000000000 Z
11
+ date: 2020-10-15 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: []