tapioca 0.10.1 → 0.10.3
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/README.md +9 -3
- data/lib/tapioca/cli.rb +24 -12
- data/lib/tapioca/commands/annotations.rb +2 -2
- data/lib/tapioca/commands/check_shims.rb +13 -21
- data/lib/tapioca/commands/command.rb +2 -2
- data/lib/tapioca/commands/command_without_tracker.rb +18 -0
- data/lib/tapioca/commands/configure.rb +3 -3
- data/lib/tapioca/commands/dsl.rb +16 -11
- data/lib/tapioca/commands/gem.rb +5 -5
- data/lib/tapioca/commands/require.rb +2 -2
- data/lib/tapioca/commands/todo.rb +2 -2
- data/lib/tapioca/commands.rb +1 -0
- data/lib/tapioca/dsl/compiler.rb +3 -3
- data/lib/tapioca/dsl/compilers/aasm.rb +4 -4
- data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +1 -1
- data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_job.rb +2 -2
- data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_associations.rb +48 -13
- data/lib/tapioca/dsl/compilers/active_record_columns.rb +22 -22
- data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +52 -48
- data/lib/tapioca/dsl/compilers/active_record_scope.rb +3 -3
- data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +2 -2
- data/lib/tapioca/dsl/compilers/active_storage.rb +2 -2
- data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +1 -1
- data/lib/tapioca/dsl/compilers/config.rb +2 -2
- data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -0
- data/lib/tapioca/dsl/compilers/graphql_mutation.rb +1 -0
- data/lib/tapioca/dsl/compilers/identity_cache.rb +12 -12
- data/lib/tapioca/dsl/compilers/protobuf.rb +21 -10
- data/lib/tapioca/dsl/compilers/rails_generators.rb +2 -2
- data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -1
- data/lib/tapioca/dsl/compilers/smart_properties.rb +2 -2
- data/lib/tapioca/dsl/compilers/state_machines.rb +24 -24
- data/lib/tapioca/dsl/compilers/url_helpers.rb +1 -1
- data/lib/tapioca/dsl/compilers.rb +1 -1
- data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +19 -0
- data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +1 -1
- data/lib/tapioca/dsl/pipeline.rb +5 -4
- data/lib/tapioca/executor.rb +2 -2
- data/lib/tapioca/gem/events.rb +1 -1
- data/lib/tapioca/gem/listeners/foreign_constants.rb +3 -2
- data/lib/tapioca/gem/listeners/methods.rb +3 -3
- data/lib/tapioca/gem/listeners/mixins.rb +3 -7
- data/lib/tapioca/gem/listeners/source_location.rb +1 -1
- data/lib/tapioca/gem/listeners/subconstants.rb +1 -1
- data/lib/tapioca/gem/listeners/yard_doc.rb +1 -1
- data/lib/tapioca/gem/pipeline.rb +11 -9
- data/lib/tapioca/gemfile.rb +4 -4
- data/lib/tapioca/helpers/config_helper.rb +4 -4
- data/lib/tapioca/helpers/env_helper.rb +1 -0
- data/lib/tapioca/helpers/gem_helper.rb +17 -5
- data/lib/tapioca/helpers/rbi_files_helper.rb +3 -3
- data/lib/tapioca/helpers/rbi_helper.rb +5 -13
- data/lib/tapioca/helpers/sorbet_helper.rb +3 -5
- data/lib/tapioca/helpers/source_uri.rb +1 -1
- data/lib/tapioca/helpers/test/dsl_compiler.rb +1 -1
- data/lib/tapioca/loaders/dsl.rb +9 -7
- data/lib/tapioca/loaders/gem.rb +2 -2
- data/lib/tapioca/loaders/loader.rb +6 -6
- data/lib/tapioca/rbi_ext/model.rb +8 -5
- data/lib/tapioca/rbi_formatter.rb +2 -2
- data/lib/tapioca/runtime/generic_type_registry.rb +22 -2
- data/lib/tapioca/runtime/reflection.rb +63 -2
- data/lib/tapioca/runtime/trackers/autoload.rb +3 -0
- data/lib/tapioca/runtime/trackers/constant_definition.rb +13 -5
- data/lib/tapioca/runtime/trackers/mixin.rb +37 -36
- data/lib/tapioca/runtime/trackers/required_ancestor.rb +17 -4
- data/lib/tapioca/runtime/trackers/tracker.rb +45 -0
- data/lib/tapioca/runtime/trackers.rb +27 -1
- data/lib/tapioca/sorbet_ext/generic_name_patch.rb +17 -6
- data/lib/tapioca/static/symbol_loader.rb +3 -3
- data/lib/tapioca/static/symbol_table_parser.rb +6 -0
- data/lib/tapioca/version.rb +1 -1
- data/lib/tapioca.rb +0 -10
- metadata +8 -20
@@ -19,20 +19,26 @@ module Tapioca
|
|
19
19
|
PROTECTED_INSTANCE_METHODS_METHOD = T.let(Module.instance_method(:protected_instance_methods), UnboundMethod)
|
20
20
|
PRIVATE_INSTANCE_METHODS_METHOD = T.let(Module.instance_method(:private_instance_methods), UnboundMethod)
|
21
21
|
METHOD_METHOD = T.let(Kernel.instance_method(:method), UnboundMethod)
|
22
|
+
UNDEFINED_CONSTANT = T.let(Module.new.freeze, Module)
|
22
23
|
|
23
24
|
REQUIRED_FROM_LABELS = T.let(["<top (required)>", "<main>"].freeze, T::Array[String])
|
24
25
|
|
26
|
+
T::Sig::WithoutRuntime.sig { params(constant: BasicObject).returns(T::Boolean) }
|
27
|
+
def constant_defined?(constant)
|
28
|
+
!UNDEFINED_CONSTANT.eql?(constant)
|
29
|
+
end
|
30
|
+
|
25
31
|
sig do
|
26
32
|
params(
|
27
33
|
symbol: String,
|
28
34
|
inherit: T::Boolean,
|
29
|
-
namespace: Module
|
35
|
+
namespace: Module,
|
30
36
|
).returns(BasicObject).checked(:never)
|
31
37
|
end
|
32
38
|
def constantize(symbol, inherit: false, namespace: Object)
|
33
39
|
namespace.const_get(symbol, inherit)
|
34
40
|
rescue NameError, LoadError, RuntimeError, ArgumentError, TypeError
|
35
|
-
|
41
|
+
UNDEFINED_CONSTANT
|
36
42
|
end
|
37
43
|
|
38
44
|
sig { params(object: BasicObject).returns(Class).checked(:never) }
|
@@ -177,6 +183,61 @@ module Tapioca
|
|
177
183
|
|
178
184
|
T.cast(result, Module)
|
179
185
|
end
|
186
|
+
|
187
|
+
sig { params(constant: Module).returns(T::Set[String]) }
|
188
|
+
def file_candidates_for(constant)
|
189
|
+
relevant_methods_for(constant).filter_map do |method|
|
190
|
+
method.source_location&.first
|
191
|
+
end.to_set
|
192
|
+
end
|
193
|
+
|
194
|
+
private
|
195
|
+
|
196
|
+
sig { params(constant: Module).returns(T::Array[UnboundMethod]) }
|
197
|
+
def relevant_methods_for(constant)
|
198
|
+
methods = methods_for(constant).select(&:source_location)
|
199
|
+
.reject { |x| method_defined_by_forwardable_module?(x) }
|
200
|
+
|
201
|
+
return methods unless methods.empty?
|
202
|
+
|
203
|
+
constants_of(constant).flat_map do |const_name|
|
204
|
+
if (mod = child_module_for_parent_with_name(constant, const_name.to_s))
|
205
|
+
relevant_methods_for(mod)
|
206
|
+
else
|
207
|
+
[]
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
sig { params(constant: Module).returns(T::Array[UnboundMethod]) }
|
213
|
+
def methods_for(constant)
|
214
|
+
modules = [constant, singleton_class_of(constant)]
|
215
|
+
method_list_methods = [
|
216
|
+
PUBLIC_INSTANCE_METHODS_METHOD,
|
217
|
+
PROTECTED_INSTANCE_METHODS_METHOD,
|
218
|
+
PRIVATE_INSTANCE_METHODS_METHOD,
|
219
|
+
]
|
220
|
+
|
221
|
+
modules.product(method_list_methods).flat_map do |mod, method_list_method|
|
222
|
+
method_list_method.bind_call(mod, false).map { |name| mod.instance_method(name) }
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
sig { params(parent: Module, name: String).returns(T.nilable(Module)) }
|
227
|
+
def child_module_for_parent_with_name(parent, name)
|
228
|
+
return if parent.autoload?(name)
|
229
|
+
|
230
|
+
child = constantize(name, inherit: true, namespace: parent)
|
231
|
+
return unless Module === child
|
232
|
+
return unless name_of(child) == "#{name_of(parent)}::#{name}"
|
233
|
+
|
234
|
+
child
|
235
|
+
end
|
236
|
+
|
237
|
+
sig { params(method: UnboundMethod).returns(T::Boolean) }
|
238
|
+
def method_defined_by_forwardable_module?(method)
|
239
|
+
method.source_location&.first == Object.const_source_location(:Forwardable)&.first
|
240
|
+
end
|
180
241
|
end
|
181
242
|
end
|
182
243
|
end
|
@@ -5,6 +5,7 @@ module Tapioca
|
|
5
5
|
module Runtime
|
6
6
|
module Trackers
|
7
7
|
module Autoload
|
8
|
+
extend Tracker
|
8
9
|
extend T::Sig
|
9
10
|
|
10
11
|
NOOP_METHOD = ->(*_args, **_kwargs, &_block) {}
|
@@ -28,6 +29,8 @@ module Tapioca
|
|
28
29
|
|
29
30
|
sig { params(constant_name: String).void }
|
30
31
|
def register(constant_name)
|
32
|
+
return unless enabled?
|
33
|
+
|
31
34
|
@constant_names_registered_for_autoload << constant_name
|
32
35
|
end
|
33
36
|
|
@@ -9,6 +9,7 @@ module Tapioca
|
|
9
9
|
# correspondence between classes/modules and files, as this information isn't
|
10
10
|
# available in the ruby runtime without extra accounting.
|
11
11
|
module ConstantDefinition
|
12
|
+
extend Tracker
|
12
13
|
extend Reflection
|
13
14
|
extend T::Sig
|
14
15
|
|
@@ -20,7 +21,7 @@ module Tapioca
|
|
20
21
|
@class_files = {}.compare_by_identity
|
21
22
|
|
22
23
|
# Immediately activated upon load. Observes class/module definition.
|
23
|
-
|
24
|
+
@class_tracepoint = TracePoint.trace(:class) do |tp|
|
24
25
|
next if tp.self.singleton_class?
|
25
26
|
|
26
27
|
key = tp.self
|
@@ -40,19 +41,26 @@ module Tapioca
|
|
40
41
|
(@class_files[key] ||= Set.new) << loc
|
41
42
|
end
|
42
43
|
|
43
|
-
|
44
|
+
@creturn_tracepoint = TracePoint.trace(:c_return) do |tp|
|
44
45
|
next unless tp.method_id == :new
|
45
|
-
next unless Module === tp.return_value
|
46
46
|
|
47
47
|
key = tp.return_value
|
48
|
+
next unless Module === key
|
49
|
+
|
48
50
|
loc = build_constant_location(tp, caller_locations)
|
49
51
|
(@class_files[key] ||= Set.new) << loc
|
50
52
|
end
|
51
53
|
|
52
54
|
class << self
|
55
|
+
def disable!
|
56
|
+
@class_tracepoint.disable
|
57
|
+
@creturn_tracepoint.disable
|
58
|
+
super
|
59
|
+
end
|
60
|
+
|
53
61
|
def build_constant_location(tp, locations)
|
54
|
-
file = resolve_loc(
|
55
|
-
lineno =
|
62
|
+
file = resolve_loc(locations)
|
63
|
+
lineno = File.identical?(file, tp.path) ? tp.lineno : 0
|
56
64
|
|
57
65
|
ConstantLocation.new(path: file, lineno: lineno)
|
58
66
|
end
|
@@ -5,11 +5,11 @@ module Tapioca
|
|
5
5
|
module Runtime
|
6
6
|
module Trackers
|
7
7
|
module Mixin
|
8
|
+
extend Tracker
|
8
9
|
extend T::Sig
|
9
10
|
|
10
11
|
@constants_to_mixin_locations = {}.compare_by_identity
|
11
12
|
@mixins_to_constants = {}.compare_by_identity
|
12
|
-
@enabled = true
|
13
13
|
|
14
14
|
class Type < T::Enum
|
15
15
|
enums do
|
@@ -28,31 +28,52 @@ module Tapioca
|
|
28
28
|
.returns(T.type_parameter(:Result))
|
29
29
|
end
|
30
30
|
def with_disabled_registration(&block)
|
31
|
-
|
32
|
-
|
33
|
-
block.call
|
34
|
-
ensure
|
35
|
-
@enabled = true
|
31
|
+
with_disabled_tracker(&block)
|
36
32
|
end
|
37
33
|
|
38
|
-
sig
|
39
|
-
params(
|
40
|
-
constant: Module,
|
41
|
-
mixin: Module,
|
42
|
-
mixin_type: Type,
|
43
|
-
).void
|
44
|
-
end
|
34
|
+
sig { params(constant: Module, mixin: Module, mixin_type: Type).void }
|
45
35
|
def register(constant, mixin, mixin_type)
|
46
|
-
return unless
|
36
|
+
return unless enabled?
|
47
37
|
|
48
38
|
location = Reflection.resolve_loc(caller_locations)
|
49
39
|
|
50
|
-
|
51
|
-
|
40
|
+
register_with_location(constant, mixin, mixin_type, location)
|
41
|
+
end
|
42
|
+
|
43
|
+
def resolve_to_attached_class(constant, mixin, mixin_type)
|
44
|
+
attached_class = Reflection.attached_class_of(constant)
|
45
|
+
return unless attached_class
|
46
|
+
|
47
|
+
if mixin_type == Type::Include || mixin_type == Type::Prepend
|
48
|
+
location = mixin_location(mixin, mixin_type, constant)
|
49
|
+
register_with_location(constant, mixin, Type::Extend, T.must(location))
|
50
|
+
end
|
51
|
+
|
52
|
+
attached_class
|
52
53
|
end
|
53
54
|
|
54
55
|
sig { params(mixin: Module).returns(T::Hash[Type, T::Hash[Module, String]]) }
|
55
56
|
def constants_with_mixin(mixin)
|
57
|
+
find_or_initialize_mixin_lookup(mixin)
|
58
|
+
end
|
59
|
+
|
60
|
+
sig { params(mixin: Module, mixin_type: Type, constant: Module).returns(T.nilable(String)) }
|
61
|
+
def mixin_location(mixin, mixin_type, constant)
|
62
|
+
find_or_initialize_mixin_lookup(mixin).dig(mixin_type, constant)
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
sig { params(constant: Module, mixin: Module, mixin_type: Type, location: String).void }
|
68
|
+
def register_with_location(constant, mixin, mixin_type, location)
|
69
|
+
return unless @enabled
|
70
|
+
|
71
|
+
constants = find_or_initialize_mixin_lookup(mixin)
|
72
|
+
constants.fetch(mixin_type).store(constant, location)
|
73
|
+
end
|
74
|
+
|
75
|
+
sig { params(mixin: Module).returns(T::Hash[Type, T::Hash[Module, String]]) }
|
76
|
+
def find_or_initialize_mixin_lookup(mixin)
|
56
77
|
@mixins_to_constants[mixin] ||= {
|
57
78
|
Type::Prepend => {}.compare_by_identity,
|
58
79
|
Type::Include => {}.compare_by_identity,
|
@@ -74,8 +95,6 @@ class Module
|
|
74
95
|
Tapioca::Runtime::Trackers::Mixin::Type::Prepend,
|
75
96
|
)
|
76
97
|
|
77
|
-
register_extend_on_attached_class(constant) if constant.singleton_class?
|
78
|
-
|
79
98
|
super
|
80
99
|
end
|
81
100
|
|
@@ -86,8 +105,6 @@ class Module
|
|
86
105
|
Tapioca::Runtime::Trackers::Mixin::Type::Include,
|
87
106
|
)
|
88
107
|
|
89
|
-
register_extend_on_attached_class(constant) if constant.singleton_class?
|
90
|
-
|
91
108
|
super
|
92
109
|
end
|
93
110
|
|
@@ -99,21 +116,5 @@ class Module
|
|
99
116
|
) if Module === obj
|
100
117
|
super
|
101
118
|
end
|
102
|
-
|
103
|
-
private
|
104
|
-
|
105
|
-
# Including or prepending on a singleton class is functionally equivalent to extending the
|
106
|
-
# attached class. Registering the mixin as an extend on the attached class ensures that
|
107
|
-
# this mixin can be found whether searching for an include/prepend on the singleton class
|
108
|
-
# or an extend on the attached class.
|
109
|
-
def register_extend_on_attached_class(constant)
|
110
|
-
attached_class = Tapioca::Runtime::Reflection.attached_class_of(constant)
|
111
|
-
|
112
|
-
Tapioca::Runtime::Trackers::Mixin.register(
|
113
|
-
T.cast(attached_class, Module),
|
114
|
-
self,
|
115
|
-
Tapioca::Runtime::Trackers::Mixin::Type::Extend,
|
116
|
-
) if attached_class
|
117
|
-
end
|
118
119
|
end)
|
119
120
|
end
|
@@ -5,27 +5,40 @@ module Tapioca
|
|
5
5
|
module Runtime
|
6
6
|
module Trackers
|
7
7
|
module RequiredAncestor
|
8
|
+
extend Tracker
|
8
9
|
@required_ancestors_map = {}.compare_by_identity
|
9
10
|
|
10
11
|
class << self
|
11
12
|
extend T::Sig
|
12
13
|
|
13
|
-
sig { params(requiring: T::Helpers, block: T.proc.
|
14
|
+
sig { params(requiring: T::Helpers, block: T.proc.void).void }
|
14
15
|
def register(requiring, block)
|
16
|
+
return unless enabled?
|
17
|
+
|
15
18
|
ancestors = @required_ancestors_map[requiring] ||= []
|
16
19
|
ancestors << block
|
17
20
|
end
|
18
21
|
|
19
|
-
sig { params(mod: Module).returns(T::Array[T.proc.
|
22
|
+
sig { params(mod: Module).returns(T::Array[T.proc.void]) }
|
20
23
|
def required_ancestors_blocks_by(mod)
|
21
24
|
@required_ancestors_map[mod] || []
|
22
25
|
end
|
23
26
|
|
24
|
-
sig { params(mod: Module).returns(T::Array[T.
|
27
|
+
sig { params(mod: Module).returns(T::Array[T.untyped]) }
|
25
28
|
def required_ancestors_by(mod)
|
26
29
|
blocks = required_ancestors_blocks_by(mod)
|
27
30
|
blocks.map do |block|
|
28
|
-
block.call
|
31
|
+
# Common return values of `block.call` here could be a Module or a Sorbet's runtime value for T.class.
|
32
|
+
# But in reality it could be whatever the block has that can pass Sorbet's static check. Like
|
33
|
+
#
|
34
|
+
# ```
|
35
|
+
# requires_ancestor { T.class_of(Foo); nil }
|
36
|
+
# ```
|
37
|
+
#
|
38
|
+
# So it's not designed to be used at runtime and it's accidental that just calling `to_s` on the above
|
39
|
+
# common values can get us the correct value to generate type signatures. (See SorbetRequiredAncestors)
|
40
|
+
# Therefore, the return value `block.call` should be considered unreliable and treated with caution.
|
41
|
+
T.unsafe(block.call)
|
29
42
|
rescue NameError
|
30
43
|
# The ancestor required doesn't exist, let's return nil and let the compiler decide what to do.
|
31
44
|
nil
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Tapioca
|
5
|
+
module Runtime
|
6
|
+
module Trackers
|
7
|
+
module Tracker
|
8
|
+
extend T::Sig
|
9
|
+
extend T::Helpers
|
10
|
+
|
11
|
+
abstract!
|
12
|
+
|
13
|
+
class << self
|
14
|
+
extend T::Sig
|
15
|
+
|
16
|
+
sig { params(base: T.all(Tracker, Module)).void }
|
17
|
+
def extended(base)
|
18
|
+
Trackers.register_tracker(base)
|
19
|
+
base.instance_exec do
|
20
|
+
@enabled = true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
sig { void }
|
26
|
+
def disable!
|
27
|
+
@enabled = false
|
28
|
+
end
|
29
|
+
|
30
|
+
def enabled?
|
31
|
+
@enabled
|
32
|
+
end
|
33
|
+
|
34
|
+
def with_disabled_tracker(&block)
|
35
|
+
original_state = @enabled
|
36
|
+
@enabled = false
|
37
|
+
|
38
|
+
block.call
|
39
|
+
ensure
|
40
|
+
@enabled = original_state
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -1,6 +1,32 @@
|
|
1
|
-
# typed:
|
1
|
+
# typed: true
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
require "tapioca/runtime/trackers/tracker"
|
5
|
+
|
6
|
+
module Tapioca
|
7
|
+
module Runtime
|
8
|
+
module Trackers
|
9
|
+
extend T::Sig
|
10
|
+
|
11
|
+
@trackers = T.let([], T::Array[Tracker])
|
12
|
+
|
13
|
+
class << self
|
14
|
+
extend T::Sig
|
15
|
+
|
16
|
+
sig { void }
|
17
|
+
def disable_all!
|
18
|
+
@trackers.each(&:disable!)
|
19
|
+
end
|
20
|
+
|
21
|
+
sig { params(tracker: Tracker).void }
|
22
|
+
def register_tracker(tracker)
|
23
|
+
@trackers << tracker
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
4
30
|
# The load order below is important:
|
5
31
|
# ----------------------------------
|
6
32
|
# We want the mixin tracker to be the first thing that is
|
@@ -28,7 +28,7 @@ module T
|
|
28
28
|
fixed,
|
29
29
|
lower,
|
30
30
|
upper,
|
31
|
-
bounds_proc
|
31
|
+
bounds_proc,
|
32
32
|
).tap do |type_variable|
|
33
33
|
Tapioca::Runtime::GenericTypeRegistry.register_type_variable(self, type_variable)
|
34
34
|
end
|
@@ -44,7 +44,7 @@ module T
|
|
44
44
|
fixed,
|
45
45
|
lower,
|
46
46
|
upper,
|
47
|
-
bounds_proc
|
47
|
+
bounds_proc,
|
48
48
|
).tap do |type_variable|
|
49
49
|
Tapioca::Runtime::GenericTypeRegistry.register_type_variable(self, type_variable)
|
50
50
|
end
|
@@ -82,6 +82,8 @@ module T
|
|
82
82
|
def coerce(val)
|
83
83
|
if val.is_a?(Tapioca::TypeVariableModule)
|
84
84
|
val.coerce_to_type_variable
|
85
|
+
elsif val.respond_to?(:__tapioca_override_type)
|
86
|
+
val.__tapioca_override_type
|
85
87
|
else
|
86
88
|
super
|
87
89
|
end
|
@@ -128,7 +130,7 @@ module Tapioca
|
|
128
130
|
fixed: T.untyped,
|
129
131
|
lower: T.untyped,
|
130
132
|
upper: T.untyped,
|
131
|
-
bounds_proc: T.nilable(T.proc.returns(T::Hash[Symbol, T.untyped]))
|
133
|
+
bounds_proc: T.nilable(T.proc.returns(T::Hash[Symbol, T.untyped])),
|
132
134
|
).void
|
133
135
|
end
|
134
136
|
def initialize(context, type, variance, fixed, lower, upper, bounds_proc)
|
@@ -164,10 +166,14 @@ module Tapioca
|
|
164
166
|
constant_name&.split("::")&.last
|
165
167
|
end
|
166
168
|
|
169
|
+
sig { returns(T::Boolean) }
|
170
|
+
def fixed?
|
171
|
+
bounds.key?(:fixed)
|
172
|
+
end
|
173
|
+
|
167
174
|
sig { returns(String) }
|
168
175
|
def serialize
|
169
|
-
|
170
|
-
fixed = bounds[:fixed].to_s if bounds.key?(:fixed)
|
176
|
+
fixed = bounds[:fixed].to_s if fixed?
|
171
177
|
lower = bounds[:lower].to_s if bounds.key?(:lower)
|
172
178
|
upper = bounds[:upper].to_s if bounds.key?(:upper)
|
173
179
|
|
@@ -176,7 +182,7 @@ module Tapioca
|
|
176
182
|
@variance,
|
177
183
|
fixed,
|
178
184
|
upper,
|
179
|
-
lower
|
185
|
+
lower,
|
180
186
|
)
|
181
187
|
end
|
182
188
|
|
@@ -213,5 +219,10 @@ module Tapioca
|
|
213
219
|
ensure
|
214
220
|
self.class.send(:remove_const, temp_name) if temp_name
|
215
221
|
end
|
222
|
+
|
223
|
+
sig { returns(T::Hash[Symbol, T.untyped]) }
|
224
|
+
def bounds
|
225
|
+
@bounds ||= @bounds_proc.call
|
226
|
+
end
|
216
227
|
end
|
217
228
|
end
|
@@ -62,14 +62,14 @@ module Tapioca
|
|
62
62
|
|
63
63
|
sig { params(paths: T::Array[Pathname]).returns(T::Set[String]) }
|
64
64
|
def symbols_from_paths(paths)
|
65
|
-
output =
|
65
|
+
output = Tempfile.create("sorbet") do |file|
|
66
66
|
file.write(Array(paths).join("\n"))
|
67
67
|
file.flush
|
68
68
|
|
69
69
|
symbol_table_json_from("@#{file.path.shellescape}")
|
70
|
-
end
|
70
|
+
end
|
71
71
|
|
72
|
-
return Set.new if output.
|
72
|
+
return Set.new if output.empty?
|
73
73
|
|
74
74
|
SymbolTableParser.parse_json(output)
|
75
75
|
end
|
@@ -43,6 +43,12 @@ module Tapioca
|
|
43
43
|
|
44
44
|
next if name.nil?
|
45
45
|
next unless SKIP_PARSE_KINDS.include?(kind)
|
46
|
+
|
47
|
+
# Turn singleton class names to attached class names
|
48
|
+
if (match_data = name.match(/<Class:(.*)>/))
|
49
|
+
name = match_data[1]
|
50
|
+
end
|
51
|
+
|
46
52
|
next if name.match?(/[<>()$]/)
|
47
53
|
next if name.match?(/^[0-9]+$/)
|
48
54
|
next if name == "T::Helpers"
|
data/lib/tapioca/version.rb
CHANGED
data/lib/tapioca.rb
CHANGED
@@ -11,16 +11,6 @@ module Tapioca
|
|
11
11
|
class << self
|
12
12
|
extend T::Sig
|
13
13
|
|
14
|
-
sig { params(trace_name: Symbol, block: T.proc.params(arg0: TracePoint).void).void }
|
15
|
-
def register_trace(trace_name, &block)
|
16
|
-
@traces << TracePoint.trace(trace_name, &block)
|
17
|
-
end
|
18
|
-
|
19
|
-
sig { void }
|
20
|
-
def disable_traces
|
21
|
-
@traces.each(&:disable)
|
22
|
-
end
|
23
|
-
|
24
14
|
sig do
|
25
15
|
type_parameters(:Result)
|
26
16
|
.params(blk: T.proc.returns(T.type_parameter(:Result)))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tapioca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ufuk Kayserilioglu
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2022-
|
14
|
+
date: 2022-11-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -55,20 +55,6 @@ dependencies:
|
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: 1.21.0
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: pry
|
60
|
-
requirement: !ruby/object:Gem::Requirement
|
61
|
-
requirements:
|
62
|
-
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: 0.12.2
|
65
|
-
type: :runtime
|
66
|
-
prerelease: false
|
67
|
-
version_requirements: !ruby/object:Gem::Requirement
|
68
|
-
requirements:
|
69
|
-
- - ">="
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: 0.12.2
|
72
58
|
- !ruby/object:Gem::Dependency
|
73
59
|
name: rbi
|
74
60
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,7 +64,7 @@ dependencies:
|
|
78
64
|
version: 0.0.0
|
79
65
|
- - ">="
|
80
66
|
- !ruby/object:Gem::Version
|
81
|
-
version: 0.0.
|
67
|
+
version: 0.0.16
|
82
68
|
type: :runtime
|
83
69
|
prerelease: false
|
84
70
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -88,21 +74,21 @@ dependencies:
|
|
88
74
|
version: 0.0.0
|
89
75
|
- - ">="
|
90
76
|
- !ruby/object:Gem::Version
|
91
|
-
version: 0.0.
|
77
|
+
version: 0.0.16
|
92
78
|
- !ruby/object:Gem::Dependency
|
93
79
|
name: sorbet-static-and-runtime
|
94
80
|
requirement: !ruby/object:Gem::Requirement
|
95
81
|
requirements:
|
96
82
|
- - ">="
|
97
83
|
- !ruby/object:Gem::Version
|
98
|
-
version: 0.5.
|
84
|
+
version: 0.5.9892
|
99
85
|
type: :runtime
|
100
86
|
prerelease: false
|
101
87
|
version_requirements: !ruby/object:Gem::Requirement
|
102
88
|
requirements:
|
103
89
|
- - ">="
|
104
90
|
- !ruby/object:Gem::Version
|
105
|
-
version: 0.5.
|
91
|
+
version: 0.5.9892
|
106
92
|
- !ruby/object:Gem::Dependency
|
107
93
|
name: spoom
|
108
94
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,6 +154,7 @@ files:
|
|
168
154
|
- lib/tapioca/commands/annotations.rb
|
169
155
|
- lib/tapioca/commands/check_shims.rb
|
170
156
|
- lib/tapioca/commands/command.rb
|
157
|
+
- lib/tapioca/commands/command_without_tracker.rb
|
171
158
|
- lib/tapioca/commands/configure.rb
|
172
159
|
- lib/tapioca/commands/dsl.rb
|
173
160
|
- lib/tapioca/commands/gem.rb
|
@@ -258,6 +245,7 @@ files:
|
|
258
245
|
- lib/tapioca/runtime/trackers/constant_definition.rb
|
259
246
|
- lib/tapioca/runtime/trackers/mixin.rb
|
260
247
|
- lib/tapioca/runtime/trackers/required_ancestor.rb
|
248
|
+
- lib/tapioca/runtime/trackers/tracker.rb
|
261
249
|
- lib/tapioca/sorbet_ext/fixed_hash_patch.rb
|
262
250
|
- lib/tapioca/sorbet_ext/generic_name_patch.rb
|
263
251
|
- lib/tapioca/sorbet_ext/name_patch.rb
|