sorbet-runtime 0.6.13610 → 0.6.13615

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: 719e6f0baea884095af3333af4c5d1cada39c03ee5bb4c23bb05ee00a0171406
4
- data.tar.gz: 7be4e804bb6055583e367662baacff6217a5f0806b0d069e4dfef05d0837431f
3
+ metadata.gz: 83afd87671f904e0e627730dbefaa1f70173159106c48dc129e684627236bb6d
4
+ data.tar.gz: 3b0f25dc28f65cd39e560ebdc0b625eda8651030693f9a185fd86557b2363628
5
5
  SHA512:
6
- metadata.gz: 59653a49e7d4db948e953ae30976656a99ee844e0b12006599f977a171f7c9f951d8707d72f8a80529f88a96c76004d06606fa130c75b646ca06753067a68e9a
7
- data.tar.gz: e30c5fc33877556d12997f7b2484a4abdeb4fcb4224792c6ba8e3c8310850a41e913c6f761cbc538ad568a792f8c51eae28a4e50f7457ce6464487ba7d23b140
6
+ metadata.gz: 8bc6a890b37dda640b8c830f3385319a1bb4ef01239e0bec56138240117e0e5f4f14aa64806027f4918c2ee60d31521c876ce072d7f853d1ff77892f2336ecc3
7
+ data.tar.gz: 1befcd02c403f3d20652f7637d365085e296e00ff178a496a72e700b943aa5ff8a744d80597fc02d6a6528a25114f86cf2ab289edd80987ef3d9a4ce7abe901a
@@ -616,6 +616,17 @@ module T::Private::Methods
616
616
  @signatures_by_method[method_to_key(maybe_wrapped_method)] = signature
617
617
  end
618
618
 
619
+ # This method tells whether `drop_unchecked_sigs!` can free `signature`.
620
+ # It returns true for a signature whose runtime checks never run.
621
+ # It returns false for an `abstract` signature, because `T::AbstractUtils`
622
+ # reads that signature after load time.
623
+ private_class_method def self.drop_sig?(signature)
624
+ return false if signature.mode == Modes.abstract
625
+
626
+ signature.check_level == :never ||
627
+ (signature.check_level == :tests && !T::Private::RuntimeLevels.check_tests?)
628
+ end
629
+
619
630
  # Only public because it needs to get called inside the first-call wrapper closure.
620
631
  def self._sig_block_is_current?(key, sig_block)
621
632
  @sig_wrappers[key].equal?(sig_block)
@@ -699,6 +710,10 @@ module T::Private::Methods
699
710
  @signatures_by_method.values.select { |sig| sig.check_level == :tests }
700
711
  end
701
712
 
713
+ def self.drop_unchecked_sigs!
714
+ @signatures_by_method.delete_if { |_key, sig| drop_sig?(sig) }
715
+ end
716
+
702
717
  # the module target is adding the methods from the module source to itself. we need to check that for all instance
703
718
  # methods M on source, M is not defined on any of target's ancestors.
704
719
  def self._hook_impl(target, source)
data/lib/types/utils.rb CHANGED
@@ -191,6 +191,18 @@ module T::Utils
191
191
  nil
192
192
  end
193
193
 
194
+ # Free the signatures whose runtime checks never run: the `.checked(:never)`
195
+ # sigs, plus the `.checked(:tests)` sigs outside of a test environment. After
196
+ # this call, `T::Utils.signature_for_method` returns `nil` for those methods,
197
+ # and nothing can rebuild them.
198
+ #
199
+ # Call this once after eagerly preloading a codebase (e.g. at service startup)
200
+ # and after `run_all_sig_blocks`, to trade that introspection for memory.
201
+ def self.drop_unchecked_sigs!
202
+ T::Private::Methods.drop_unchecked_sigs!
203
+ nil
204
+ end
205
+
194
206
  def self.lift_enum(enum)
195
207
  unless enum.is_a?(T::Types::Enum)
196
208
  raise ArgumentError.new("#{enum.inspect} is not a T.deprecated_enum")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sorbet-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.13610
4
+ version: 0.6.13615
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe