sorbet-runtime 0.5.5930 → 0.5.5942

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: ef79af0190c9fb03be7b4607daff1d42971c53ec1d7bdebd1e28d63782153ee6
4
- data.tar.gz: 85a6da9fb36a8d384eb09632ab7ae677fd71a63ac42a4129300f963855cd0432
3
+ metadata.gz: 4838c21772de1169f412a971cfe59e49fc482bda8de9fb70920fd4bcab5e654f
4
+ data.tar.gz: 5e27052a663a22e70e5aa3afee7563f43be650946ec4673df2fb246535a28bb6
5
5
  SHA512:
6
- metadata.gz: 118a7c5f6de98fa8e03aa36da7ba2d9c2e33b46aadd392e738f704fbc3b1f79d88d9399ef2af16db57aa5a8b91c66f23907d3748c7a675471b9e43175a8da415
7
- data.tar.gz: 88899f7961e2769853dde0246667b36ad167afc54b68bce2d962ac63975c915fb7c90947a85b842fe63f2e6f6e4a3c4f152adf64ae97437cdb9c6607d35ae766
6
+ metadata.gz: 87abc9d8a3a9a753d96577a52856c4e04b2dfaaefb1908e696d9882c04a593ab6cdd9112660afa887d57fd3df62dbf99fded5a697b176ac1c043011b3fd43db1
7
+ data.tar.gz: 6f10e93404924fbf7752eb01786e717d585472df7b2c77aaead247df1d170998ff46b8d3d8e5b51bad6773fc950280ebc3c922651078a249fef2d29929d75aef
@@ -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.
@@ -4,8 +4,11 @@
4
4
  module T::NonForcingConstants
5
5
  # NOTE: This method is documented on the RBI in Sorbet's payload, so that it
6
6
  # shows up in the hover/completion documentation via LSP.
7
- T::Sig::WithoutRuntime.sig {params(val: BasicObject, klass: String).returns(T::Boolean)}
8
- def self.non_forcing_is_a?(val, klass)
7
+ T::Sig::WithoutRuntime.sig {params(val: BasicObject, klass: String, package: T.nilable(String)).returns(T::Boolean)}
8
+ def self.non_forcing_is_a?(val, klass, package: nil)
9
+ # TODO(gdritter): once we have a runtime implementation of
10
+ # packages, we'll need to actually handle the `package` argument
11
+ # here.
9
12
  method_name = "T::NonForcingConstants.non_forcing_is_a?"
10
13
  if klass.empty?
11
14
  raise ArgumentError.new("The string given to `#{method_name}` must not be empty")
@@ -18,7 +21,10 @@ module T::NonForcingConstants
18
21
  parts.each do |part|
19
22
  if current_klass.nil?
20
23
  # First iteration
21
- if part != ""
24
+ if part != "" && package.nil?
25
+ # if we've supplied a package, we're probably running in
26
+ # package mode, which means absolute references are
27
+ # meaningless
22
28
  raise ArgumentError.new("The string given to `#{method_name}` must be an absolute constant reference that starts with `::`")
23
29
  end
24
30
 
@@ -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.5930
4
+ version: 0.5.5942
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-01 00:00:00.000000000 Z
11
+ date: 2020-10-09 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: []