tapioca 0.19.0 → 0.19.2
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 +69 -27
- data/lib/tapioca/cli.rb +11 -1
- data/lib/tapioca/commands/abstract_dsl.rb +6 -1
- data/lib/tapioca/commands/check_shims.rb +3 -0
- data/lib/tapioca/commands/configure.rb +1 -0
- data/lib/tapioca/commands/dsl_generate.rb +15 -0
- data/lib/tapioca/commands/todo.rb +8 -2
- data/lib/tapioca/dsl/compiler.rb +13 -13
- data/lib/tapioca/dsl/compilers/aasm.rb +1 -1
- 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 +1 -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 +1 -1
- data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +65 -17
- data/lib/tapioca/dsl/compilers/active_record_enum.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +1 -1
- 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_environment_inquirer.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 +1 -1
- 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/graphql_type_helper.rb +4 -2
- data/lib/tapioca/dsl/pipeline.rb +13 -37
- data/lib/tapioca/gem/events.rb +7 -7
- data/lib/tapioca/gem/listeners/methods.rb +8 -8
- data/lib/tapioca/gem/listeners/mixins.rb +3 -3
- data/lib/tapioca/gem/listeners/sorbet_signatures.rb +5 -3
- data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +1 -1
- data/lib/tapioca/gem/pipeline.rb +18 -18
- data/lib/tapioca/helpers/sorbet_helper.rb +19 -0
- data/lib/tapioca/helpers/test/dsl_compiler.rb +2 -9
- data/lib/tapioca/internal.rb +2 -0
- data/lib/tapioca/rbi_ext/model.rb +8 -5
- data/lib/tapioca/rbs/rewriter.rb +80 -25
- data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +6 -6
- data/lib/tapioca/runtime/generic_type_registry.rb +17 -18
- data/lib/tapioca/runtime/reflection.rb +20 -20
- 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 +2 -2
- data/lib/tapioca/runtime/trackers/tracker.rb +1 -1
- data/lib/tapioca/sorbet_ext/generic_name_patch.rb +1 -21
- data/lib/tapioca/sorbet_ext/generic_type_patch.rb +48 -0
- data/lib/tapioca/sorbet_ext/void_patch.rb +29 -0
- data/lib/tapioca/static/symbol_loader.rb +19 -1
- data/lib/tapioca/version.rb +1 -1
- metadata +8 -6
|
@@ -20,7 +20,7 @@ module Tapioca
|
|
|
20
20
|
PROTECTED_INSTANCE_METHODS_METHOD = Module.instance_method(:protected_instance_methods) #: UnboundMethod
|
|
21
21
|
PRIVATE_INSTANCE_METHODS_METHOD = Module.instance_method(:private_instance_methods) #: UnboundMethod
|
|
22
22
|
METHOD_METHOD = Kernel.instance_method(:method) #: UnboundMethod
|
|
23
|
-
UNDEFINED_CONSTANT = Module.new.freeze #:
|
|
23
|
+
UNDEFINED_CONSTANT = Module.new.freeze #: Module[top]
|
|
24
24
|
|
|
25
25
|
REQUIRED_FROM_LABELS = ["<top (required)>", "<main>", "<compiled>"].freeze #: Array[String]
|
|
26
26
|
|
|
@@ -31,7 +31,7 @@ module Tapioca
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# @without_runtime
|
|
34
|
-
#: (String symbol, ?inherit: bool, ?namespace:
|
|
34
|
+
#: (String symbol, ?inherit: bool, ?namespace: Module[top]) -> BasicObject
|
|
35
35
|
def constantize(symbol, inherit: false, namespace: Object)
|
|
36
36
|
namespace.const_get(symbol, inherit)
|
|
37
37
|
rescue NameError, LoadError, RuntimeError, ArgumentError, TypeError
|
|
@@ -43,23 +43,23 @@ module Tapioca
|
|
|
43
43
|
CLASS_METHOD.bind_call(object)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
#: (
|
|
46
|
+
#: (Module[top] constant) -> Array[Symbol]
|
|
47
47
|
def constants_of(constant)
|
|
48
48
|
CONSTANTS_METHOD.bind_call(constant, false)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
#: (
|
|
51
|
+
#: (Module[top] constant) -> String?
|
|
52
52
|
def name_of(constant)
|
|
53
53
|
name = NAME_METHOD.bind_call(constant)
|
|
54
54
|
name&.start_with?("#<") ? nil : name
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
#: (
|
|
57
|
+
#: (Module[top] constant) -> Class[top]
|
|
58
58
|
def singleton_class_of(constant)
|
|
59
59
|
SINGLETON_CLASS_METHOD.bind_call(constant)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
#: (
|
|
62
|
+
#: (Module[top] constant) -> Array[Module[top]]
|
|
63
63
|
def ancestors_of(constant)
|
|
64
64
|
ANCESTORS_METHOD.bind_call(constant)
|
|
65
65
|
end
|
|
@@ -69,7 +69,7 @@ module Tapioca
|
|
|
69
69
|
SUPERCLASS_METHOD.bind_call(constant)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
#: (Class[top] singleton_class) ->
|
|
72
|
+
#: (Class[top] singleton_class) -> Module[top]?
|
|
73
73
|
def attached_class_of(singleton_class)
|
|
74
74
|
result = singleton_class.attached_object
|
|
75
75
|
Module === result ? result : nil
|
|
@@ -85,22 +85,22 @@ module Tapioca
|
|
|
85
85
|
EQUAL_METHOD.bind_call(object, other)
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
#: (
|
|
88
|
+
#: (Module[top] constant) -> Array[Symbol]
|
|
89
89
|
def public_instance_methods_of(constant)
|
|
90
90
|
PUBLIC_INSTANCE_METHODS_METHOD.bind_call(constant)
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
#: (
|
|
93
|
+
#: (Module[top] constant) -> Array[Symbol]
|
|
94
94
|
def protected_instance_methods_of(constant)
|
|
95
95
|
PROTECTED_INSTANCE_METHODS_METHOD.bind_call(constant)
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
-
#: (
|
|
98
|
+
#: (Module[top] constant) -> Array[Symbol]
|
|
99
99
|
def private_instance_methods_of(constant)
|
|
100
100
|
PRIVATE_INSTANCE_METHODS_METHOD.bind_call(constant)
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
#: (
|
|
103
|
+
#: (Module[top] constant) -> Array[Module[top]]
|
|
104
104
|
def inherited_ancestors_of(constant)
|
|
105
105
|
if Class === constant
|
|
106
106
|
ancestors_of(superclass_of(constant) || Object)
|
|
@@ -109,7 +109,7 @@ module Tapioca
|
|
|
109
109
|
end
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
-
#: (
|
|
112
|
+
#: (Module[top] constant) -> String?
|
|
113
113
|
def qualified_name_of(constant)
|
|
114
114
|
name = name_of(constant)
|
|
115
115
|
return if name.nil?
|
|
@@ -142,7 +142,7 @@ module Tapioca
|
|
|
142
142
|
type.to_s
|
|
143
143
|
end
|
|
144
144
|
|
|
145
|
-
#: (
|
|
145
|
+
#: (Module[top] constant, Symbol method) -> Method
|
|
146
146
|
def method_of(constant, method)
|
|
147
147
|
METHOD_METHOD.bind_call(constant, method)
|
|
148
148
|
end
|
|
@@ -211,7 +211,7 @@ module Tapioca
|
|
|
211
211
|
SourceLocation.from_loc([file, resolved_loc.lineno])
|
|
212
212
|
end
|
|
213
213
|
|
|
214
|
-
#: (
|
|
214
|
+
#: (Module[top] constant) -> Set[String]
|
|
215
215
|
def file_candidates_for(constant)
|
|
216
216
|
# Grab all source files for (relevant) methods defined on the constant
|
|
217
217
|
candidates = relevant_methods_for(constant).filter_map do |method|
|
|
@@ -225,25 +225,25 @@ module Tapioca
|
|
|
225
225
|
candidates
|
|
226
226
|
end
|
|
227
227
|
|
|
228
|
-
#: (
|
|
228
|
+
#: (Module[top] constant) -> untyped
|
|
229
229
|
def abstract_type_of(constant)
|
|
230
230
|
T::Private::Abstract::Data.get(constant, :abstract_type) ||
|
|
231
231
|
T::Private::Abstract::Data.get(singleton_class_of(constant), :abstract_type)
|
|
232
232
|
end
|
|
233
233
|
|
|
234
|
-
#: (
|
|
234
|
+
#: (Module[top] constant) -> bool
|
|
235
235
|
def final_module?(constant)
|
|
236
236
|
T::Private::Final.final_module?(constant)
|
|
237
237
|
end
|
|
238
238
|
|
|
239
|
-
#: (
|
|
239
|
+
#: (Module[top] constant) -> bool
|
|
240
240
|
def sealed_module?(constant)
|
|
241
241
|
T::Private::Sealed.sealed_module?(constant)
|
|
242
242
|
end
|
|
243
243
|
|
|
244
244
|
private
|
|
245
245
|
|
|
246
|
-
#: (
|
|
246
|
+
#: (Module[top] constant) -> Array[UnboundMethod]
|
|
247
247
|
def relevant_methods_for(constant)
|
|
248
248
|
methods = methods_for(constant).select(&:source_location)
|
|
249
249
|
.reject { |x| method_defined_by_forwardable_module?(x) }
|
|
@@ -259,7 +259,7 @@ module Tapioca
|
|
|
259
259
|
end
|
|
260
260
|
end
|
|
261
261
|
|
|
262
|
-
#: (
|
|
262
|
+
#: (Module[top] constant) -> Array[UnboundMethod]
|
|
263
263
|
def methods_for(constant)
|
|
264
264
|
modules = [constant, singleton_class_of(constant)]
|
|
265
265
|
method_list_methods = [
|
|
@@ -273,7 +273,7 @@ module Tapioca
|
|
|
273
273
|
end
|
|
274
274
|
end
|
|
275
275
|
|
|
276
|
-
#: (
|
|
276
|
+
#: (Module[top] parent, String name) -> Module[top]?
|
|
277
277
|
def child_module_for_parent_with_name(parent, name)
|
|
278
278
|
return if parent.autoload?(name)
|
|
279
279
|
|
|
@@ -12,7 +12,7 @@ module Tapioca
|
|
|
12
12
|
extend Tracker
|
|
13
13
|
extend Reflection
|
|
14
14
|
|
|
15
|
-
@class_files = {}.compare_by_identity #: Hash[
|
|
15
|
+
@class_files = {}.compare_by_identity #: Hash[Module[top], Set[SourceLocation]]
|
|
16
16
|
|
|
17
17
|
# Immediately activated upon load. Observes class/module definition.
|
|
18
18
|
@class_tracepoint = TracePoint.trace(:class) do |tp|
|
|
@@ -83,12 +83,12 @@ module Tapioca
|
|
|
83
83
|
# Returns the files in which this class or module was opened. Doesn't know
|
|
84
84
|
# about situations where the class was opened prior to +require+ing,
|
|
85
85
|
# or where metaprogramming was used via +eval+, etc.
|
|
86
|
-
#: (
|
|
86
|
+
#: (Module[top] klass) -> Set[String]
|
|
87
87
|
def files_for(klass)
|
|
88
88
|
locations_for(klass).map(&:file).to_set
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
-
#: (
|
|
91
|
+
#: (Module[top] klass) -> Set[SourceLocation]
|
|
92
92
|
def locations_for(klass)
|
|
93
93
|
@class_files.fetch(klass, Set.new)
|
|
94
94
|
end
|
|
@@ -7,10 +7,10 @@ module Tapioca
|
|
|
7
7
|
module MethodDefinition
|
|
8
8
|
extend Tracker
|
|
9
9
|
|
|
10
|
-
@method_definitions = {}.compare_by_identity #: Hash[
|
|
10
|
+
@method_definitions = {}.compare_by_identity #: Hash[Module[top], Hash[Symbol, Array[SourceLocation]]]
|
|
11
11
|
|
|
12
12
|
class << self
|
|
13
|
-
#: (Symbol method_name,
|
|
13
|
+
#: (Symbol method_name, Module[top] owner, Array[Thread::Backtrace::Location] locations) -> void
|
|
14
14
|
def register(method_name, owner, locations)
|
|
15
15
|
return unless enabled?
|
|
16
16
|
# If Sorbet runtime is redefining a method, it sets this to true.
|
|
@@ -24,7 +24,7 @@ module Tapioca
|
|
|
24
24
|
registrations_for(method_name, owner) << loc
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
#: (Symbol method_name,
|
|
27
|
+
#: (Symbol method_name, Module[top] owner) -> Array[SourceLocation]
|
|
28
28
|
def method_definitions_for(method_name, owner)
|
|
29
29
|
definitions = registrations_for(method_name, owner)
|
|
30
30
|
|
|
@@ -38,7 +38,7 @@ module Tapioca
|
|
|
38
38
|
|
|
39
39
|
private
|
|
40
40
|
|
|
41
|
-
#: (Symbol method_name,
|
|
41
|
+
#: (Symbol method_name, Module[top] owner) -> Array[SourceLocation]
|
|
42
42
|
def registrations_for(method_name, owner)
|
|
43
43
|
owner_lookup = (@method_definitions[owner] ||= {})
|
|
44
44
|
owner_lookup[method_name] ||= []
|
|
@@ -24,7 +24,7 @@ module Tapioca
|
|
|
24
24
|
with_disabled_tracker(&block)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
#: (
|
|
27
|
+
#: (Module[top] constant, Module[top] mixin, Type mixin_type) -> void
|
|
28
28
|
def register(constant, mixin, mixin_type)
|
|
29
29
|
return unless enabled?
|
|
30
30
|
|
|
@@ -46,19 +46,19 @@ module Tapioca
|
|
|
46
46
|
attached_class
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
#: (
|
|
49
|
+
#: (Module[top] mixin) -> Hash[Type, Hash[Module[top], String]]
|
|
50
50
|
def constants_with_mixin(mixin)
|
|
51
51
|
find_or_initialize_mixin_lookup(mixin)
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
#: (
|
|
54
|
+
#: (Module[top] mixin, Type mixin_type, Module[top] constant) -> String?
|
|
55
55
|
def mixin_location(mixin, mixin_type, constant)
|
|
56
56
|
find_or_initialize_mixin_lookup(mixin).dig(mixin_type, constant)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
private
|
|
60
60
|
|
|
61
|
-
#: (
|
|
61
|
+
#: (Module[top] constant, Module[top] mixin, Type mixin_type, String location) -> void
|
|
62
62
|
def register_with_location(constant, mixin, mixin_type, location)
|
|
63
63
|
return unless @enabled
|
|
64
64
|
|
|
@@ -66,7 +66,7 @@ module Tapioca
|
|
|
66
66
|
constants.fetch(mixin_type).store(constant, location)
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
#: (
|
|
69
|
+
#: (Module[top] mixin) -> Hash[Type, Hash[Module[top], String]]
|
|
70
70
|
def find_or_initialize_mixin_lookup(mixin)
|
|
71
71
|
@mixins_to_constants[mixin] ||= {
|
|
72
72
|
Type::Prepend => {}.compare_by_identity,
|
|
@@ -17,12 +17,12 @@ module Tapioca
|
|
|
17
17
|
ancestors << block
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
#: (
|
|
20
|
+
#: (Module[top] mod) -> Array[^-> void]
|
|
21
21
|
def required_ancestors_blocks_by(mod)
|
|
22
22
|
@required_ancestors_map[mod] || []
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
#: (
|
|
25
|
+
#: (Module[top] mod) -> Array[untyped]
|
|
26
26
|
def required_ancestors_by(mod)
|
|
27
27
|
blocks = required_ancestors_blocks_by(mod)
|
|
28
28
|
blocks.map do |block|
|
|
@@ -82,26 +82,6 @@ module T
|
|
|
82
82
|
prepend GenericPatch
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
|
-
|
|
86
|
-
module Utils
|
|
87
|
-
module Private
|
|
88
|
-
module PrivateCoercePatch
|
|
89
|
-
def coerce_and_check_module_types(val, check_val, check_module_type)
|
|
90
|
-
if val.is_a?(Tapioca::TypeVariableModule)
|
|
91
|
-
val.coerce_to_type_variable
|
|
92
|
-
elsif val.respond_to?(:__tapioca_override_type)
|
|
93
|
-
val.__tapioca_override_type
|
|
94
|
-
else
|
|
95
|
-
super
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
class << self
|
|
101
|
-
prepend(PrivateCoercePatch)
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
85
|
end
|
|
106
86
|
|
|
107
87
|
module Tapioca
|
|
@@ -133,7 +113,7 @@ module Tapioca
|
|
|
133
113
|
#: Type
|
|
134
114
|
attr_reader :type
|
|
135
115
|
|
|
136
|
-
#: (
|
|
116
|
+
#: (Module[top] context, Type type, Symbol variance, (^-> Hash[Symbol, untyped])? bounds_proc) -> void
|
|
137
117
|
def initialize(context, type, variance, bounds_proc)
|
|
138
118
|
@context = context
|
|
139
119
|
@type = type
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module T
|
|
5
|
+
module Utils
|
|
6
|
+
module Private
|
|
7
|
+
# Preserve Tapioca's generic type variables and instantiated generic
|
|
8
|
+
# names when Sorbet coerces them into runtime types.
|
|
9
|
+
module TapiocaGenericTypeCoercePatch
|
|
10
|
+
def coerce_and_check_module_types(val, check_val, check_module_type)
|
|
11
|
+
if val.is_a?(Tapioca::TypeVariableModule)
|
|
12
|
+
val.coerce_to_type_variable
|
|
13
|
+
elsif val.respond_to?(:__tapioca_override_type)
|
|
14
|
+
val.__tapioca_override_type
|
|
15
|
+
else
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class << self
|
|
22
|
+
prepend(TapiocaGenericTypeCoercePatch)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
module Private
|
|
28
|
+
module Casts
|
|
29
|
+
module TapiocaGenericTypeCastPatch
|
|
30
|
+
# https://github.com/sorbet/sorbet/commit/b8d64c7fd9a08e2b9159b5d592bc2de6d586b44a
|
|
31
|
+
# inlines the Module fast path in `T.let`, `T.cast`, `T.bind`, and
|
|
32
|
+
# `T.assert_type!`, so generic module clones can reach this cast path
|
|
33
|
+
# without going through `T::Utils::Private::TapiocaGenericTypeCoercePatch`.
|
|
34
|
+
def cast(value, type, cast_method)
|
|
35
|
+
if type.respond_to?(:__tapioca_override_type)
|
|
36
|
+
type = type.__tapioca_override_type
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
super(value, type, cast_method)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class << self
|
|
44
|
+
prepend(TapiocaGenericTypeCastPatch)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# If Signature has `effective_return_type`, then `return_type` always returns the correct type.
|
|
5
|
+
# Ref: https://github.com/sorbet/sorbet/pull/10121
|
|
6
|
+
return if T::Private::Methods::Signature.method_defined?(:effective_return_type)
|
|
7
|
+
|
|
8
|
+
module T
|
|
9
|
+
module Private
|
|
10
|
+
module Methods
|
|
11
|
+
module DeclBuilderPatch
|
|
12
|
+
def void
|
|
13
|
+
super.tap do
|
|
14
|
+
@_real_returns_is_void = true
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def finalize!
|
|
19
|
+
super.tap do
|
|
20
|
+
#: self as untyped
|
|
21
|
+
decl.returns = T::Private::Types::Void::Private::INSTANCE if @_real_returns_is_void
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
DeclBuilder.prepend(DeclBuilderPatch)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -87,7 +87,25 @@ module Tapioca
|
|
|
87
87
|
|
|
88
88
|
#: (String input, ?table_type: String) -> String
|
|
89
89
|
def symbol_table_json_from(input, table_type: "symbol-table-json")
|
|
90
|
-
|
|
90
|
+
supported_values = ["symbol-table-json", "symbol-table-full-json"]
|
|
91
|
+
unless supported_values.include?(table_type)
|
|
92
|
+
raise NotImplementedError, <<~MSG
|
|
93
|
+
Got an unsupported value for `table_type` (#{table_type.inspect}).
|
|
94
|
+
The only supported values are:
|
|
95
|
+
#{supported_values.map { |v| "- #{v}" }.join("\n")}
|
|
96
|
+
|
|
97
|
+
This is because we use `--stop-after=namer` as a performance optimization. Other print formats
|
|
98
|
+
may require running later stages of Sorbet's pipeline. Please adjust the `stop-after` accordingly.
|
|
99
|
+
MSG
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
sorbet(
|
|
103
|
+
"--no-config",
|
|
104
|
+
"--quiet",
|
|
105
|
+
"--print=#{table_type}",
|
|
106
|
+
"--stop-after=namer",
|
|
107
|
+
input,
|
|
108
|
+
).out
|
|
91
109
|
end
|
|
92
110
|
end
|
|
93
111
|
end
|
data/lib/tapioca/version.rb
CHANGED
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.19.
|
|
4
|
+
version: 0.19.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ufuk Kayserilioglu
|
|
@@ -102,14 +102,14 @@ dependencies:
|
|
|
102
102
|
requirements:
|
|
103
103
|
- - ">="
|
|
104
104
|
- !ruby/object:Gem::Version
|
|
105
|
-
version: 0.
|
|
105
|
+
version: 0.6.12698
|
|
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: 0.
|
|
112
|
+
version: 0.6.12698
|
|
113
113
|
- !ruby/object:Gem::Dependency
|
|
114
114
|
name: thor
|
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -144,14 +144,14 @@ dependencies:
|
|
|
144
144
|
requirements:
|
|
145
145
|
- - ">="
|
|
146
146
|
- !ruby/object:Gem::Version
|
|
147
|
-
version: 1.7.
|
|
147
|
+
version: 1.7.16
|
|
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: 1.7.
|
|
154
|
+
version: 1.7.16
|
|
155
155
|
- !ruby/object:Gem::Dependency
|
|
156
156
|
name: tsort
|
|
157
157
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -305,8 +305,10 @@ files:
|
|
|
305
305
|
- lib/tapioca/runtime/trackers/tracker.rb
|
|
306
306
|
- lib/tapioca/sorbet_ext/backcompat_patches.rb
|
|
307
307
|
- lib/tapioca/sorbet_ext/generic_name_patch.rb
|
|
308
|
+
- lib/tapioca/sorbet_ext/generic_type_patch.rb
|
|
308
309
|
- lib/tapioca/sorbet_ext/name_patch.rb
|
|
309
310
|
- lib/tapioca/sorbet_ext/proc_bind_patch.rb
|
|
311
|
+
- lib/tapioca/sorbet_ext/void_patch.rb
|
|
310
312
|
- lib/tapioca/static/requires_compiler.rb
|
|
311
313
|
- lib/tapioca/static/symbol_loader.rb
|
|
312
314
|
- lib/tapioca/static/symbol_table_parser.rb
|
|
@@ -330,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
330
332
|
- !ruby/object:Gem::Version
|
|
331
333
|
version: '0'
|
|
332
334
|
requirements: []
|
|
333
|
-
rubygems_version: 4.0.
|
|
335
|
+
rubygems_version: 4.0.6
|
|
334
336
|
specification_version: 4
|
|
335
337
|
summary: A Ruby Interface file generator for gems, core types and the Ruby standard
|
|
336
338
|
library
|