sorbet-runtime 0.5.6231 → 0.5.6239
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/types/private/methods/_methods.rb +0 -34
- data/lib/types/props/_props.rb +2 -1
- data/lib/types/props/private/serde_transform.rb +11 -14
- data/lib/types/utils.rb +0 -13
- 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: bd529ffe10dcd180d0586c9be21e5d526dac6f9c8795425a144af3e33200465e
|
|
4
|
+
data.tar.gz: 8eb08915e3e6a94e058edf51ecf14ea6907fdc4e75a51d916621a55ace1c8e51
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17552e97e54a5e41d77317b5cc663b3ad137e7fed471ea74eacced944b5366dd180863fa0962e2cddc354edb0fd1decf9775f8a5803f54437db732e34380ef3e
|
|
7
|
+
data.tar.gz: 1a1428f72c9ad09630a15b49701dcce5620ec5f78c3b65f6b77ba8ee02f5cc270889edd2983dc4776dc6eccf507c1eb8aec8b7b3a25ec84d652dbc4a5a39b9c1
|
|
@@ -75,40 +75,6 @@ module T::Private::Methods
|
|
|
75
75
|
T::Types::Proc.new(decl.params, decl.returns)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
# See docs at T::Utils.register_forwarder.
|
|
79
|
-
def self.register_forwarder(from_method, to_method, mode: Modes.overridable, remove_first_param: false)
|
|
80
|
-
# Normalize the method (see comment in signature_for_key).
|
|
81
|
-
from_method = from_method.owner.instance_method(from_method.name)
|
|
82
|
-
|
|
83
|
-
from_key = method_to_key(from_method)
|
|
84
|
-
maybe_run_sig_block_for_key(from_key)
|
|
85
|
-
if @signatures_by_method.key?(from_key)
|
|
86
|
-
raise "#{from_method} already has a method signature"
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
from_params = from_method.parameters
|
|
90
|
-
if from_params.length != 2 || from_params[0][0] != :rest || from_params[1][0] != :block
|
|
91
|
-
raise "forwarder methods should take a single splat param and a block param. `#{from_method}` " \
|
|
92
|
-
"takes these params: #{from_params}. For help, ask #dev-productivity."
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
# If there's already a signature for to_method, we get `parameters` from there, to enable
|
|
96
|
-
# chained forwarding. NB: we don't use `signature_for_key` here, because the normalization it
|
|
97
|
-
# does is broken when `to_method` has been clobbered by another method.
|
|
98
|
-
to_key = method_to_key(to_method)
|
|
99
|
-
maybe_run_sig_block_for_key(to_key)
|
|
100
|
-
to_params = @signatures_by_method[to_key]&.parameters || to_method.parameters
|
|
101
|
-
|
|
102
|
-
if remove_first_param
|
|
103
|
-
to_params = to_params[1..-1]
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
# We don't bother trying to preserve any types from to_signature because this won't be
|
|
107
|
-
# statically analyzed, and the types will just get checked when the forwarding happens.
|
|
108
|
-
from_signature = Signature.new_untyped(method: from_method, mode: mode, parameters: to_params)
|
|
109
|
-
@signatures_by_method[from_key] = from_signature
|
|
110
|
-
end
|
|
111
|
-
|
|
112
78
|
# Returns the signature for a method whose definition was preceded by `sig`.
|
|
113
79
|
#
|
|
114
80
|
# @param method [UnboundMethod]
|
data/lib/types/props/_props.rb
CHANGED
|
@@ -100,6 +100,7 @@ module T::Props
|
|
|
100
100
|
# form.
|
|
101
101
|
#
|
|
102
102
|
# @return [void]
|
|
103
|
+
sig {params(name: Symbol, cls: T.untyped, rules: T.untyped).void}
|
|
103
104
|
def prop(name, cls, rules={})
|
|
104
105
|
cls = T::Utils.coerce(cls) if !cls.is_a?(Module)
|
|
105
106
|
decorator.prop_defined(name, cls, rules)
|
|
@@ -124,7 +125,7 @@ module T::Props
|
|
|
124
125
|
end
|
|
125
126
|
|
|
126
127
|
# Shorthand helper to define a `prop` with `immutable => true`
|
|
127
|
-
sig {params(name:
|
|
128
|
+
sig {params(name: Symbol, cls_or_args: T.untyped, args: T::Hash[Symbol, T.untyped]).void}
|
|
128
129
|
def const(name, cls_or_args, args={})
|
|
129
130
|
if (cls_or_args.is_a?(Hash) && cls_or_args.key?(:immutable)) || args.key?(:immutable)
|
|
130
131
|
Kernel.raise ArgumentError.new("Cannot pass 'immutable' argument when using 'const' keyword to define a prop")
|
|
@@ -99,21 +99,18 @@ module T::Props
|
|
|
99
99
|
else
|
|
100
100
|
"#{varname}.nil? ? nil : #{inner}"
|
|
101
101
|
end
|
|
102
|
+
elsif type.types.all? {|t| generate(t, mode, varname).nil?}
|
|
103
|
+
# Handle, e.g., T::Boolean
|
|
104
|
+
nil
|
|
102
105
|
else
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
# Chalk::ODM::DeprecatedNumemric), we could opt to special case
|
|
112
|
-
# this union to have no specific serde transform (the only reason
|
|
113
|
-
# why Float has a special case is because round tripping through
|
|
114
|
-
# JSON might normalize Floats to Integers)
|
|
115
|
-
"T::Props::Utils.deep_clone_object(#{varname})"
|
|
116
|
-
end
|
|
106
|
+
# We currently deep_clone_object if the type was T.any(Integer, Float).
|
|
107
|
+
# When we get better support for union types (maybe this specific
|
|
108
|
+
# union type, because it would be a replacement for
|
|
109
|
+
# Chalk::ODM::DeprecatedNumemric), we could opt to special case
|
|
110
|
+
# this union to have no specific serde transform (the only reason
|
|
111
|
+
# why Float has a special case is because round tripping through
|
|
112
|
+
# JSON might normalize Floats to Integers)
|
|
113
|
+
"T::Props::Utils.deep_clone_object(#{varname})"
|
|
117
114
|
end
|
|
118
115
|
when T::Types::Intersection
|
|
119
116
|
dynamic_fallback = "T::Props::Utils.deep_clone_object(#{varname})"
|
data/lib/types/utils.rb
CHANGED
|
@@ -52,19 +52,6 @@ module T::Utils
|
|
|
52
52
|
end.uniq
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
# Associates a signature with a forwarder method that matches the signature of the method it
|
|
56
|
-
# forwards to. This is necessary because forwarder methods are often declared with catch-all
|
|
57
|
-
# splat parameters, rather than the exact set of parameters ultimately used by the target method,
|
|
58
|
-
# so they cannot be validated as strictly.
|
|
59
|
-
#
|
|
60
|
-
# The caller of this method must ensure that the forwarder method properly forwards all parameters
|
|
61
|
-
# such that the signature is accurate.
|
|
62
|
-
def self.register_forwarder(from_method, to_method, remove_first_param: false)
|
|
63
|
-
T::Private::Methods.register_forwarder(
|
|
64
|
-
from_method, to_method, remove_first_param: remove_first_param
|
|
65
|
-
)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
55
|
# Returns the signature for the instance method on the supplied module, or nil if it's not found or not typed.
|
|
69
56
|
#
|
|
70
57
|
# @example T::Utils.signature_for_instance_method(MyClass, :my_method)
|
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.6239
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stripe
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-01-
|
|
11
|
+
date: 2021-01-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|