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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/tapioca/commands/abstract_dsl.rb +21 -2
  4. data/lib/tapioca/commands/abstract_gem.rb +21 -2
  5. data/lib/tapioca/commands/annotations.rb +7 -1
  6. data/lib/tapioca/commands/check_shims.rb +9 -1
  7. data/lib/tapioca/commands/command.rb +1 -1
  8. data/lib/tapioca/dsl/compiler.rb +17 -12
  9. data/lib/tapioca/dsl/compilers/aasm.rb +2 -2
  10. data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +2 -2
  11. data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -1
  12. data/lib/tapioca/dsl/compilers/action_text.rb +1 -1
  13. data/lib/tapioca/dsl/compilers/active_job.rb +1 -1
  14. data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -1
  15. data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +7 -1
  16. data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +1 -1
  17. data/lib/tapioca/dsl/compilers/active_record_associations.rb +1 -1
  18. data/lib/tapioca/dsl/compilers/active_record_columns.rb +8 -2
  19. data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +1 -1
  20. data/lib/tapioca/dsl/compilers/active_record_enum.rb +2 -2
  21. data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +1 -1
  22. data/lib/tapioca/dsl/compilers/active_record_relations.rb +94 -100
  23. data/lib/tapioca/dsl/compilers/active_record_scope.rb +1 -1
  24. data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +1 -1
  25. data/lib/tapioca/dsl/compilers/active_record_store.rb +1 -1
  26. data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +1 -1
  27. data/lib/tapioca/dsl/compilers/active_resource.rb +1 -1
  28. data/lib/tapioca/dsl/compilers/active_storage.rb +2 -2
  29. data/lib/tapioca/dsl/compilers/active_support_concern.rb +6 -6
  30. data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +1 -1
  31. data/lib/tapioca/dsl/compilers/active_support_time_ext.rb +1 -1
  32. data/lib/tapioca/dsl/compilers/config.rb +2 -2
  33. data/lib/tapioca/dsl/compilers/frozen_record.rb +1 -1
  34. data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -1
  35. data/lib/tapioca/dsl/compilers/graphql_mutation.rb +1 -1
  36. data/lib/tapioca/dsl/compilers/identity_cache.rb +2 -2
  37. data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +1 -1
  38. data/lib/tapioca/dsl/compilers/kredis.rb +1 -1
  39. data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +2 -2
  40. data/lib/tapioca/dsl/compilers/protobuf.rb +7 -3
  41. data/lib/tapioca/dsl/compilers/rails_generators.rb +1 -1
  42. data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -1
  43. data/lib/tapioca/dsl/compilers/smart_properties.rb +1 -1
  44. data/lib/tapioca/dsl/compilers/state_machines.rb +2 -2
  45. data/lib/tapioca/dsl/compilers/url_helpers.rb +7 -7
  46. data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +7 -3
  47. data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +18 -3
  48. data/lib/tapioca/dsl/pipeline.rb +25 -11
  49. data/lib/tapioca/gem/events.rb +15 -8
  50. data/lib/tapioca/gem/listeners/methods.rb +19 -7
  51. data/lib/tapioca/gem/listeners/mixins.rb +3 -3
  52. data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +1 -1
  53. data/lib/tapioca/gem/pipeline.rb +25 -18
  54. data/lib/tapioca/gemfile.rb +1 -1
  55. data/lib/tapioca/helpers/config_helper.rb +5 -1
  56. data/lib/tapioca/helpers/rbi_files_helper.rb +8 -1
  57. data/lib/tapioca/helpers/test/content.rb +1 -1
  58. data/lib/tapioca/internal.rb +1 -0
  59. data/lib/tapioca/loaders/gem.rb +15 -3
  60. data/lib/tapioca/rbi_ext/model.rb +9 -2
  61. data/lib/tapioca/repo_index.rb +1 -1
  62. data/lib/tapioca/runtime/attached_class_of_32.rb +1 -1
  63. data/lib/tapioca/runtime/attached_class_of_legacy.rb +1 -1
  64. data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +6 -6
  65. data/lib/tapioca/runtime/generic_type_registry.rb +8 -8
  66. data/lib/tapioca/runtime/helpers.rb +40 -0
  67. data/lib/tapioca/runtime/reflection.rb +19 -19
  68. data/lib/tapioca/runtime/trackers/autoload.rb +1 -1
  69. data/lib/tapioca/runtime/trackers/constant_definition.rb +3 -3
  70. data/lib/tapioca/runtime/trackers/method_definition.rb +4 -4
  71. data/lib/tapioca/runtime/trackers/mixin.rb +5 -5
  72. data/lib/tapioca/runtime/trackers/required_ancestor.rb +3 -3
  73. data/lib/tapioca/runtime/trackers/tracker.rb +1 -1
  74. data/lib/tapioca/sorbet_ext/generic_name_patch.rb +4 -4
  75. data/lib/tapioca/sorbet_ext/name_patch.rb +3 -14
  76. data/lib/tapioca/static/requires_compiler.rb +1 -1
  77. data/lib/tapioca/version.rb +1 -1
  78. data/lib/tapioca.rb +0 -36
  79. metadata +20 -19
@@ -135,7 +135,7 @@ module Tapioca
135
135
  extend T::Sig
136
136
 
137
137
  # @override
138
- #: -> T::Enumerable[Module]
138
+ #: -> Enumerable[T::Module[top]]
139
139
  def gather_constants
140
140
  descendants_of(::ActiveRecord::Base).reject(&:abstract_class?)
141
141
  end
@@ -111,7 +111,7 @@ module Tapioca
111
111
  extend T::Sig
112
112
 
113
113
  # @override
114
- #: -> T::Enumerable[Module]
114
+ #: -> Enumerable[T::Module[top]]
115
115
  def gather_constants
116
116
  descendants_of(::ActiveRecord::Base).select do |klass|
117
117
  klass.include?(ActiveRecord::TypedStore::Behavior)
@@ -74,7 +74,7 @@ module Tapioca
74
74
  extend T::Sig
75
75
 
76
76
  # @override
77
- #: -> T::Enumerable[Module]
77
+ #: -> Enumerable[T::Module[top]]
78
78
  def gather_constants
79
79
  descendants_of(::ActiveResource::Base)
80
80
  end
@@ -38,7 +38,7 @@ module Tapioca
38
38
  # def photo=(attachable); end
39
39
  # end
40
40
  # ~~~
41
- #: [ConstantType = (Module & ::ActiveStorage::Reflection::ActiveRecordExtensions::ClassMethods)]
41
+ #: [ConstantType = (T::Module[top] & ::ActiveStorage::Reflection::ActiveRecordExtensions::ClassMethods)]
42
42
  class ActiveStorage < Compiler
43
43
  extend T::Sig
44
44
 
@@ -68,7 +68,7 @@ module Tapioca
68
68
  extend T::Sig
69
69
 
70
70
  # @override
71
- #: -> T::Enumerable[Module]
71
+ #: -> Enumerable[T::Module[top]]
72
72
  def gather_constants
73
73
  descendants_of(::ActiveRecord::Base)
74
74
  .reject(&:abstract_class?)
@@ -37,7 +37,7 @@ module Tapioca
37
37
  # mixes_in_class_methods(::Foo::ClassMethods)
38
38
  # end
39
39
  # ~~~
40
- #: [ConstantType = Module]
40
+ #: [ConstantType = T::Module[top]]
41
41
  class ActiveSupportConcern < Compiler
42
42
  extend T::Sig
43
43
 
@@ -65,7 +65,7 @@ module Tapioca
65
65
  extend T::Sig
66
66
 
67
67
  # @override
68
- #: -> T::Enumerable[Module]
68
+ #: -> Enumerable[T::Module[top]]
69
69
  def gather_constants
70
70
  all_modules.select do |mod|
71
71
  name_of(mod) && # i.e. not anonymous
@@ -76,10 +76,10 @@ module Tapioca
76
76
  end
77
77
 
78
78
  # Returns true when `mod` includes other concerns
79
- #: (Module mod) -> bool
79
+ #: (T::Module[top] mod) -> bool
80
80
  def has_dependencies?(mod) = dependencies_of(mod).any?
81
81
 
82
- #: (Module concern) -> Array[Module]
82
+ #: (T::Module[top] concern) -> Array[T::Module[top]]
83
83
  def dependencies_of(concern)
84
84
  concern.instance_variable_get(:@_dependencies) || []
85
85
  end
@@ -87,12 +87,12 @@ module Tapioca
87
87
 
88
88
  private
89
89
 
90
- #: (Module concern) -> Array[Module]
90
+ #: (T::Module[top] concern) -> Array[T::Module[top]]
91
91
  def dependencies_of(concern)
92
92
  self.class.dependencies_of(concern)
93
93
  end
94
94
 
95
- #: (?Module concern) -> Array[Module]
95
+ #: (?T::Module[top] concern) -> Array[T::Module[top]]
96
96
  def linearized_dependencies(concern = constant)
97
97
  # Grab all the dependencies of the concern
98
98
  dependencies = dependencies_of(concern)
@@ -97,7 +97,7 @@ module Tapioca
97
97
  extend T::Sig
98
98
 
99
99
  # @override
100
- #: -> T::Enumerable[Module]
100
+ #: -> Enumerable[T::Module[top]]
101
101
  def gather_constants
102
102
  descendants_of(::ActiveSupport::CurrentAttributes)
103
103
  end
@@ -58,7 +58,7 @@ module Tapioca
58
58
  extend T::Sig
59
59
 
60
60
  # @override
61
- #: -> T::Enumerable[Module]
61
+ #: -> Enumerable[T::Module[top]]
62
62
  def gather_constants
63
63
  [::Time]
64
64
  end
@@ -40,7 +40,7 @@ module Tapioca
40
40
  # def github=(value); end
41
41
  # end
42
42
  # ```
43
- #: [ConstantType = Module]
43
+ #: [ConstantType = T::Module[top]]
44
44
  class Config < Compiler
45
45
  extend T::Sig
46
46
 
@@ -96,7 +96,7 @@ module Tapioca
96
96
  extend T::Sig
97
97
 
98
98
  # @override
99
- #: -> T::Enumerable[Module]
99
+ #: -> Enumerable[T::Module[top]]
100
100
  def gather_constants
101
101
  name = ::Config.const_name
102
102
  return [] unless Object.const_defined?(name)
@@ -88,7 +88,7 @@ module Tapioca
88
88
  extend T::Sig
89
89
 
90
90
  # @override
91
- #: -> T::Enumerable[Module]
91
+ #: -> Enumerable[T::Module[top]]
92
92
  def gather_constants
93
93
  descendants_of(::FrozenRecord::Base).reject(&:abstract_class?)
94
94
  end
@@ -77,7 +77,7 @@ module Tapioca
77
77
  extend T::Sig
78
78
 
79
79
  # @override
80
- #: -> T::Enumerable[Module]
80
+ #: -> Enumerable[T::Module[top]]
81
81
  def gather_constants
82
82
  all_classes.select { |c| GraphQL::Schema::InputObject > c }
83
83
  end
@@ -74,7 +74,7 @@ module Tapioca
74
74
  extend T::Sig
75
75
 
76
76
  # @override
77
- #: -> T::Enumerable[Module]
77
+ #: -> Enumerable[T::Module[top]]
78
78
  def gather_constants
79
79
  all_classes.select { |c| GraphQL::Schema::Mutation > c && GraphQL::Schema::RelayClassicMutation != c }
80
80
  end
@@ -59,7 +59,7 @@ module Tapioca
59
59
  class IdentityCache < Compiler
60
60
  extend T::Sig
61
61
 
62
- COLLECTION_TYPE = ->(type) { "T::Array[::#{type}]" } #: ^((Module | String) type) -> String
62
+ COLLECTION_TYPE = ->(type) { "T::Array[::#{type}]" } #: ^((T::Module[top] | String) type) -> String
63
63
 
64
64
  # @override
65
65
  #: -> void
@@ -95,7 +95,7 @@ module Tapioca
95
95
  extend T::Sig
96
96
 
97
97
  # @override
98
- #: -> T::Enumerable[Module]
98
+ #: -> Enumerable[T::Module[top]]
99
99
  def gather_constants
100
100
  descendants_of(::ActiveRecord::Base).select do |klass|
101
101
  ::IdentityCache::WithoutPrimaryIndex > klass
@@ -109,7 +109,7 @@ module Tapioca
109
109
  extend T::Sig
110
110
 
111
111
  # @override
112
- #: -> T::Enumerable[Module]
112
+ #: -> Enumerable[T::Module[top]]
113
113
  def gather_constants
114
114
  all_modules.select do |c|
115
115
  name_of(c) && ::JsonApiClient::Resource > c
@@ -88,7 +88,7 @@ module Tapioca
88
88
  extend T::Sig
89
89
 
90
90
  # @override
91
- #: -> T::Enumerable[Module]
91
+ #: -> Enumerable[T::Module[top]]
92
92
  def gather_constants
93
93
  all_classes
94
94
  .grep(::Kredis::Attributes::ClassMethods)
@@ -44,7 +44,7 @@ module Tapioca
44
44
  # end
45
45
  # end
46
46
  # ~~~
47
- #: [ConstantType = Module]
47
+ #: [ConstantType = T::Module[top]]
48
48
  class MixedInClassAttributes < Compiler
49
49
  extend T::Sig
50
50
 
@@ -63,7 +63,7 @@ module Tapioca
63
63
  extend T::Sig
64
64
 
65
65
  # @override
66
- #: -> T::Enumerable[Module]
66
+ #: -> Enumerable[T::Module[top]]
67
67
  def gather_constants
68
68
  # Select all non-anonymous modules that have overridden Module.included
69
69
  all_modules.select do |mod|
@@ -156,7 +156,7 @@ module Tapioca
156
156
  extend T::Sig
157
157
 
158
158
  # @override
159
- #: -> T::Enumerable[Module]
159
+ #: -> Enumerable[T::Module[top]]
160
160
  def gather_constants
161
161
  marker = Google::Protobuf::MessageExts::ClassMethods
162
162
 
@@ -168,7 +168,7 @@ module Tapioca
168
168
  else
169
169
  T.cast(
170
170
  ObjectSpace.each_object(marker).to_a,
171
- T::Array[Module],
171
+ T::Array[T::Module[T.anything]],
172
172
  )
173
173
  end
174
174
 
@@ -269,7 +269,11 @@ module Tapioca
269
269
  Field.new(
270
270
  name: descriptor.name,
271
271
  type: type,
272
- init_type: "T.nilable(T.any(#{type}, T::Array[#{elem_type}]))",
272
+ # The FFI implementation accepts Enumerables:
273
+ # https://github.com/protocolbuffers/protobuf/blob/fc0eda1fd4eff075f1fb2e9249fa4209f0227e33/ruby/lib/google/protobuf/ffi/repeated_field.rb#L361-L366
274
+ # However the C implementation of the initializer specifically checks for Arrays:
275
+ # https://github.com/protocolbuffers/protobuf/blob/fc0eda1fd4eff075f1fb2e9249fa4209f0227e33/ruby/ext/google/protobuf_c/message.c#L568-L573
276
+ init_type: "T.nilable(T::Array[#{elem_type}])",
273
277
  default: "T.unsafe(nil)",
274
278
  )
275
279
  end
@@ -60,7 +60,7 @@ module Tapioca
60
60
  extend T::Sig
61
61
 
62
62
  # @override
63
- #: -> T::Enumerable[Module]
63
+ #: -> Enumerable[T::Module[top]]
64
64
  def gather_constants
65
65
  all_classes.select do |const|
66
66
  name = qualified_name_of(const)
@@ -87,7 +87,7 @@ module Tapioca
87
87
  extend T::Sig
88
88
 
89
89
  # @override
90
- #: -> T::Enumerable[Module]
90
+ #: -> Enumerable[T::Module[top]]
91
91
  def gather_constants
92
92
  all_classes.select { |c| Sidekiq::Worker > c }
93
93
  end
@@ -84,7 +84,7 @@ module Tapioca
84
84
  extend T::Sig
85
85
 
86
86
  # @override
87
- #: -> T::Enumerable[Module]
87
+ #: -> Enumerable[T::Module[top]]
88
88
  def gather_constants
89
89
  all_modules.select do |c|
90
90
  name_of(c) &&
@@ -109,7 +109,7 @@ module Tapioca
109
109
  # end
110
110
  # end
111
111
  # ~~~
112
- #: [ConstantType = (Module & ::StateMachines::ClassMethods)]
112
+ #: [ConstantType = (T::Module[top] & ::StateMachines::ClassMethods)]
113
113
  class StateMachines < Compiler
114
114
  extend T::Sig
115
115
 
@@ -158,7 +158,7 @@ module Tapioca
158
158
  extend T::Sig
159
159
 
160
160
  # @override
161
- #: -> T::Enumerable[Module]
161
+ #: -> Enumerable[T::Module[top]]
162
162
  def gather_constants
163
163
  all_classes.select { |mod| ::StateMachines::InstanceMethods > mod }
164
164
  end
@@ -78,7 +78,7 @@ module Tapioca
78
78
  # include GeneratedUrlHelpersModule
79
79
  # end
80
80
  # ~~~
81
- #: [ConstantType = Module]
81
+ #: [ConstantType = T::Module[top]]
82
82
  class UrlHelpers < Compiler
83
83
  extend T::Sig
84
84
 
@@ -99,7 +99,7 @@ module Tapioca
99
99
  class << self
100
100
  extend T::Sig
101
101
  # @override
102
- #: -> T::Enumerable[Module]
102
+ #: -> Enumerable[T::Module[top]]
103
103
  def gather_constants
104
104
  return [] unless defined?(Rails.application) && Rails.application
105
105
 
@@ -131,7 +131,7 @@ module Tapioca
131
131
  constants.concat(NON_DISCOVERABLE_INCLUDERS).push(GeneratedUrlHelpersModule, GeneratedPathHelpersModule)
132
132
  end
133
133
 
134
- #: -> Array[Module]
134
+ #: -> Array[T::Module[top]]
135
135
  def gather_non_discoverable_includers
136
136
  [].tap do |includers|
137
137
  if defined?(ActionController::TemplateAssertions) && defined?(ActionDispatch::IntegrationTest)
@@ -146,7 +146,7 @@ module Tapioca
146
146
 
147
147
  # Returns `true` if `mod` "directly" includes `helper`.
148
148
  # For classes, this method will return false if the `helper` is included only by a superclass
149
- #: (Module mod, Module helper) -> bool
149
+ #: (T::Module[top] mod, T::Module[top] helper) -> bool
150
150
  private def includes_helper?(mod, helper)
151
151
  ancestors = ancestors_of(mod)
152
152
 
@@ -161,11 +161,11 @@ module Tapioca
161
161
  end
162
162
  end
163
163
 
164
- NON_DISCOVERABLE_INCLUDERS = gather_non_discoverable_includers #: Array[Module]
164
+ NON_DISCOVERABLE_INCLUDERS = gather_non_discoverable_includers #: Array[T::Module[top]]
165
165
 
166
166
  private
167
167
 
168
- #: (RBI::Tree root, Module constant) -> void
168
+ #: (RBI::Tree root, T::Module[top] constant) -> void
169
169
  def generate_module_for(root, constant)
170
170
  root.create_module(T.must(constant.name)) do |mod|
171
171
  mod.create_include("::ActionDispatch::Routing::UrlFor")
@@ -181,7 +181,7 @@ module Tapioca
181
181
  end
182
182
  end
183
183
 
184
- #: (RBI::Scope mod, Module helper_module) -> void
184
+ #: (RBI::Scope mod, T::Module[top] helper_module) -> void
185
185
  def create_mixins_for(mod, helper_module)
186
186
  include_helper = constant.ancestors.include?(helper_module) || NON_DISCOVERABLE_INCLUDERS.include?(constant)
187
187
  extend_helper = constant.singleton_class.ancestors.include?(helper_module)
@@ -22,7 +22,9 @@ module Tapioca
22
22
  class << self
23
23
  extend T::Sig
24
24
 
25
- #: (Hash[String, untyped] options) { (String value, ColumnTypeOption default_column_type_option) -> void } -> ColumnTypeOption
25
+ #: (
26
+ #| Hash[String, untyped] options,
27
+ #| ) { (String value, ColumnTypeOption default_column_type_option) -> void } -> ColumnTypeOption
26
28
  def from_options(options, &block)
27
29
  column_type_option = Persisted
28
30
  value = options["ActiveRecordColumnTypes"]
@@ -152,8 +154,10 @@ module Tapioca
152
154
  when ActiveRecord::Type::Serialized
153
155
  serialized_column_type(column_type)
154
156
  when ->(type) {
155
- defined?(ActiveRecord::Normalization::NormalizedValueType) &&
156
- ActiveRecord::Normalization::NormalizedValueType === type
157
+ (defined?(ActiveRecord::Normalization::NormalizedValueType) &&
158
+ ActiveRecord::Normalization::NormalizedValueType === type) ||
159
+ (defined?(ActiveModel::Attributes::Normalization::NormalizedValueType) &&
160
+ ActiveModel::Attributes::Normalization::NormalizedValueType === type)
157
161
  }
158
162
  type_for_activerecord_value(column_type.cast_type, column_nullability:)
159
163
  when ->(type) {
@@ -9,7 +9,10 @@ module Tapioca
9
9
 
10
10
  extend T::Sig
11
11
 
12
- #: (GraphQL::Schema::Argument argument, (singleton(GraphQL::Schema::Mutation) | singleton(GraphQL::Schema::InputObject)) constant) -> String
12
+ #: (
13
+ #| GraphQL::Schema::Argument argument,
14
+ #| (singleton(GraphQL::Schema::Mutation) | singleton(GraphQL::Schema::InputObject)) constant
15
+ #| ) -> String
13
16
  def type_for_argument(argument, constant)
14
17
  type = if argument.loads
15
18
  loads_type = ::GraphQL::Schema::Wrapper.new(argument.loads)
@@ -34,7 +37,19 @@ module Tapioca
34
37
  )
35
38
  end
36
39
 
37
- #: ((GraphQL::Schema::Wrapper | singleton(GraphQL::Schema::Scalar) | singleton(GraphQL::Schema::Enum) | singleton(GraphQL::Schema::Union) | singleton(GraphQL::Schema::Object) | singleton(GraphQL::Schema::Interface) | singleton(GraphQL::Schema::InputObject)) type, ?ignore_nilable_wrapper: bool, ?prepare_method: Method?) -> String
40
+ #: (
41
+ #| (
42
+ #| GraphQL::Schema::Wrapper |
43
+ #| singleton(GraphQL::Schema::Scalar) |
44
+ #| singleton(GraphQL::Schema::Enum) |
45
+ #| singleton(GraphQL::Schema::Union) |
46
+ #| singleton(GraphQL::Schema::Object) |
47
+ #| singleton(GraphQL::Schema::Interface) |
48
+ #| singleton(GraphQL::Schema::InputObject)
49
+ #| ) type,
50
+ #| ?ignore_nilable_wrapper: bool,
51
+ #| ?prepare_method: Method?
52
+ #| ) -> String
38
53
  def type_for(type, ignore_nilable_wrapper: false, prepare_method: nil)
39
54
  unwrapped_type = type.unwrap
40
55
 
@@ -97,7 +112,7 @@ module Tapioca
97
112
 
98
113
  private
99
114
 
100
- #: (Module constant) -> String
115
+ #: (T::Module[top] constant) -> String
101
116
  def type_for_constant(constant)
102
117
  if constant.instance_methods.include?(:prepare)
103
118
  prepare_method = constant.instance_method(:prepare)
@@ -6,16 +6,16 @@ module Tapioca
6
6
  class Pipeline
7
7
  extend T::Sig
8
8
 
9
- #: T::Enumerable[singleton(Compiler)]
9
+ #: Enumerable[singleton(Compiler)]
10
10
  attr_reader :active_compilers
11
11
 
12
- #: Array[Module]
12
+ #: Array[T::Module[top]]
13
13
  attr_reader :requested_constants
14
14
 
15
15
  #: Array[Pathname]
16
16
  attr_reader :requested_paths
17
17
 
18
- #: Array[Module]
18
+ #: Array[T::Module[top]]
19
19
  attr_reader :skipped_constants
20
20
 
21
21
  #: ^(String error) -> void
@@ -24,7 +24,17 @@ module Tapioca
24
24
  #: Array[String]
25
25
  attr_reader :errors
26
26
 
27
- #: (requested_constants: Array[Module], ?requested_paths: Array[Pathname], ?requested_compilers: Array[singleton(Compiler)], ?excluded_compilers: Array[singleton(Compiler)], ?error_handler: ^(String error) -> void, ?skipped_constants: Array[Module], ?number_of_workers: Integer?, ?compiler_options: Hash[String, untyped], ?lsp_addon: bool) -> void
27
+ #: (
28
+ #| requested_constants: Array[T::Module[top]],
29
+ #| ?requested_paths: Array[Pathname],
30
+ #| ?requested_compilers: Array[singleton(Compiler)],
31
+ #| ?excluded_compilers: Array[singleton(Compiler)],
32
+ #| ?error_handler: ^(String error) -> void,
33
+ #| ?skipped_constants: Array[T::Module[top]],
34
+ #| ?number_of_workers: Integer?,
35
+ #| ?compiler_options: Hash[String, untyped],
36
+ #| ?lsp_addon: bool
37
+ #| ) -> void
28
38
  def initialize(
29
39
  requested_constants:,
30
40
  requested_paths: [],
@@ -48,7 +58,7 @@ module Tapioca
48
58
  @errors = [] #: Array[String]
49
59
  end
50
60
 
51
- #: [T] { (Module constant, RBI::File rbi) -> T } -> Array[T]
61
+ #: [R] { (T::Module[top] constant, RBI::File rbi) -> R } -> Array[R]
52
62
  def run(&blk)
53
63
  constants_to_process = gather_constants(requested_constants, requested_paths, skipped_constants)
54
64
  .select { |c| Module === c } # Filter value constants out
@@ -111,7 +121,7 @@ module Tapioca
111
121
 
112
122
  private
113
123
 
114
- #: (Array[singleton(Compiler)] requested_compilers, Array[singleton(Compiler)] excluded_compilers) -> T::Enumerable[singleton(Compiler)]
124
+ #: (Array[singleton(Compiler)] requested_compilers, Array[singleton(Compiler)] excluded_compilers) -> Enumerable[singleton(Compiler)]
115
125
  def gather_active_compilers(requested_compilers, excluded_compilers)
116
126
  active_compilers = compilers
117
127
  active_compilers -= excluded_compilers
@@ -119,7 +129,11 @@ module Tapioca
119
129
  active_compilers
120
130
  end
121
131
 
122
- #: (Array[Module] requested_constants, Array[Pathname] requested_paths, Array[Module] skipped_constants) -> Set[Module]
132
+ #: (
133
+ #| Array[T::Module[top]] requested_constants,
134
+ #| Array[Pathname] requested_paths,
135
+ #| Array[T::Module[top]] skipped_constants
136
+ #| ) -> Set[T::Module[top]]
123
137
  def gather_constants(requested_constants, requested_paths, skipped_constants)
124
138
  Compiler.requested_constants = requested_constants
125
139
  constants = Set.new.compare_by_identity
@@ -141,14 +155,14 @@ module Tapioca
141
155
  constants
142
156
  end
143
157
 
144
- #: (Set[Module] constants) -> Set[Module]
158
+ #: (Set[T::Module[top]] constants) -> Set[T::Module[top]]
145
159
  def filter_anonymous_and_reloaded_constants(constants)
146
160
  # Group constants by their names
147
161
  constants_by_name = constants
148
162
  .group_by { |c| Runtime::Reflection.name_of(c) }
149
163
  .select { |name, _| !name.nil? }
150
164
 
151
- constants_by_name = T.cast(constants_by_name, T::Hash[String, T::Array[Module]])
165
+ constants_by_name = T.cast(constants_by_name, T::Hash[String, T::Array[T::Module[T.anything]]])
152
166
 
153
167
  # Find the constants that have been reloaded
154
168
  reloaded_constants = constants_by_name.select { |_, constants| constants.size > 1 }.keys
@@ -164,13 +178,13 @@ module Tapioca
164
178
  # set of constants that are actually in memory with those names.
165
179
  filtered_constants = constants_by_name
166
180
  .keys
167
- .map { |name| T.cast(Runtime::Reflection.constantize(name), Module) }
181
+ .map { |name| T.cast(Runtime::Reflection.constantize(name), T::Module[T.anything]) }
168
182
  .select { |mod| Runtime::Reflection.constant_defined?(mod) }
169
183
 
170
184
  Set.new.compare_by_identity.merge(filtered_constants)
171
185
  end
172
186
 
173
- #: (Module constant) -> RBI::File?
187
+ #: (T::Module[top] constant) -> RBI::File?
174
188
  def rbi_for_constant(constant)
175
189
  file = RBI::File.new(strictness: "true")
176
190
 
@@ -44,12 +44,12 @@ module Tapioca
44
44
  extend T::Sig
45
45
 
46
46
  # @override
47
- #: -> Module
47
+ #: -> T::Module[top]
48
48
  def constant
49
- T.cast(@constant, Module)
49
+ T.cast(@constant, T::Module[T.anything])
50
50
  end
51
51
 
52
- #: (String symbol, Module constant) -> void
52
+ #: (String symbol, T::Module[top] constant) -> void
53
53
  def initialize(symbol, constant)
54
54
  super
55
55
  end
@@ -62,10 +62,10 @@ module Tapioca
62
62
  #: String
63
63
  attr_reader :symbol
64
64
 
65
- #: Module
65
+ #: T::Module[top]
66
66
  attr_reader :constant
67
67
 
68
- #: (String symbol, Module constant) -> void
68
+ #: (String symbol, T::Module[top] constant) -> void
69
69
  def initialize(symbol, constant)
70
70
  super()
71
71
  @symbol = symbol
@@ -79,7 +79,7 @@ module Tapioca
79
79
  #: RBI::Const
80
80
  attr_reader :node
81
81
 
82
- #: (String symbol, Module constant, RBI::Const node) -> void
82
+ #: (String symbol, T::Module[top] constant, RBI::Const node) -> void
83
83
  def initialize(symbol, constant, node)
84
84
  super(symbol, constant)
85
85
  @node = node
@@ -92,7 +92,7 @@ module Tapioca
92
92
  #: RBI::Scope
93
93
  attr_reader :node
94
94
 
95
- #: (String symbol, Module constant, RBI::Scope node) -> void
95
+ #: (String symbol, T::Module[top] constant, RBI::Scope node) -> void
96
96
  def initialize(symbol, constant, node)
97
97
  super(symbol, constant)
98
98
  @node = node
@@ -116,7 +116,14 @@ module Tapioca
116
116
  #: Array[[Symbol, String]]
117
117
  attr_reader :parameters
118
118
 
119
- #: (String symbol, Module constant, UnboundMethod method, RBI::Method node, untyped signature, Array[[Symbol, String]] parameters) -> void
119
+ #: (
120
+ #| String symbol,
121
+ #| T::Module[top] constant,
122
+ #| UnboundMethod method,
123
+ #| RBI::Method node,
124
+ #| untyped signature,
125
+ #| Array[[Symbol, String]] parameters
126
+ #| ) -> void
120
127
  def initialize(symbol, constant, method, node, signature, parameters) # rubocop:disable Metrics/ParameterLists
121
128
  super(symbol, constant)
122
129
  @node = node