sorbet-runtime 0.5.11262 → 0.5.11264

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: 1692cdd07ecb588ec487fe91f7e9ef6f0cc080f1ee7d93017cf85186fa4b4542
4
- data.tar.gz: 0bb03f41417caa78e9f7d440b35f1d48e8fa51b6dff7bf2c9458695fdcbc40de
3
+ metadata.gz: 62274143243d0c8273c8ffb6d77212b3e048b809d02e754456be2ccc197c31a8
4
+ data.tar.gz: 709863c45b47abf5dddc2a1978bf1af84db62aa0873edc200f701b907939b24c
5
5
  SHA512:
6
- metadata.gz: 2ba0f3bd9800064629273762dba847d9c72d7a7c02e4726bcf2612cd3c07a693e14a62b82af279b591540e648d612fce72e4c9d9721a9f4ac161f233906d5396
7
- data.tar.gz: 323d8c22bf830f3b8c5125c0ed2b96345e359ca5e493ec3291c1f9acbc05101aa9687eea7d30952aa7b9cab3708664ecb05957927bc9715fec088349fbf4a6bf
6
+ metadata.gz: 56b94b8d19773a6bfb5ba935273b51c4da92f156cbe1d598a60c634bc8b78b37625cdb4264561a55e6fa89300b1405f8b85c93c412127f30851f3966f3e97214
7
+ data.tar.gz: a29047c353c376c7aa3e3f7de4024332bda5a0a08994831aa420187419a0df1a86235de09a80c1f7aaaa66928ac0fe67430ed3140d0dacaa59b68a4e7ba7ace5
@@ -19,6 +19,7 @@ module T::Private::Types; end
19
19
  require_relative 'types/configuration'
20
20
  require_relative 'types/_types'
21
21
  require_relative 'types/private/decl_state'
22
+ require_relative 'types/private/caller_utils'
22
23
  require_relative 'types/private/class_utils'
23
24
  require_relative 'types/private/runtime_levels'
24
25
  require_relative 'types/private/methods/_methods'
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ # typed: false
3
+
4
+ module T::Private::CallerUtils
5
+ if Thread.respond_to?(:each_caller_location) # RUBY_VERSION >= "3.2"
6
+ def self.find_caller
7
+ Thread.each_caller_location do |loc|
8
+ next if loc.path&.start_with?("<internal:")
9
+
10
+ return loc if yield(loc)
11
+ end
12
+ nil
13
+ end
14
+ else
15
+ def self.find_caller
16
+ caller_locations(2).find do |loc|
17
+ !loc.path&.start_with?("<internal:") && yield(loc)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -168,7 +168,7 @@ module T::Private::Methods
168
168
 
169
169
  definition_file, definition_line = T::Private::Methods.signature_for_method(ancestor.instance_method(method_name)).method.source_location
170
170
  is_redefined = target == ancestor
171
- caller_loc = caller_locations.find {|l| !l.to_s.start_with?(SORBET_RUNTIME_LIB_PATH)}
171
+ caller_loc = T::Private::CallerUtils.find_caller {|loc| !loc.path.to_s.start_with?(SORBET_RUNTIME_LIB_PATH)}
172
172
  extra_info = "\n"
173
173
  if caller_loc
174
174
  extra_info = (is_redefined ? "Redefined" : "Overridden") + " here: #{caller_loc.path}:#{caller_loc.lineno}\n"
@@ -5,8 +5,8 @@ module T::Private::Sealed
5
5
  module NoInherit
6
6
  def inherited(child)
7
7
  super
8
- this_line = Kernel.caller.find {|line| !line.match(/in `inherited'$/)}
9
- T::Private::Sealed.validate_inheritance(this_line, self, child, 'inherited')
8
+ caller_loc = T::Private::CallerUtils.find_caller {|loc| !loc.to_s.match(/in `inherited'$/)}
9
+ T::Private::Sealed.validate_inheritance(caller_loc&.to_s, self, child, 'inherited')
10
10
  @sorbet_sealed_module_all_subclasses << child
11
11
  end
12
12
 
@@ -22,15 +22,15 @@ module T::Private::Sealed
22
22
  module NoIncludeExtend
23
23
  def included(child)
24
24
  super
25
- this_line = Kernel.caller.find {|line| !line.match(/in `included'$/)}
26
- T::Private::Sealed.validate_inheritance(this_line, self, child, 'included')
25
+ caller_loc = T::Private::CallerUtils.find_caller {|loc| !loc.to_s.match(/in `included'$/)}
26
+ T::Private::Sealed.validate_inheritance(caller_loc&.to_s, self, child, 'included')
27
27
  @sorbet_sealed_module_all_subclasses << child
28
28
  end
29
29
 
30
30
  def extended(child)
31
31
  super
32
- this_line = Kernel.caller.find {|line| !line.match(/in `extended'$/)}
33
- T::Private::Sealed.validate_inheritance(this_line, self, child, 'extended')
32
+ caller_loc = T::Private::CallerUtils.find_caller {|loc| !loc.to_s.match(/in `extended'$/)}
33
+ T::Private::Sealed.validate_inheritance(caller_loc&.to_s, self, child, 'extended')
34
34
  @sorbet_sealed_module_all_subclasses << child
35
35
  end
36
36
 
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.11262
4
+ version: 0.5.11264
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-17 00:00:00.000000000 Z
11
+ date: 2024-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -156,6 +156,7 @@ files:
156
156
  - lib/types/private/abstract/declare.rb
157
157
  - lib/types/private/abstract/hooks.rb
158
158
  - lib/types/private/abstract/validate.rb
159
+ - lib/types/private/caller_utils.rb
159
160
  - lib/types/private/casts.rb
160
161
  - lib/types/private/class_utils.rb
161
162
  - lib/types/private/compiler.rb