tapioca 0.17.8 → 0.17.10
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 +2 -2
- data/lib/tapioca/commands/abstract_dsl.rb +21 -2
- data/lib/tapioca/commands/abstract_gem.rb +21 -2
- data/lib/tapioca/commands/annotations.rb +7 -1
- data/lib/tapioca/commands/check_shims.rb +9 -1
- data/lib/tapioca/commands/command.rb +1 -1
- data/lib/tapioca/dsl/compiler.rb +17 -12
- data/lib/tapioca/dsl/compilers/aasm.rb +2 -2
- data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +2 -2
- data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -1
- data/lib/tapioca/dsl/compilers/action_text.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_job.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +7 -1
- data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_associations.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_columns.rb +8 -2
- data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_enum.rb +2 -2
- data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +94 -100
- data/lib/tapioca/dsl/compilers/active_record_scope.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_store.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_resource.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_storage.rb +2 -2
- data/lib/tapioca/dsl/compilers/active_support_concern.rb +6 -6
- data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_support_time_ext.rb +1 -1
- data/lib/tapioca/dsl/compilers/config.rb +2 -2
- data/lib/tapioca/dsl/compilers/frozen_record.rb +1 -1
- data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -1
- data/lib/tapioca/dsl/compilers/graphql_mutation.rb +1 -1
- data/lib/tapioca/dsl/compilers/identity_cache.rb +2 -2
- data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +1 -1
- data/lib/tapioca/dsl/compilers/kredis.rb +1 -1
- data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +2 -2
- data/lib/tapioca/dsl/compilers/protobuf.rb +7 -3
- data/lib/tapioca/dsl/compilers/rails_generators.rb +1 -1
- data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -1
- data/lib/tapioca/dsl/compilers/smart_properties.rb +1 -1
- data/lib/tapioca/dsl/compilers/state_machines.rb +2 -2
- data/lib/tapioca/dsl/compilers/url_helpers.rb +7 -7
- data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +7 -3
- data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +18 -3
- data/lib/tapioca/dsl/pipeline.rb +25 -11
- data/lib/tapioca/gem/events.rb +15 -8
- data/lib/tapioca/gem/listeners/methods.rb +19 -7
- data/lib/tapioca/gem/listeners/mixins.rb +3 -3
- data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +1 -1
- data/lib/tapioca/gem/pipeline.rb +25 -18
- data/lib/tapioca/gemfile.rb +1 -1
- data/lib/tapioca/helpers/config_helper.rb +5 -1
- data/lib/tapioca/helpers/rbi_files_helper.rb +8 -1
- data/lib/tapioca/helpers/test/content.rb +1 -1
- data/lib/tapioca/internal.rb +1 -0
- data/lib/tapioca/loaders/gem.rb +15 -3
- data/lib/tapioca/rbi_ext/model.rb +9 -2
- data/lib/tapioca/repo_index.rb +1 -1
- data/lib/tapioca/runtime/attached_class_of_32.rb +1 -1
- data/lib/tapioca/runtime/attached_class_of_legacy.rb +1 -1
- data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +6 -6
- data/lib/tapioca/runtime/generic_type_registry.rb +8 -8
- data/lib/tapioca/runtime/helpers.rb +40 -0
- data/lib/tapioca/runtime/reflection.rb +19 -19
- data/lib/tapioca/runtime/trackers/autoload.rb +1 -1
- data/lib/tapioca/runtime/trackers/constant_definition.rb +3 -3
- data/lib/tapioca/runtime/trackers/method_definition.rb +4 -4
- data/lib/tapioca/runtime/trackers/mixin.rb +5 -5
- data/lib/tapioca/runtime/trackers/required_ancestor.rb +3 -3
- data/lib/tapioca/runtime/trackers/tracker.rb +1 -1
- data/lib/tapioca/sorbet_ext/generic_name_patch.rb +4 -4
- data/lib/tapioca/sorbet_ext/name_patch.rb +3 -14
- data/lib/tapioca/static/requires_compiler.rb +1 -1
- data/lib/tapioca/version.rb +1 -1
- data/lib/tapioca.rb +0 -36
- metadata +20 -19
|
@@ -32,7 +32,7 @@ module Tapioca
|
|
|
32
32
|
PROTECTED_INSTANCE_METHODS_METHOD = Module.instance_method(:protected_instance_methods) #: UnboundMethod
|
|
33
33
|
PRIVATE_INSTANCE_METHODS_METHOD = Module.instance_method(:private_instance_methods) #: UnboundMethod
|
|
34
34
|
METHOD_METHOD = Kernel.instance_method(:method) #: UnboundMethod
|
|
35
|
-
UNDEFINED_CONSTANT = Module.new.freeze #: Module
|
|
35
|
+
UNDEFINED_CONSTANT = Module.new.freeze #: T::Module[top]
|
|
36
36
|
|
|
37
37
|
REQUIRED_FROM_LABELS = ["<top (required)>", "<main>", "<compiled>"].freeze #: Array[String]
|
|
38
38
|
|
|
@@ -43,7 +43,7 @@ module Tapioca
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
# @without_runtime
|
|
46
|
-
#: (String symbol, ?inherit: bool, ?namespace: Module) -> BasicObject
|
|
46
|
+
#: (String symbol, ?inherit: bool, ?namespace: T::Module[top]) -> BasicObject
|
|
47
47
|
def constantize(symbol, inherit: false, namespace: Object)
|
|
48
48
|
namespace.const_get(symbol, inherit)
|
|
49
49
|
rescue NameError, LoadError, RuntimeError, ArgumentError, TypeError
|
|
@@ -55,23 +55,23 @@ module Tapioca
|
|
|
55
55
|
CLASS_METHOD.bind_call(object)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
#: (Module constant) -> Array[Symbol]
|
|
58
|
+
#: (T::Module[top] constant) -> Array[Symbol]
|
|
59
59
|
def constants_of(constant)
|
|
60
60
|
CONSTANTS_METHOD.bind_call(constant, false)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
#: (Module constant) -> String?
|
|
63
|
+
#: (T::Module[top] constant) -> String?
|
|
64
64
|
def name_of(constant)
|
|
65
65
|
name = NAME_METHOD.bind_call(constant)
|
|
66
66
|
name&.start_with?("#<") ? nil : name
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
#: (Module constant) -> Class[top]
|
|
69
|
+
#: (T::Module[top] constant) -> Class[top]
|
|
70
70
|
def singleton_class_of(constant)
|
|
71
71
|
SINGLETON_CLASS_METHOD.bind_call(constant)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
#: (Module constant) -> Array[Module]
|
|
74
|
+
#: (T::Module[top] constant) -> Array[T::Module[top]]
|
|
75
75
|
def ancestors_of(constant)
|
|
76
76
|
ANCESTORS_METHOD.bind_call(constant)
|
|
77
77
|
end
|
|
@@ -91,22 +91,22 @@ module Tapioca
|
|
|
91
91
|
EQUAL_METHOD.bind_call(object, other)
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
#: (Module constant) -> Array[Symbol]
|
|
94
|
+
#: (T::Module[top] constant) -> Array[Symbol]
|
|
95
95
|
def public_instance_methods_of(constant)
|
|
96
96
|
PUBLIC_INSTANCE_METHODS_METHOD.bind_call(constant)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
#: (Module constant) -> Array[Symbol]
|
|
99
|
+
#: (T::Module[top] constant) -> Array[Symbol]
|
|
100
100
|
def protected_instance_methods_of(constant)
|
|
101
101
|
PROTECTED_INSTANCE_METHODS_METHOD.bind_call(constant)
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
-
#: (Module constant) -> Array[Symbol]
|
|
104
|
+
#: (T::Module[top] constant) -> Array[Symbol]
|
|
105
105
|
def private_instance_methods_of(constant)
|
|
106
106
|
PRIVATE_INSTANCE_METHODS_METHOD.bind_call(constant)
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
-
#: (Module constant) -> Array[Module]
|
|
109
|
+
#: (T::Module[top] constant) -> Array[T::Module[top]]
|
|
110
110
|
def inherited_ancestors_of(constant)
|
|
111
111
|
if Class === constant
|
|
112
112
|
ancestors_of(superclass_of(constant) || Object)
|
|
@@ -115,7 +115,7 @@ module Tapioca
|
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
-
#: (Module constant) -> String?
|
|
118
|
+
#: (T::Module[top] constant) -> String?
|
|
119
119
|
def qualified_name_of(constant)
|
|
120
120
|
name = name_of(constant)
|
|
121
121
|
return if name.nil?
|
|
@@ -148,7 +148,7 @@ module Tapioca
|
|
|
148
148
|
type.to_s
|
|
149
149
|
end
|
|
150
150
|
|
|
151
|
-
#: (Module constant, Symbol method) -> Method
|
|
151
|
+
#: (T::Module[top] constant, Symbol method) -> Method
|
|
152
152
|
def method_of(constant, method)
|
|
153
153
|
METHOD_METHOD.bind_call(constant, method)
|
|
154
154
|
end
|
|
@@ -217,32 +217,32 @@ module Tapioca
|
|
|
217
217
|
SourceLocation.from_loc([file, resolved_loc.lineno])
|
|
218
218
|
end
|
|
219
219
|
|
|
220
|
-
#: (Module constant) -> Set[String]
|
|
220
|
+
#: (T::Module[top] constant) -> Set[String]
|
|
221
221
|
def file_candidates_for(constant)
|
|
222
222
|
relevant_methods_for(constant).filter_map do |method|
|
|
223
223
|
method.source_location&.first
|
|
224
224
|
end.to_set
|
|
225
225
|
end
|
|
226
226
|
|
|
227
|
-
#: (Module constant) -> untyped
|
|
227
|
+
#: (T::Module[top] constant) -> untyped
|
|
228
228
|
def abstract_type_of(constant)
|
|
229
229
|
T::Private::Abstract::Data.get(constant, :abstract_type) ||
|
|
230
230
|
T::Private::Abstract::Data.get(singleton_class_of(constant), :abstract_type)
|
|
231
231
|
end
|
|
232
232
|
|
|
233
|
-
#: (Module constant) -> bool
|
|
233
|
+
#: (T::Module[top] constant) -> bool
|
|
234
234
|
def final_module?(constant)
|
|
235
235
|
T::Private::Final.final_module?(constant)
|
|
236
236
|
end
|
|
237
237
|
|
|
238
|
-
#: (Module constant) -> bool
|
|
238
|
+
#: (T::Module[top] constant) -> bool
|
|
239
239
|
def sealed_module?(constant)
|
|
240
240
|
T::Private::Sealed.sealed_module?(constant)
|
|
241
241
|
end
|
|
242
242
|
|
|
243
243
|
private
|
|
244
244
|
|
|
245
|
-
#: (Module constant) -> Array[UnboundMethod]
|
|
245
|
+
#: (T::Module[top] constant) -> Array[UnboundMethod]
|
|
246
246
|
def relevant_methods_for(constant)
|
|
247
247
|
methods = methods_for(constant).select(&:source_location)
|
|
248
248
|
.reject { |x| method_defined_by_forwardable_module?(x) }
|
|
@@ -258,7 +258,7 @@ module Tapioca
|
|
|
258
258
|
end
|
|
259
259
|
end
|
|
260
260
|
|
|
261
|
-
#: (Module constant) -> Array[UnboundMethod]
|
|
261
|
+
#: (T::Module[top] constant) -> Array[UnboundMethod]
|
|
262
262
|
def methods_for(constant)
|
|
263
263
|
modules = [constant, singleton_class_of(constant)]
|
|
264
264
|
method_list_methods = [
|
|
@@ -272,7 +272,7 @@ module Tapioca
|
|
|
272
272
|
end
|
|
273
273
|
end
|
|
274
274
|
|
|
275
|
-
#: (Module parent, String name) -> Module?
|
|
275
|
+
#: (T::Module[top] parent, String name) -> T::Module[top]?
|
|
276
276
|
def child_module_for_parent_with_name(parent, name)
|
|
277
277
|
return if parent.autoload?(name)
|
|
278
278
|
|
|
@@ -15,7 +15,7 @@ module Tapioca
|
|
|
15
15
|
|
|
16
16
|
#: -> void
|
|
17
17
|
def eager_load_all!
|
|
18
|
-
|
|
18
|
+
Runtime.with_disabled_exits do
|
|
19
19
|
until @constant_names_registered_for_autoload.empty?
|
|
20
20
|
# Grab the next constant name
|
|
21
21
|
constant_name = T.must(@constant_names_registered_for_autoload.shift)
|
|
@@ -13,7 +13,7 @@ module Tapioca
|
|
|
13
13
|
extend Reflection
|
|
14
14
|
extend T::Sig
|
|
15
15
|
|
|
16
|
-
@class_files = {}.compare_by_identity #: Hash[Module, Set[SourceLocation]]
|
|
16
|
+
@class_files = {}.compare_by_identity #: Hash[T::Module[top], Set[SourceLocation]]
|
|
17
17
|
|
|
18
18
|
# Immediately activated upon load. Observes class/module definition.
|
|
19
19
|
@class_tracepoint = TracePoint.trace(:class) do |tp|
|
|
@@ -70,12 +70,12 @@ module Tapioca
|
|
|
70
70
|
# Returns the files in which this class or module was opened. Doesn't know
|
|
71
71
|
# about situations where the class was opened prior to +require+ing,
|
|
72
72
|
# or where metaprogramming was used via +eval+, etc.
|
|
73
|
-
#: (Module klass) -> Set[String]
|
|
73
|
+
#: (T::Module[top] klass) -> Set[String]
|
|
74
74
|
def files_for(klass)
|
|
75
75
|
locations_for(klass).map(&:file).to_set
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
#: (Module klass) -> Set[SourceLocation]
|
|
78
|
+
#: (T::Module[top] klass) -> Set[SourceLocation]
|
|
79
79
|
def locations_for(klass)
|
|
80
80
|
@class_files.fetch(klass, Set.new)
|
|
81
81
|
end
|
|
@@ -8,10 +8,10 @@ module Tapioca
|
|
|
8
8
|
extend Tracker
|
|
9
9
|
extend T::Sig
|
|
10
10
|
|
|
11
|
-
@method_definitions = {}.compare_by_identity #: Hash[Module, Hash[Symbol, Array[SourceLocation]]]
|
|
11
|
+
@method_definitions = {}.compare_by_identity #: Hash[T::Module[top], Hash[Symbol, Array[SourceLocation]]]
|
|
12
12
|
|
|
13
13
|
class << self
|
|
14
|
-
#: (Symbol method_name, Module owner, Array[Thread::Backtrace::Location] locations) -> void
|
|
14
|
+
#: (Symbol method_name, T::Module[top] owner, Array[Thread::Backtrace::Location] locations) -> void
|
|
15
15
|
def register(method_name, owner, locations)
|
|
16
16
|
return unless enabled?
|
|
17
17
|
# If Sorbet runtime is redefining a method, it sets this to true.
|
|
@@ -25,7 +25,7 @@ module Tapioca
|
|
|
25
25
|
registrations_for(method_name, owner) << loc
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
#: (Symbol method_name, Module owner) -> Array[SourceLocation]
|
|
28
|
+
#: (Symbol method_name, T::Module[top] owner) -> Array[SourceLocation]
|
|
29
29
|
def method_definitions_for(method_name, owner)
|
|
30
30
|
definitions = registrations_for(method_name, owner)
|
|
31
31
|
|
|
@@ -39,7 +39,7 @@ module Tapioca
|
|
|
39
39
|
|
|
40
40
|
private
|
|
41
41
|
|
|
42
|
-
#: (Symbol method_name, Module owner) -> Array[SourceLocation]
|
|
42
|
+
#: (Symbol method_name, T::Module[top] owner) -> Array[SourceLocation]
|
|
43
43
|
def registrations_for(method_name, owner)
|
|
44
44
|
owner_lookup = (@method_definitions[owner] ||= {})
|
|
45
45
|
owner_lookup[method_name] ||= []
|
|
@@ -27,7 +27,7 @@ module Tapioca
|
|
|
27
27
|
with_disabled_tracker(&block)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
#: (Module constant, Module mixin, Type mixin_type) -> void
|
|
30
|
+
#: (T::Module[top] constant, T::Module[top] mixin, Type mixin_type) -> void
|
|
31
31
|
def register(constant, mixin, mixin_type)
|
|
32
32
|
return unless enabled?
|
|
33
33
|
|
|
@@ -49,19 +49,19 @@ module Tapioca
|
|
|
49
49
|
attached_class
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
#: (Module mixin) -> Hash[Type, Hash[Module, String]]
|
|
52
|
+
#: (T::Module[top] mixin) -> Hash[Type, Hash[T::Module[top], String]]
|
|
53
53
|
def constants_with_mixin(mixin)
|
|
54
54
|
find_or_initialize_mixin_lookup(mixin)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
#: (Module mixin, Type mixin_type, Module constant) -> String?
|
|
57
|
+
#: (T::Module[top] mixin, Type mixin_type, T::Module[top] constant) -> String?
|
|
58
58
|
def mixin_location(mixin, mixin_type, constant)
|
|
59
59
|
find_or_initialize_mixin_lookup(mixin).dig(mixin_type, constant)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
private
|
|
63
63
|
|
|
64
|
-
#: (Module constant, Module mixin, Type mixin_type, String location) -> void
|
|
64
|
+
#: (T::Module[top] constant, T::Module[top] mixin, Type mixin_type, String location) -> void
|
|
65
65
|
def register_with_location(constant, mixin, mixin_type, location)
|
|
66
66
|
return unless @enabled
|
|
67
67
|
|
|
@@ -69,7 +69,7 @@ module Tapioca
|
|
|
69
69
|
constants.fetch(mixin_type).store(constant, location)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
#: (Module mixin) -> Hash[Type, Hash[Module, String]]
|
|
72
|
+
#: (T::Module[top] mixin) -> Hash[Type, Hash[T::Module[top], String]]
|
|
73
73
|
def find_or_initialize_mixin_lookup(mixin)
|
|
74
74
|
@mixins_to_constants[mixin] ||= {
|
|
75
75
|
Type::Prepend => {}.compare_by_identity,
|
|
@@ -19,12 +19,12 @@ module Tapioca
|
|
|
19
19
|
ancestors << block
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
#: (Module mod) -> Array[^-> void]
|
|
22
|
+
#: (T::Module[top] mod) -> Array[^-> void]
|
|
23
23
|
def required_ancestors_blocks_by(mod)
|
|
24
24
|
@required_ancestors_map[mod] || []
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
#: (Module mod) -> Array[untyped]
|
|
27
|
+
#: (T::Module[top] mod) -> Array[untyped]
|
|
28
28
|
def required_ancestors_by(mod)
|
|
29
29
|
blocks = required_ancestors_blocks_by(mod)
|
|
30
30
|
blocks.map do |block|
|
|
@@ -52,7 +52,7 @@ end
|
|
|
52
52
|
|
|
53
53
|
module T
|
|
54
54
|
module Helpers
|
|
55
|
-
prepend(Module.new do
|
|
55
|
+
prepend(::Module.new do
|
|
56
56
|
def requires_ancestor(&block)
|
|
57
57
|
# We can't directly call the block since the ancestor might not be loaded yet.
|
|
58
58
|
# We save the block in the map and will resolve it later.
|
|
@@ -22,7 +22,7 @@ module T
|
|
|
22
22
|
# `T::Generic#type_member` just instantiates a `T::Type::TypeMember` instance and returns it.
|
|
23
23
|
# We use that when registering the type member and then later return it from this method.
|
|
24
24
|
Tapioca::TypeVariableModule.new(
|
|
25
|
-
T.cast(self, Module),
|
|
25
|
+
T.cast(self, ::Module),
|
|
26
26
|
Tapioca::TypeVariableModule::Type::Member,
|
|
27
27
|
variance,
|
|
28
28
|
bounds_proc,
|
|
@@ -35,7 +35,7 @@ module T
|
|
|
35
35
|
# `T::Generic#type_template` just instantiates a `T::Type::TypeTemplate` instance and returns it.
|
|
36
36
|
# We use that when registering the type template and then later return it from this method.
|
|
37
37
|
Tapioca::TypeVariableModule.new(
|
|
38
|
-
T.cast(self, Module),
|
|
38
|
+
T.cast(self, ::Module),
|
|
39
39
|
Tapioca::TypeVariableModule::Type::Template,
|
|
40
40
|
variance,
|
|
41
41
|
bounds_proc,
|
|
@@ -48,7 +48,7 @@ module T
|
|
|
48
48
|
Tapioca::Runtime::GenericTypeRegistry.register_type_variable(
|
|
49
49
|
self,
|
|
50
50
|
Tapioca::TypeVariableModule.new(
|
|
51
|
-
T.cast(self, Module),
|
|
51
|
+
T.cast(self, ::Module),
|
|
52
52
|
Tapioca::TypeVariableModule::Type::HasAttachedClass,
|
|
53
53
|
variance,
|
|
54
54
|
bounds_proc,
|
|
@@ -135,7 +135,7 @@ module Tapioca
|
|
|
135
135
|
#: Type
|
|
136
136
|
attr_reader :type
|
|
137
137
|
|
|
138
|
-
#: (Module context, Type type, Symbol variance, (^-> Hash[Symbol, untyped])? bounds_proc) -> void
|
|
138
|
+
#: (T::Module[top] context, Type type, Symbol variance, (^-> Hash[Symbol, untyped])? bounds_proc) -> void
|
|
139
139
|
def initialize(context, type, variance, bounds_proc)
|
|
140
140
|
@context = context
|
|
141
141
|
@type = type
|
|
@@ -5,24 +5,13 @@ module T
|
|
|
5
5
|
module Types
|
|
6
6
|
class Simple
|
|
7
7
|
module NamePatch
|
|
8
|
-
NAME_METHOD = Module.instance_method(:name) #: UnboundMethod
|
|
9
|
-
|
|
10
8
|
def name
|
|
11
9
|
# Sorbet memoizes this method into the `@name` instance variable but
|
|
12
10
|
# doing so means that types get memoized before this patch is applied
|
|
13
|
-
qualified_name_of(@raw_type)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def qualified_name_of(constant)
|
|
17
|
-
name = NAME_METHOD.bind_call(constant)
|
|
18
|
-
name = nil if name&.start_with?("#<")
|
|
19
|
-
return "::T.untyped" if name.nil?
|
|
11
|
+
name = Tapioca::Runtime::Reflection.qualified_name_of(@raw_type)
|
|
12
|
+
name = "::T.untyped" if name.nil?
|
|
20
13
|
|
|
21
|
-
|
|
22
|
-
name
|
|
23
|
-
else
|
|
24
|
-
"::#{name}"
|
|
25
|
-
end
|
|
14
|
+
name
|
|
26
15
|
end
|
|
27
16
|
end
|
|
28
17
|
|
|
@@ -40,7 +40,7 @@ module Tapioca
|
|
|
40
40
|
end.sort.uniq
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
#: (String file_path) ->
|
|
43
|
+
#: (String file_path) -> Enumerable[String]
|
|
44
44
|
def collect_requires(file_path)
|
|
45
45
|
File.binread(file_path).lines.filter_map do |line|
|
|
46
46
|
/^\s*require\s*(\(\s*)?['"](?<name>[^'"]+)['"](\s*\))?/.match(line) { |m| m["name"] }
|
data/lib/tapioca/version.rb
CHANGED
data/lib/tapioca.rb
CHANGED
|
@@ -9,42 +9,6 @@ module Tapioca
|
|
|
9
9
|
|
|
10
10
|
@traces = [] #: Array[TracePoint]
|
|
11
11
|
|
|
12
|
-
NOOP_METHOD = ->(*_args, **_kwargs, &_block) {} #: ^() -> void
|
|
13
|
-
private_constant :NOOP_METHOD
|
|
14
|
-
|
|
15
|
-
class << self
|
|
16
|
-
extend T::Sig
|
|
17
|
-
|
|
18
|
-
#: [Result] { -> Result } -> Result
|
|
19
|
-
def silence_warnings(&blk)
|
|
20
|
-
original_verbosity = $VERBOSE
|
|
21
|
-
$VERBOSE = nil
|
|
22
|
-
::Gem::DefaultUserInteraction.use_ui(::Gem::SilentUI.new) do
|
|
23
|
-
blk.call
|
|
24
|
-
end
|
|
25
|
-
ensure
|
|
26
|
-
$VERBOSE = original_verbosity
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
#: [Result] { -> Result } -> Result
|
|
30
|
-
def with_disabled_exits(&block)
|
|
31
|
-
original_abort = Kernel.instance_method(:abort)
|
|
32
|
-
original_exit = Kernel.instance_method(:exit)
|
|
33
|
-
|
|
34
|
-
begin
|
|
35
|
-
Kernel.define_method(:abort, NOOP_METHOD)
|
|
36
|
-
Kernel.define_method(:exit, NOOP_METHOD)
|
|
37
|
-
|
|
38
|
-
Tapioca.silence_warnings do
|
|
39
|
-
block.call
|
|
40
|
-
end
|
|
41
|
-
ensure
|
|
42
|
-
Kernel.define_method(:exit, original_exit)
|
|
43
|
-
Kernel.define_method(:abort, original_abort)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
12
|
class Error < StandardError; end
|
|
49
13
|
|
|
50
14
|
LIB_ROOT_DIR = T.must(__dir__) #: String
|
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.17.
|
|
4
|
+
version: 0.17.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ufuk Kayserilioglu
|
|
@@ -69,89 +69,89 @@ dependencies:
|
|
|
69
69
|
- !ruby/object:Gem::Version
|
|
70
70
|
version: 1.21.0
|
|
71
71
|
- !ruby/object:Gem::Dependency
|
|
72
|
-
name:
|
|
72
|
+
name: require-hooks
|
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
|
74
74
|
requirements:
|
|
75
75
|
- - ">="
|
|
76
76
|
- !ruby/object:Gem::Version
|
|
77
|
-
version: 0.
|
|
77
|
+
version: 0.2.2
|
|
78
78
|
type: :runtime
|
|
79
79
|
prerelease: false
|
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
|
81
81
|
requirements:
|
|
82
82
|
- - ">="
|
|
83
83
|
- !ruby/object:Gem::Version
|
|
84
|
-
version: 0.
|
|
84
|
+
version: 0.2.2
|
|
85
85
|
- !ruby/object:Gem::Dependency
|
|
86
|
-
name:
|
|
86
|
+
name: sorbet-static-and-runtime
|
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
|
88
88
|
requirements:
|
|
89
89
|
- - ">="
|
|
90
90
|
- !ruby/object:Gem::Version
|
|
91
|
-
version: 0.
|
|
91
|
+
version: 0.5.11087
|
|
92
92
|
type: :runtime
|
|
93
93
|
prerelease: false
|
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
|
95
95
|
requirements:
|
|
96
96
|
- - ">="
|
|
97
97
|
- !ruby/object:Gem::Version
|
|
98
|
-
version: 0.
|
|
98
|
+
version: 0.5.11087
|
|
99
99
|
- !ruby/object:Gem::Dependency
|
|
100
|
-
name:
|
|
100
|
+
name: thor
|
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
|
102
102
|
requirements:
|
|
103
103
|
- - ">="
|
|
104
104
|
- !ruby/object:Gem::Version
|
|
105
|
-
version:
|
|
105
|
+
version: 1.2.0
|
|
106
106
|
type: :runtime
|
|
107
107
|
prerelease: false
|
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
|
109
109
|
requirements:
|
|
110
110
|
- - ">="
|
|
111
111
|
- !ruby/object:Gem::Version
|
|
112
|
-
version:
|
|
112
|
+
version: 1.2.0
|
|
113
113
|
- !ruby/object:Gem::Dependency
|
|
114
|
-
name:
|
|
114
|
+
name: yard-sorbet
|
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
|
116
116
|
requirements:
|
|
117
117
|
- - ">="
|
|
118
118
|
- !ruby/object:Gem::Version
|
|
119
|
-
version:
|
|
119
|
+
version: '0'
|
|
120
120
|
type: :runtime
|
|
121
121
|
prerelease: false
|
|
122
122
|
version_requirements: !ruby/object:Gem::Requirement
|
|
123
123
|
requirements:
|
|
124
124
|
- - ">="
|
|
125
125
|
- !ruby/object:Gem::Version
|
|
126
|
-
version:
|
|
126
|
+
version: '0'
|
|
127
127
|
- !ruby/object:Gem::Dependency
|
|
128
|
-
name:
|
|
128
|
+
name: rbi
|
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|
|
130
130
|
requirements:
|
|
131
131
|
- - ">="
|
|
132
132
|
- !ruby/object:Gem::Version
|
|
133
|
-
version:
|
|
133
|
+
version: 0.3.7
|
|
134
134
|
type: :runtime
|
|
135
135
|
prerelease: false
|
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
|
137
137
|
requirements:
|
|
138
138
|
- - ">="
|
|
139
139
|
- !ruby/object:Gem::Version
|
|
140
|
-
version:
|
|
140
|
+
version: 0.3.7
|
|
141
141
|
- !ruby/object:Gem::Dependency
|
|
142
|
-
name:
|
|
142
|
+
name: spoom
|
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|
|
144
144
|
requirements:
|
|
145
145
|
- - ">="
|
|
146
146
|
- !ruby/object:Gem::Version
|
|
147
|
-
version:
|
|
147
|
+
version: 1.7.9
|
|
148
148
|
type: :runtime
|
|
149
149
|
prerelease: false
|
|
150
150
|
version_requirements: !ruby/object:Gem::Requirement
|
|
151
151
|
requirements:
|
|
152
152
|
- - ">="
|
|
153
153
|
- !ruby/object:Gem::Version
|
|
154
|
-
version:
|
|
154
|
+
version: 1.7.9
|
|
155
155
|
email:
|
|
156
156
|
- ruby@shopify.com
|
|
157
157
|
executables:
|
|
@@ -280,6 +280,7 @@ files:
|
|
|
280
280
|
- lib/tapioca/runtime/attached_class_of_legacy.rb
|
|
281
281
|
- lib/tapioca/runtime/dynamic_mixin_compiler.rb
|
|
282
282
|
- lib/tapioca/runtime/generic_type_registry.rb
|
|
283
|
+
- lib/tapioca/runtime/helpers.rb
|
|
283
284
|
- lib/tapioca/runtime/reflection.rb
|
|
284
285
|
- lib/tapioca/runtime/source_location.rb
|
|
285
286
|
- lib/tapioca/runtime/trackers.rb
|