sorbet-runtime 0.5.9242 → 0.5.9265
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 +4 -4
- data/lib/sorbet-runtime.rb +0 -2
- data/lib/types/configuration.rb +12 -12
- data/lib/types/private/methods/_methods.rb +7 -6
- data/lib/types/private/sealed.rb +11 -3
- data/lib/types/props/decorator.rb +1 -1
- data/lib/types/types/enum.rb +0 -2
- data/lib/types/types/simple.rb +2 -2
- data/lib/types/types/typed_set.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b52db74c71b24507f2db2379bc55dea9c8ec1d58b398125b24fbc0f7c58bb32
|
4
|
+
data.tar.gz: 66b9b653df351958e03e5a79cba712667e56aa301ad4d491ecc7a1d967cc21ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edd169f69038e211dc74a436a2e018a8432c6bb871b55c2e2f94140df73a28d27c6f40e32855e05855cf9d23f42c36b025a8381339688c87a550d2fffe698fe1
|
7
|
+
data.tar.gz: 54b5a6b1cc0ce42923035612b912011ff4a0f52668193ae494f67f7e73c51d3cd4bf8405143e2876b375f4c106e96b4ecb7c69d7c8ab3e98e481d647bdb847f8
|
data/lib/sorbet-runtime.rb
CHANGED
data/lib/types/configuration.rb
CHANGED
@@ -415,21 +415,21 @@ module T::Configuration
|
|
415
415
|
raise ArgumentError.new("Provided values must all be class name strings.")
|
416
416
|
end
|
417
417
|
|
418
|
-
@scalar_types =
|
418
|
+
@scalar_types = values.each_with_object({}) {|x, acc| acc[x] = true}.freeze
|
419
419
|
end
|
420
420
|
end
|
421
421
|
|
422
|
-
@default_scalar_types =
|
423
|
-
NilClass
|
424
|
-
TrueClass
|
425
|
-
FalseClass
|
426
|
-
Integer
|
427
|
-
Float
|
428
|
-
String
|
429
|
-
Symbol
|
430
|
-
Time
|
431
|
-
T::Enum
|
432
|
-
|
422
|
+
@default_scalar_types = {
|
423
|
+
"NilClass" => true,
|
424
|
+
"TrueClass" => true,
|
425
|
+
"FalseClass" => true,
|
426
|
+
"Integer" => true,
|
427
|
+
"Float" => true,
|
428
|
+
"String" => true,
|
429
|
+
"Symbol" => true,
|
430
|
+
"Time" => true,
|
431
|
+
"T::Enum" => true,
|
432
|
+
}.freeze
|
433
433
|
|
434
434
|
def self.scalar_types
|
435
435
|
@scalar_types || @default_scalar_types
|
@@ -2,13 +2,13 @@
|
|
2
2
|
# typed: false
|
3
3
|
|
4
4
|
module T::Private::Methods
|
5
|
-
@installed_hooks =
|
5
|
+
@installed_hooks = {}
|
6
6
|
@signatures_by_method = {}
|
7
7
|
@sig_wrappers = {}
|
8
8
|
@sigs_that_raised = {}
|
9
9
|
# stores method names that were declared final without regard for where.
|
10
10
|
# enables early rejection of names that we know can't induce final method violations.
|
11
|
-
@was_ever_final_names =
|
11
|
+
@was_ever_final_names = {}
|
12
12
|
# maps from modules to the set of final methods declared in that module.
|
13
13
|
# we also overload entries slightly: if the value is nil, that means that the
|
14
14
|
# module has final methods somewhere along its ancestor chain, but does not itself
|
@@ -190,10 +190,11 @@ module T::Private::Methods
|
|
190
190
|
m = is_singleton_method ? mod.singleton_class : mod
|
191
191
|
methods = @modules_with_final[m]
|
192
192
|
if methods.nil?
|
193
|
-
methods =
|
193
|
+
methods = {}
|
194
194
|
@modules_with_final[m] = methods
|
195
195
|
end
|
196
|
-
methods
|
196
|
+
methods[method_name] = true
|
197
|
+
nil
|
197
198
|
end
|
198
199
|
|
199
200
|
def self.note_module_deals_with_final(mod)
|
@@ -276,7 +277,7 @@ module T::Private::Methods
|
|
276
277
|
|
277
278
|
@sig_wrappers[key] = sig_block
|
278
279
|
if current_declaration.final
|
279
|
-
@was_ever_final_names
|
280
|
+
@was_ever_final_names[method_name] = true
|
280
281
|
# use hook_mod, not mod, because for example, we want class C to be marked as having final if we def C.foo as
|
281
282
|
# final. change this to mod to see some final_method tests fail.
|
282
283
|
note_module_deals_with_final(hook_mod)
|
@@ -527,7 +528,7 @@ module T::Private::Methods
|
|
527
528
|
|
528
529
|
def self.install_hooks(mod)
|
529
530
|
return if @installed_hooks.include?(mod)
|
530
|
-
@installed_hooks
|
531
|
+
@installed_hooks[mod] = true
|
531
532
|
|
532
533
|
if mod == TOP_SELF
|
533
534
|
# self at the top-level of a file is weirdly special in Ruby
|
data/lib/types/private/sealed.rb
CHANGED
@@ -11,7 +11,11 @@ module T::Private::Sealed
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def sealed_subclasses
|
14
|
-
@
|
14
|
+
@sorbet_sealed_module_all_subclasses_set ||= # rubocop:disable Naming/MemoizedInstanceVariableName
|
15
|
+
begin
|
16
|
+
require 'set'
|
17
|
+
Set.new(@sorbet_sealed_module_all_subclasses).freeze
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
@@ -34,7 +38,11 @@ module T::Private::Sealed
|
|
34
38
|
# this will freeze the set so that you can never get into a
|
35
39
|
# state where you use the subclasses list and then something
|
36
40
|
# else will add to it
|
37
|
-
@
|
41
|
+
@sorbet_sealed_module_all_subclasses_set ||= # rubocop:disable Naming/MemoizedInstanceVariableName
|
42
|
+
begin
|
43
|
+
require 'set'
|
44
|
+
Set.new(@sorbet_sealed_module_all_subclasses).freeze
|
45
|
+
end
|
38
46
|
end
|
39
47
|
end
|
40
48
|
|
@@ -53,7 +61,7 @@ module T::Private::Sealed
|
|
53
61
|
raise "Couldn't determine declaration file for sealed class."
|
54
62
|
end
|
55
63
|
mod.instance_variable_set(:@sorbet_sealed_module_decl_file, decl_file)
|
56
|
-
mod.instance_variable_set(:@sorbet_sealed_module_all_subclasses,
|
64
|
+
mod.instance_variable_set(:@sorbet_sealed_module_all_subclasses, [])
|
57
65
|
end
|
58
66
|
|
59
67
|
def self.sealed_module?(mod)
|
@@ -198,7 +198,7 @@ class T::Props::Decorator
|
|
198
198
|
end
|
199
199
|
|
200
200
|
# TODO: we should really be checking all the methods on `cls`, not just Object
|
201
|
-
BANNED_METHOD_NAMES = T.let(Object.instance_methods.
|
201
|
+
BANNED_METHOD_NAMES = T.let(Object.instance_methods.each_with_object({}) {|x, acc| acc[x] = true}.freeze, T::Hash[Symbol, TrueClass])
|
202
202
|
|
203
203
|
# checked(:never) - Rules hash is expensive to check
|
204
204
|
sig do
|
data/lib/types/types/enum.rb
CHANGED
data/lib/types/types/simple.rb
CHANGED
@@ -48,8 +48,6 @@ module T::Types
|
|
48
48
|
|
49
49
|
type = if mod == ::Array
|
50
50
|
T::Array[T.untyped]
|
51
|
-
elsif mod == ::Set
|
52
|
-
T::Set[T.untyped]
|
53
51
|
elsif mod == ::Hash
|
54
52
|
T::Hash[T.untyped, T.untyped]
|
55
53
|
elsif mod == ::Enumerable
|
@@ -58,6 +56,8 @@ module T::Types
|
|
58
56
|
T::Enumerator[T.untyped]
|
59
57
|
elsif mod == ::Range
|
60
58
|
T::Range[T.untyped]
|
59
|
+
elsif !Object.autoload?(:Set) && Object.const_defined?(:Set) && mod == ::Set
|
60
|
+
T::Set[T.untyped]
|
61
61
|
else
|
62
62
|
Simple.new(mod)
|
63
63
|
end
|
@@ -16,15 +16,24 @@ module T::Types
|
|
16
16
|
|
17
17
|
# overrides Base
|
18
18
|
def recursively_valid?(obj)
|
19
|
+
# Re-implements non_forcing_is_a?
|
20
|
+
return false if Object.autoload?(:Set) # Set is meant to be autoloaded but not yet loaded, this value can't be a Set
|
21
|
+
return false unless Object.const_defined?(:Set) # Set is not loaded yet
|
19
22
|
obj.is_a?(Set) && super
|
20
23
|
end
|
21
24
|
|
22
25
|
# overrides Base
|
23
26
|
def valid?(obj)
|
27
|
+
# Re-implements non_forcing_is_a?
|
28
|
+
return false if Object.autoload?(:Set) # Set is meant to be autoloaded but not yet loaded, this value can't be a Set
|
29
|
+
return false unless Object.const_defined?(:Set) # Set is not loaded yet
|
24
30
|
obj.is_a?(Set)
|
25
31
|
end
|
26
32
|
|
27
33
|
def new(*args)
|
34
|
+
# Fine for this to blow up, because hopefully if they're trying to make a
|
35
|
+
# Set, they don't mind putting (or already have put) a `require 'set'` in
|
36
|
+
# their program directly.
|
28
37
|
Set.new(*T.unsafe(args))
|
29
38
|
end
|
30
39
|
|
@@ -34,6 +43,9 @@ module T::Types
|
|
34
43
|
end
|
35
44
|
|
36
45
|
def valid?(obj)
|
46
|
+
# Re-implements non_forcing_is_a?
|
47
|
+
return false if Object.autoload?(:Set) # Set is meant to be autoloaded but not yet loaded, this value can't be a Set
|
48
|
+
return false unless Object.const_defined?(:Set) # Set is not loaded yet
|
37
49
|
obj.is_a?(Set)
|
38
50
|
end
|
39
51
|
end
|
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.
|
4
|
+
version: 0.5.9265
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|