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
|
@@ -107,7 +107,7 @@ module Tapioca
|
|
|
107
107
|
|
|
108
108
|
class << self
|
|
109
109
|
# @override
|
|
110
|
-
#: -> Enumerable[
|
|
110
|
+
#: -> Enumerable[Module[top]]
|
|
111
111
|
def gather_constants
|
|
112
112
|
descendants_of(::ActiveRecord::Base).select do |klass|
|
|
113
113
|
klass.include?(ActiveRecord::TypedStore::Behavior)
|
|
@@ -38,7 +38,7 @@ module Tapioca
|
|
|
38
38
|
# def photo=(attachable); end
|
|
39
39
|
# end
|
|
40
40
|
# ~~~
|
|
41
|
-
#: [ConstantType = (
|
|
41
|
+
#: [ConstantType = (Module[top] & ::ActiveStorage::Reflection::ActiveRecordExtensions::ClassMethods)]
|
|
42
42
|
class ActiveStorage < Compiler
|
|
43
43
|
# @override
|
|
44
44
|
#: -> void
|
|
@@ -64,7 +64,7 @@ module Tapioca
|
|
|
64
64
|
|
|
65
65
|
class << self
|
|
66
66
|
# @override
|
|
67
|
-
#: -> Enumerable[
|
|
67
|
+
#: -> Enumerable[Module[top]]
|
|
68
68
|
def gather_constants
|
|
69
69
|
descendants_of(::ActiveRecord::Base)
|
|
70
70
|
.reject(&:abstract_class?)
|
|
@@ -37,7 +37,7 @@ module Tapioca
|
|
|
37
37
|
# mixes_in_class_methods(::Foo::ClassMethods)
|
|
38
38
|
# end
|
|
39
39
|
# ~~~
|
|
40
|
-
#: [ConstantType =
|
|
40
|
+
#: [ConstantType = Module[top]]
|
|
41
41
|
class ActiveSupportConcern < Compiler
|
|
42
42
|
# @override
|
|
43
43
|
#: -> void
|
|
@@ -61,7 +61,7 @@ module Tapioca
|
|
|
61
61
|
|
|
62
62
|
class << self
|
|
63
63
|
# @override
|
|
64
|
-
#: -> Enumerable[
|
|
64
|
+
#: -> Enumerable[Module[top]]
|
|
65
65
|
def gather_constants
|
|
66
66
|
all_modules.select do |mod|
|
|
67
67
|
name_of(mod) && # i.e. not anonymous
|
|
@@ -72,10 +72,10 @@ module Tapioca
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
# Returns true when `mod` includes other concerns
|
|
75
|
-
#: (
|
|
75
|
+
#: (Module[top] mod) -> bool
|
|
76
76
|
def has_dependencies?(mod) = dependencies_of(mod).any?
|
|
77
77
|
|
|
78
|
-
#: (
|
|
78
|
+
#: (Module[top] concern) -> Array[Module[top]]
|
|
79
79
|
def dependencies_of(concern)
|
|
80
80
|
concern.instance_variable_get(:@_dependencies) || []
|
|
81
81
|
end
|
|
@@ -83,12 +83,12 @@ module Tapioca
|
|
|
83
83
|
|
|
84
84
|
private
|
|
85
85
|
|
|
86
|
-
#: (
|
|
86
|
+
#: (Module[top] concern) -> Array[Module[top]]
|
|
87
87
|
def dependencies_of(concern)
|
|
88
88
|
self.class.dependencies_of(concern)
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
-
#: (?
|
|
91
|
+
#: (?Module[top] concern) -> Array[Module[top]]
|
|
92
92
|
def linearized_dependencies(concern = constant)
|
|
93
93
|
# Grab all the dependencies of the concern
|
|
94
94
|
dependencies = dependencies_of(concern)
|
|
@@ -40,7 +40,7 @@ module Tapioca
|
|
|
40
40
|
# def github=(value); end
|
|
41
41
|
# end
|
|
42
42
|
# ```
|
|
43
|
-
#: [ConstantType =
|
|
43
|
+
#: [ConstantType = Module[top]]
|
|
44
44
|
class Config < Compiler
|
|
45
45
|
CONFIG_OPTIONS_SUFFIX = "ConfigOptions"
|
|
46
46
|
|
|
@@ -92,7 +92,7 @@ module Tapioca
|
|
|
92
92
|
|
|
93
93
|
class << self
|
|
94
94
|
# @override
|
|
95
|
-
#: -> Enumerable[
|
|
95
|
+
#: -> Enumerable[Module[top]]
|
|
96
96
|
def gather_constants
|
|
97
97
|
name = ::Config.const_name
|
|
98
98
|
return [] unless Object.const_defined?(name)
|
|
@@ -57,7 +57,7 @@ module Tapioca
|
|
|
57
57
|
# ~~~
|
|
58
58
|
#: [ConstantType = singleton(::ActiveRecord::Base)]
|
|
59
59
|
class IdentityCache < Compiler
|
|
60
|
-
COLLECTION_TYPE = ->(type) { "T::Array[::#{type}]" } #: ^((
|
|
60
|
+
COLLECTION_TYPE = ->(type) { "T::Array[::#{type}]" } #: ^((Module[top] | String) type) -> String
|
|
61
61
|
|
|
62
62
|
# @override
|
|
63
63
|
#: -> void
|
|
@@ -91,7 +91,7 @@ module Tapioca
|
|
|
91
91
|
|
|
92
92
|
class << self
|
|
93
93
|
# @override
|
|
94
|
-
#: -> Enumerable[
|
|
94
|
+
#: -> Enumerable[Module[top]]
|
|
95
95
|
def gather_constants
|
|
96
96
|
descendants_of(::ActiveRecord::Base).select do |klass|
|
|
97
97
|
::IdentityCache::WithoutPrimaryIndex > klass
|
|
@@ -44,7 +44,7 @@ module Tapioca
|
|
|
44
44
|
# end
|
|
45
45
|
# end
|
|
46
46
|
# ~~~
|
|
47
|
-
#: [ConstantType =
|
|
47
|
+
#: [ConstantType = Module[top]]
|
|
48
48
|
class MixedInClassAttributes < Compiler
|
|
49
49
|
# @override
|
|
50
50
|
#: -> void
|
|
@@ -59,7 +59,7 @@ module Tapioca
|
|
|
59
59
|
|
|
60
60
|
class << self
|
|
61
61
|
# @override
|
|
62
|
-
#: -> Enumerable[
|
|
62
|
+
#: -> Enumerable[Module[top]]
|
|
63
63
|
def gather_constants
|
|
64
64
|
# Select all non-anonymous modules that have overridden Module.included
|
|
65
65
|
all_modules.select do |mod|
|
|
@@ -109,7 +109,7 @@ module Tapioca
|
|
|
109
109
|
# end
|
|
110
110
|
# end
|
|
111
111
|
# ~~~
|
|
112
|
-
#: [ConstantType = (
|
|
112
|
+
#: [ConstantType = (Module[top] & ::StateMachines::ClassMethods)]
|
|
113
113
|
class StateMachines < Compiler
|
|
114
114
|
# @override
|
|
115
115
|
#: -> void
|
|
@@ -154,7 +154,7 @@ module Tapioca
|
|
|
154
154
|
|
|
155
155
|
class << self
|
|
156
156
|
# @override
|
|
157
|
-
#: -> Enumerable[
|
|
157
|
+
#: -> Enumerable[Module[top]]
|
|
158
158
|
def gather_constants
|
|
159
159
|
all_classes.select { |mod| ::StateMachines::InstanceMethods > mod }
|
|
160
160
|
end
|
|
@@ -78,7 +78,7 @@ module Tapioca
|
|
|
78
78
|
# include GeneratedUrlHelpersModule
|
|
79
79
|
# end
|
|
80
80
|
# ~~~
|
|
81
|
-
#: [ConstantType =
|
|
81
|
+
#: [ConstantType = Module[top]]
|
|
82
82
|
class UrlHelpers < Compiler
|
|
83
83
|
# @override
|
|
84
84
|
#: -> void
|
|
@@ -96,7 +96,7 @@ module Tapioca
|
|
|
96
96
|
|
|
97
97
|
class << self
|
|
98
98
|
# @override
|
|
99
|
-
#: -> Enumerable[
|
|
99
|
+
#: -> Enumerable[Module[top]]
|
|
100
100
|
def gather_constants
|
|
101
101
|
return [] unless defined?(Rails.application) && Rails.application
|
|
102
102
|
|
|
@@ -128,7 +128,7 @@ module Tapioca
|
|
|
128
128
|
constants.concat(NON_DISCOVERABLE_INCLUDERS).push(GeneratedUrlHelpersModule, GeneratedPathHelpersModule)
|
|
129
129
|
end
|
|
130
130
|
|
|
131
|
-
#: -> Array[
|
|
131
|
+
#: -> Array[Module[top]]
|
|
132
132
|
def gather_non_discoverable_includers
|
|
133
133
|
[].tap do |includers|
|
|
134
134
|
if defined?(ActionController::TemplateAssertions) && defined?(ActionDispatch::IntegrationTest)
|
|
@@ -143,7 +143,7 @@ module Tapioca
|
|
|
143
143
|
|
|
144
144
|
# Returns `true` if `mod` "directly" includes `helper`.
|
|
145
145
|
# For classes, this method will return false if the `helper` is included only by a superclass
|
|
146
|
-
#: (
|
|
146
|
+
#: (Module[top] mod, Module[top] helper) -> bool
|
|
147
147
|
private def includes_helper?(mod, helper)
|
|
148
148
|
ancestors = ancestors_of(mod)
|
|
149
149
|
|
|
@@ -158,11 +158,11 @@ module Tapioca
|
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
-
NON_DISCOVERABLE_INCLUDERS = gather_non_discoverable_includers #: Array[
|
|
161
|
+
NON_DISCOVERABLE_INCLUDERS = gather_non_discoverable_includers #: Array[Module[top]]
|
|
162
162
|
|
|
163
163
|
private
|
|
164
164
|
|
|
165
|
-
#: (RBI::Tree root,
|
|
165
|
+
#: (RBI::Tree root, Module[top] constant) -> void
|
|
166
166
|
def generate_module_for(root, constant)
|
|
167
167
|
root.create_module(T.must(constant.name)) do |mod|
|
|
168
168
|
mod.create_include("::ActionDispatch::Routing::UrlFor")
|
|
@@ -178,7 +178,7 @@ module Tapioca
|
|
|
178
178
|
end
|
|
179
179
|
end
|
|
180
180
|
|
|
181
|
-
#: (RBI::Scope mod,
|
|
181
|
+
#: (RBI::Scope mod, Module[top] helper_module) -> void
|
|
182
182
|
def create_mixins_for(mod, helper_module)
|
|
183
183
|
include_helper = constant.ancestors.include?(helper_module) || NON_DISCOVERABLE_INCLUDERS.include?(constant)
|
|
184
184
|
extend_helper = constant.singleton_class.ancestors.include?(helper_module)
|
|
@@ -80,7 +80,9 @@ module Tapioca
|
|
|
80
80
|
signature = Runtime::Reflection.signature_of(method)
|
|
81
81
|
return_type = signature&.return_type
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
# Wrap as non-nilable for required arguments. `coerce_input` supports both
|
|
84
|
+
# required and optional; optional arguments are re-wrapped below based on `type.non_null?`
|
|
85
|
+
valid_return_type?(return_type) ? (T::Utils.unwrap_nilable(return_type) || return_type).to_s : "T.untyped"
|
|
84
86
|
when GraphQL::Schema::InputObject.singleton_class
|
|
85
87
|
type_for_constant(unwrapped_type)
|
|
86
88
|
when Module
|
|
@@ -110,7 +112,7 @@ module Tapioca
|
|
|
110
112
|
|
|
111
113
|
private
|
|
112
114
|
|
|
113
|
-
#: (
|
|
115
|
+
#: (Module[top] constant) -> String
|
|
114
116
|
def type_for_constant(constant)
|
|
115
117
|
if constant.instance_methods.include?(:prepare)
|
|
116
118
|
prepare_method = constant.instance_method(:prepare)
|
data/lib/tapioca/dsl/pipeline.rb
CHANGED
|
@@ -7,13 +7,13 @@ module Tapioca
|
|
|
7
7
|
#: Enumerable[singleton(Compiler)]
|
|
8
8
|
attr_reader :active_compilers
|
|
9
9
|
|
|
10
|
-
#: Array[
|
|
10
|
+
#: Array[Module[top]]
|
|
11
11
|
attr_reader :requested_constants
|
|
12
12
|
|
|
13
13
|
#: Array[Pathname]
|
|
14
14
|
attr_reader :requested_paths
|
|
15
15
|
|
|
16
|
-
#: Array[
|
|
16
|
+
#: Array[Module[top]]
|
|
17
17
|
attr_reader :skipped_constants
|
|
18
18
|
|
|
19
19
|
#: ^(String error) -> void
|
|
@@ -23,12 +23,12 @@ module Tapioca
|
|
|
23
23
|
attr_reader :errors
|
|
24
24
|
|
|
25
25
|
#: (
|
|
26
|
-
#| requested_constants: Array[
|
|
26
|
+
#| requested_constants: Array[Module[top]],
|
|
27
27
|
#| ?requested_paths: Array[Pathname],
|
|
28
28
|
#| ?requested_compilers: Array[singleton(Compiler)],
|
|
29
29
|
#| ?excluded_compilers: Array[singleton(Compiler)],
|
|
30
30
|
#| ?error_handler: ^(String error) -> void,
|
|
31
|
-
#| ?skipped_constants: Array[
|
|
31
|
+
#| ?skipped_constants: Array[Module[top]],
|
|
32
32
|
#| ?number_of_workers: Integer?,
|
|
33
33
|
#| ?compiler_options: Hash[String, untyped],
|
|
34
34
|
#| ?lsp_addon: bool
|
|
@@ -56,7 +56,7 @@ module Tapioca
|
|
|
56
56
|
@errors = [] #: Array[String]
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
#: [R] { (
|
|
59
|
+
#: [R] { (Module[top] constant, RBI::File rbi) -> R } -> Array[R]
|
|
60
60
|
def run(&blk)
|
|
61
61
|
constants_to_process = gather_constants(requested_constants, requested_paths, skipped_constants)
|
|
62
62
|
.select { |c| Module === c } # Filter value constants out
|
|
@@ -128,17 +128,17 @@ module Tapioca
|
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
#: (
|
|
131
|
-
#| Array[
|
|
131
|
+
#| Array[Module[top]] requested_constants,
|
|
132
132
|
#| Array[Pathname] requested_paths,
|
|
133
|
-
#| Array[
|
|
134
|
-
#| ) -> Set[
|
|
133
|
+
#| Array[Module[top]] skipped_constants
|
|
134
|
+
#| ) -> Set[Module[top]]
|
|
135
135
|
def gather_constants(requested_constants, requested_paths, skipped_constants)
|
|
136
136
|
Compiler.requested_constants = requested_constants
|
|
137
137
|
constants = Set.new.compare_by_identity
|
|
138
138
|
active_compilers.each do |compiler|
|
|
139
139
|
constants.merge(compiler.processable_constants)
|
|
140
140
|
end
|
|
141
|
-
constants =
|
|
141
|
+
constants = filter_anonymous_constants(constants)
|
|
142
142
|
constants -= skipped_constants
|
|
143
143
|
|
|
144
144
|
unless requested_constants.empty? && requested_paths.empty?
|
|
@@ -153,36 +153,12 @@ module Tapioca
|
|
|
153
153
|
constants
|
|
154
154
|
end
|
|
155
155
|
|
|
156
|
-
#: (Set[
|
|
157
|
-
def
|
|
158
|
-
|
|
159
|
-
constants_by_name = constants
|
|
160
|
-
.group_by { |c| Runtime::Reflection.name_of(c) }
|
|
161
|
-
.select { |name, _| !name.nil? }
|
|
162
|
-
|
|
163
|
-
constants_by_name = T.cast(constants_by_name, T::Hash[String, T::Array[T::Module[T.anything]]])
|
|
164
|
-
|
|
165
|
-
# Find the constants that have been reloaded
|
|
166
|
-
reloaded_constants = constants_by_name.select { |_, constants| constants.size > 1 }.keys
|
|
167
|
-
|
|
168
|
-
unless reloaded_constants.empty? || @lsp_addon
|
|
169
|
-
reloaded_constant_names = reloaded_constants.map { |name| "`#{name}`" }.join(", ")
|
|
170
|
-
|
|
171
|
-
$stderr.puts("WARNING: Multiple constants with the same name: #{reloaded_constant_names}")
|
|
172
|
-
$stderr.puts("Make sure some object is not holding onto these constants during an app reload.")
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
# Look up all the constants back from their names. The resulting constant set will be the
|
|
176
|
-
# set of constants that are actually in memory with those names.
|
|
177
|
-
filtered_constants = constants_by_name
|
|
178
|
-
.keys
|
|
179
|
-
.map { |name| T.cast(Runtime::Reflection.constantize(name), T::Module[T.anything]) }
|
|
180
|
-
.select { |mod| Runtime::Reflection.constant_defined?(mod) }
|
|
181
|
-
|
|
182
|
-
Set.new.compare_by_identity.merge(filtered_constants)
|
|
156
|
+
#: (Set[Module[top]] constants) -> Set[Module[top]]
|
|
157
|
+
def filter_anonymous_constants(constants)
|
|
158
|
+
constants.keep_if { |constant| Runtime::Reflection.name_of(constant) }
|
|
183
159
|
end
|
|
184
160
|
|
|
185
|
-
#: (
|
|
161
|
+
#: (Module[top] constant) -> RBI::File?
|
|
186
162
|
def rbi_for_constant(constant)
|
|
187
163
|
file = RBI::File.new(strictness: "true")
|
|
188
164
|
|
data/lib/tapioca/gem/events.rb
CHANGED
|
@@ -37,12 +37,12 @@ module Tapioca
|
|
|
37
37
|
|
|
38
38
|
class ForeignConstantFound < ConstantFound
|
|
39
39
|
# @override
|
|
40
|
-
#: ->
|
|
40
|
+
#: -> Module[top]
|
|
41
41
|
def constant
|
|
42
42
|
T.cast(@constant, T::Module[T.anything])
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
#: (String symbol,
|
|
45
|
+
#: (String symbol, Module[top] constant) -> void
|
|
46
46
|
def initialize(symbol, constant)
|
|
47
47
|
super
|
|
48
48
|
end
|
|
@@ -53,10 +53,10 @@ module Tapioca
|
|
|
53
53
|
#: String
|
|
54
54
|
attr_reader :symbol
|
|
55
55
|
|
|
56
|
-
#:
|
|
56
|
+
#: Module[top]
|
|
57
57
|
attr_reader :constant
|
|
58
58
|
|
|
59
|
-
#: (String symbol,
|
|
59
|
+
#: (String symbol, Module[top] constant) -> void
|
|
60
60
|
def initialize(symbol, constant)
|
|
61
61
|
super()
|
|
62
62
|
@symbol = symbol
|
|
@@ -68,7 +68,7 @@ module Tapioca
|
|
|
68
68
|
#: RBI::Const
|
|
69
69
|
attr_reader :node
|
|
70
70
|
|
|
71
|
-
#: (String symbol,
|
|
71
|
+
#: (String symbol, Module[top] constant, RBI::Const node) -> void
|
|
72
72
|
def initialize(symbol, constant, node)
|
|
73
73
|
super(symbol, constant)
|
|
74
74
|
@node = node
|
|
@@ -79,7 +79,7 @@ module Tapioca
|
|
|
79
79
|
#: RBI::Scope
|
|
80
80
|
attr_reader :node
|
|
81
81
|
|
|
82
|
-
#: (String symbol,
|
|
82
|
+
#: (String symbol, Module[top] constant, RBI::Scope node) -> void
|
|
83
83
|
def initialize(symbol, constant, node)
|
|
84
84
|
super(symbol, constant)
|
|
85
85
|
@node = node
|
|
@@ -103,7 +103,7 @@ module Tapioca
|
|
|
103
103
|
|
|
104
104
|
#: (
|
|
105
105
|
#| String symbol,
|
|
106
|
-
#|
|
|
106
|
+
#| Module[top] constant,
|
|
107
107
|
#| UnboundMethod method,
|
|
108
108
|
#| RBI::Method node,
|
|
109
109
|
#| untyped signature,
|
|
@@ -25,9 +25,9 @@ module Tapioca
|
|
|
25
25
|
#: (
|
|
26
26
|
#| RBI::Tree tree,
|
|
27
27
|
#| String module_name,
|
|
28
|
-
#|
|
|
28
|
+
#| Module[top] mod,
|
|
29
29
|
#| ?Array[Symbol] for_visibility,
|
|
30
|
-
#| ?attached_class:
|
|
30
|
+
#| ?attached_class: Module[top]?
|
|
31
31
|
#| ) -> void
|
|
32
32
|
def compile_directly_owned_methods(
|
|
33
33
|
tree,
|
|
@@ -59,7 +59,7 @@ module Tapioca
|
|
|
59
59
|
#: (
|
|
60
60
|
#| RBI::Tree tree,
|
|
61
61
|
#| String symbol_name,
|
|
62
|
-
#|
|
|
62
|
+
#| Module[top] constant,
|
|
63
63
|
#| UnboundMethod? method,
|
|
64
64
|
#| ?RBI::Visibility visibility
|
|
65
65
|
#| ) -> void
|
|
@@ -169,7 +169,7 @@ module Tapioca
|
|
|
169
169
|
# This method implements a better way of checking whether a constant defines a method.
|
|
170
170
|
# It walks up the ancestor tree via the `super_method` method; if any of the super
|
|
171
171
|
# methods are owned by the constant, it means that the constant declares the method.
|
|
172
|
-
#: (UnboundMethod method,
|
|
172
|
+
#: (UnboundMethod method, Module[top] constant) -> bool
|
|
173
173
|
def method_owned_by_constant?(method, constant)
|
|
174
174
|
# Widen the type of `method` to be nilable
|
|
175
175
|
method = method #: UnboundMethod?
|
|
@@ -183,7 +183,7 @@ module Tapioca
|
|
|
183
183
|
false
|
|
184
184
|
end
|
|
185
185
|
|
|
186
|
-
#: (
|
|
186
|
+
#: (Module[top] mod) -> Hash[Symbol, Array[Symbol]]
|
|
187
187
|
def method_names_by_visibility(mod)
|
|
188
188
|
{
|
|
189
189
|
public: public_instance_methods_of(mod),
|
|
@@ -192,7 +192,7 @@ module Tapioca
|
|
|
192
192
|
}
|
|
193
193
|
end
|
|
194
194
|
|
|
195
|
-
#: (
|
|
195
|
+
#: (Module[top] constant, String method_name) -> bool
|
|
196
196
|
def struct_method?(constant, method_name)
|
|
197
197
|
return false unless T::Props::ClassMethods === constant
|
|
198
198
|
|
|
@@ -202,7 +202,7 @@ module Tapioca
|
|
|
202
202
|
.include?(method_name.gsub(/=$/, "").to_sym)
|
|
203
203
|
end
|
|
204
204
|
|
|
205
|
-
#: (
|
|
205
|
+
#: (Module[top]? attached_class, Symbol method_name) -> bool?
|
|
206
206
|
def method_new_in_abstract_class?(attached_class, method_name)
|
|
207
207
|
attached_class &&
|
|
208
208
|
method_name == :new &&
|
|
@@ -210,7 +210,7 @@ module Tapioca
|
|
|
210
210
|
Class === attached_class.singleton_class
|
|
211
211
|
end
|
|
212
212
|
|
|
213
|
-
#: (
|
|
213
|
+
#: (Module[top] constant) -> UnboundMethod?
|
|
214
214
|
def initialize_method_for(constant)
|
|
215
215
|
constant.instance_method(:initialize)
|
|
216
216
|
rescue
|
|
@@ -30,7 +30,7 @@ module Tapioca
|
|
|
30
30
|
add_mixins(node, constant, extends.reverse, Runtime::Trackers::Mixin::Type::Extend)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
#: (RBI::Tree tree,
|
|
33
|
+
#: (RBI::Tree tree, Module[top] constant, Array[Module[top]] mods, Runtime::Trackers::Mixin::Type mixin_type) -> void
|
|
34
34
|
def add_mixins(tree, constant, mods, mixin_type)
|
|
35
35
|
mods
|
|
36
36
|
.select do |mod|
|
|
@@ -57,7 +57,7 @@ module Tapioca
|
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
#: (
|
|
60
|
+
#: (Module[top] constant, Module[top] mixin, Runtime::Trackers::Mixin::Type mixin_type) -> bool
|
|
61
61
|
def mixed_in_by_gem?(constant, mixin, mixin_type)
|
|
62
62
|
mixin_location = Runtime::Trackers::Mixin.mixin_location(mixin, mixin_type, constant)
|
|
63
63
|
|
|
@@ -73,7 +73,7 @@ module Tapioca
|
|
|
73
73
|
mixin_name.start_with?("T::") && !mixin_name.start_with?("T::Props")
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
#: (
|
|
76
|
+
#: (Module[top] constant) -> Array[Module[top]]
|
|
77
77
|
def interesting_ancestors_of(constant)
|
|
78
78
|
inherited_ancestors = Set.new.compare_by_identity.merge(inherited_ancestors_of(constant))
|
|
79
79
|
|