tapioca 0.17.9 → 0.18.0

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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -2
  3. data/lib/tapioca/bundler_ext/auto_require_hook.rb +0 -3
  4. data/lib/tapioca/cli.rb +0 -2
  5. data/lib/tapioca/commands/abstract_dsl.rb +21 -2
  6. data/lib/tapioca/commands/abstract_gem.rb +20 -1
  7. data/lib/tapioca/commands/annotations.rb +7 -3
  8. data/lib/tapioca/commands/check_shims.rb +9 -2
  9. data/lib/tapioca/commands/command.rb +0 -1
  10. data/lib/tapioca/dsl/compiler.rb +17 -16
  11. data/lib/tapioca/dsl/compilers/aasm.rb +2 -6
  12. data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +2 -6
  13. data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -5
  14. data/lib/tapioca/dsl/compilers/action_text.rb +1 -5
  15. data/lib/tapioca/dsl/compilers/active_job.rb +1 -5
  16. data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -5
  17. data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +1 -5
  18. data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +1 -3
  19. data/lib/tapioca/dsl/compilers/active_record_associations.rb +1 -6
  20. data/lib/tapioca/dsl/compilers/active_record_columns.rb +8 -5
  21. data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +1 -4
  22. data/lib/tapioca/dsl/compilers/active_record_enum.rb +1 -5
  23. data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +1 -5
  24. data/lib/tapioca/dsl/compilers/active_record_relations.rb +45 -87
  25. data/lib/tapioca/dsl/compilers/active_record_scope.rb +1 -2
  26. data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +1 -4
  27. data/lib/tapioca/dsl/compilers/active_record_store.rb +1 -4
  28. data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +1 -5
  29. data/lib/tapioca/dsl/compilers/active_resource.rb +1 -5
  30. data/lib/tapioca/dsl/compilers/active_storage.rb +2 -6
  31. data/lib/tapioca/dsl/compilers/active_support_concern.rb +6 -10
  32. data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +4 -19
  33. data/lib/tapioca/dsl/compilers/active_support_environment_inquirer.rb +60 -0
  34. data/lib/tapioca/dsl/compilers/active_support_time_ext.rb +1 -5
  35. data/lib/tapioca/dsl/compilers/config.rb +2 -6
  36. data/lib/tapioca/dsl/compilers/frozen_record.rb +1 -5
  37. data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -5
  38. data/lib/tapioca/dsl/compilers/graphql_mutation.rb +1 -5
  39. data/lib/tapioca/dsl/compilers/identity_cache.rb +2 -6
  40. data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +4 -18
  41. data/lib/tapioca/dsl/compilers/kredis.rb +1 -5
  42. data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +2 -6
  43. data/lib/tapioca/dsl/compilers/protobuf.rb +2 -6
  44. data/lib/tapioca/dsl/compilers/rails_generators.rb +1 -5
  45. data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -5
  46. data/lib/tapioca/dsl/compilers/smart_properties.rb +1 -5
  47. data/lib/tapioca/dsl/compilers/state_machines.rb +2 -6
  48. data/lib/tapioca/dsl/compilers/url_helpers.rb +7 -10
  49. data/lib/tapioca/dsl/helpers/active_model_type_helper.rb +0 -2
  50. data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +3 -6
  51. data/lib/tapioca/dsl/helpers/active_record_constants_helper.rb +0 -2
  52. data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +18 -5
  53. data/lib/tapioca/dsl/pipeline.rb +25 -13
  54. data/lib/tapioca/executor.rb +0 -2
  55. data/lib/tapioca/gem/events.rb +15 -23
  56. data/lib/tapioca/gem/listeners/base.rb +0 -1
  57. data/lib/tapioca/gem/listeners/dynamic_mixins.rb +0 -2
  58. data/lib/tapioca/gem/listeners/foreign_constants.rb +0 -2
  59. data/lib/tapioca/gem/listeners/methods.rb +19 -9
  60. data/lib/tapioca/gem/listeners/mixins.rb +3 -5
  61. data/lib/tapioca/gem/listeners/remove_empty_payload_scopes.rb +0 -2
  62. data/lib/tapioca/gem/listeners/sorbet_enums.rb +0 -2
  63. data/lib/tapioca/gem/listeners/sorbet_helpers.rb +0 -2
  64. data/lib/tapioca/gem/listeners/sorbet_props.rb +0 -1
  65. data/lib/tapioca/gem/listeners/sorbet_required_ancestors.rb +0 -2
  66. data/lib/tapioca/gem/listeners/sorbet_signatures.rb +0 -2
  67. data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +1 -3
  68. data/lib/tapioca/gem/listeners/source_location.rb +6 -7
  69. data/lib/tapioca/gem/listeners/subconstants.rb +0 -2
  70. data/lib/tapioca/gem/listeners/yard_doc.rb +0 -2
  71. data/lib/tapioca/gem/pipeline.rb +25 -21
  72. data/lib/tapioca/gemfile.rb +1 -3
  73. data/lib/tapioca/helpers/cli_helper.rb +0 -1
  74. data/lib/tapioca/helpers/config_helper.rb +5 -2
  75. data/lib/tapioca/helpers/env_helper.rb +0 -1
  76. data/lib/tapioca/helpers/gem_helper.rb +0 -2
  77. data/lib/tapioca/helpers/git_attributes.rb +0 -2
  78. data/lib/tapioca/helpers/package_url.rb +416 -0
  79. data/lib/tapioca/helpers/rbi_files_helper.rb +8 -2
  80. data/lib/tapioca/helpers/rbi_helper.rb +0 -3
  81. data/lib/tapioca/helpers/sorbet_helper.rb +0 -2
  82. data/lib/tapioca/helpers/test/content.rb +0 -1
  83. data/lib/tapioca/helpers/test/dsl_compiler.rb +0 -3
  84. data/lib/tapioca/helpers/test/isolation.rb +0 -6
  85. data/lib/tapioca/helpers/test/template.rb +1 -9
  86. data/lib/tapioca/internal.rb +1 -1
  87. data/lib/tapioca/loaders/dsl.rb +0 -4
  88. data/lib/tapioca/loaders/gem.rb +14 -6
  89. data/lib/tapioca/loaders/loader.rb +0 -1
  90. data/lib/tapioca/rbi_ext/model.rb +9 -4
  91. data/lib/tapioca/rbi_formatter.rb +0 -2
  92. data/lib/tapioca/repo_index.rb +1 -4
  93. data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +6 -9
  94. data/lib/tapioca/runtime/generic_type_registry.rb +8 -12
  95. data/lib/tapioca/runtime/reflection.rb +25 -31
  96. data/lib/tapioca/runtime/trackers/autoload.rb +0 -3
  97. data/lib/tapioca/runtime/trackers/constant_definition.rb +30 -8
  98. data/lib/tapioca/runtime/trackers/method_definition.rb +4 -5
  99. data/lib/tapioca/runtime/trackers/mixin.rb +5 -8
  100. data/lib/tapioca/runtime/trackers/required_ancestor.rb +2 -4
  101. data/lib/tapioca/runtime/trackers/tracker.rb +1 -4
  102. data/lib/tapioca/runtime/trackers.rb +0 -4
  103. data/lib/tapioca/sorbet_ext/generic_name_patch.rb +1 -3
  104. data/lib/tapioca/static/requires_compiler.rb +1 -3
  105. data/lib/tapioca/static/symbol_loader.rb +0 -1
  106. data/lib/tapioca/static/symbol_table_parser.rb +0 -4
  107. data/lib/tapioca/version.rb +1 -1
  108. data/lib/tapioca.rb +0 -2
  109. metadata +18 -5
  110. data/lib/tapioca/helpers/source_uri.rb +0 -84
  111. data/lib/tapioca/runtime/attached_class_of_32.rb +0 -20
  112. data/lib/tapioca/runtime/attached_class_of_legacy.rb +0 -24
@@ -65,8 +65,6 @@ module Tapioca
65
65
  # ~~~
66
66
  #: [ConstantType = (Class[::Kredis::Attributes] & ::Kredis::Attributes::ClassMethods & Extensions::Kredis)]
67
67
  class Kredis < Compiler
68
- extend T::Sig
69
-
70
68
  # @override
71
69
  #: -> void
72
70
  def decorate
@@ -85,10 +83,8 @@ module Tapioca
85
83
  end
86
84
 
87
85
  class << self
88
- extend T::Sig
89
-
90
86
  # @override
91
- #: -> T::Enumerable[Module]
87
+ #: -> Enumerable[T::Module[top]]
92
88
  def gather_constants
93
89
  all_classes
94
90
  .grep(::Kredis::Attributes::ClassMethods)
@@ -44,10 +44,8 @@ module Tapioca
44
44
  # end
45
45
  # end
46
46
  # ~~~
47
- #: [ConstantType = Module]
47
+ #: [ConstantType = T::Module[top]]
48
48
  class MixedInClassAttributes < Compiler
49
- extend T::Sig
50
-
51
49
  # @override
52
50
  #: -> void
53
51
  def decorate
@@ -60,10 +58,8 @@ module Tapioca
60
58
  end
61
59
 
62
60
  class << self
63
- extend T::Sig
64
-
65
61
  # @override
66
- #: -> T::Enumerable[Module]
62
+ #: -> Enumerable[T::Module[top]]
67
63
  def gather_constants
68
64
  # Select all non-anonymous modules that have overridden Module.included
69
65
  all_modules.select do |mod|
@@ -73,8 +73,6 @@ module Tapioca
73
73
  prop :default, String
74
74
  end
75
75
 
76
- extend T::Sig
77
-
78
76
  FIELD_RE = /^[a-z_][a-zA-Z0-9_]*$/
79
77
 
80
78
  # @override
@@ -153,10 +151,8 @@ module Tapioca
153
151
  end
154
152
 
155
153
  class << self
156
- extend T::Sig
157
-
158
154
  # @override
159
- #: -> T::Enumerable[Module]
155
+ #: -> Enumerable[T::Module[top]]
160
156
  def gather_constants
161
157
  marker = Google::Protobuf::MessageExts::ClassMethods
162
158
 
@@ -168,7 +164,7 @@ module Tapioca
168
164
  else
169
165
  T.cast(
170
166
  ObjectSpace.each_object(marker).to_a,
171
- T::Array[Module],
167
+ T::Array[T::Module[T.anything]],
172
168
  )
173
169
  end
174
170
 
@@ -35,8 +35,6 @@ module Tapioca
35
35
  # ~~~
36
36
  #: [ConstantType = singleton(::Rails::Generators::Base)]
37
37
  class RailsGenerators < Compiler
38
- extend T::Sig
39
-
40
38
  BUILT_IN_MATCHER = /::(ActionMailbox|ActionText|ActiveRecord|Rails)::Generators/
41
39
 
42
40
  # @override
@@ -57,10 +55,8 @@ module Tapioca
57
55
  end
58
56
 
59
57
  class << self
60
- extend T::Sig
61
-
62
58
  # @override
63
- #: -> T::Enumerable[Module]
59
+ #: -> Enumerable[T::Module[top]]
64
60
  def gather_constants
65
61
  all_classes.select do |const|
66
62
  name = qualified_name_of(const)
@@ -43,8 +43,6 @@ module Tapioca
43
43
  # * `self.perform_in` will also accept a `ActiveSupport::Duration` value
44
44
  #: [ConstantType = singleton(::Sidekiq::Worker)]
45
45
  class SidekiqWorker < Compiler
46
- extend T::Sig
47
-
48
46
  # @override
49
47
  #: -> void
50
48
  def decorate
@@ -84,10 +82,8 @@ module Tapioca
84
82
  end
85
83
 
86
84
  class << self
87
- extend T::Sig
88
-
89
85
  # @override
90
- #: -> T::Enumerable[Module]
86
+ #: -> Enumerable[T::Module[top]]
91
87
  def gather_constants
92
88
  all_classes.select { |c| Sidekiq::Worker > c }
93
89
  end
@@ -60,8 +60,6 @@ module Tapioca
60
60
  # ~~~
61
61
  #: [ConstantType = singleton(::SmartProperties)]
62
62
  class SmartProperties < Compiler
63
- extend T::Sig
64
-
65
63
  # @override
66
64
  #: -> void
67
65
  def decorate
@@ -81,10 +79,8 @@ module Tapioca
81
79
  end
82
80
 
83
81
  class << self
84
- extend T::Sig
85
-
86
82
  # @override
87
- #: -> T::Enumerable[Module]
83
+ #: -> Enumerable[T::Module[top]]
88
84
  def gather_constants
89
85
  all_modules.select do |c|
90
86
  name_of(c) &&
@@ -109,10 +109,8 @@ 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
- extend T::Sig
115
-
116
114
  # @override
117
115
  #: -> void
118
116
  def decorate
@@ -155,10 +153,8 @@ module Tapioca
155
153
  end
156
154
 
157
155
  class << self
158
- extend T::Sig
159
-
160
156
  # @override
161
- #: -> T::Enumerable[Module]
157
+ #: -> Enumerable[T::Module[top]]
162
158
  def gather_constants
163
159
  all_classes.select { |mod| ::StateMachines::InstanceMethods > mod }
164
160
  end
@@ -78,10 +78,8 @@ 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
- extend T::Sig
84
-
85
83
  # @override
86
84
  #: -> void
87
85
  def decorate
@@ -97,9 +95,8 @@ module Tapioca
97
95
  end
98
96
 
99
97
  class << self
100
- extend T::Sig
101
98
  # @override
102
- #: -> T::Enumerable[Module]
99
+ #: -> Enumerable[T::Module[top]]
103
100
  def gather_constants
104
101
  return [] unless defined?(Rails.application) && Rails.application
105
102
 
@@ -131,7 +128,7 @@ module Tapioca
131
128
  constants.concat(NON_DISCOVERABLE_INCLUDERS).push(GeneratedUrlHelpersModule, GeneratedPathHelpersModule)
132
129
  end
133
130
 
134
- #: -> Array[Module]
131
+ #: -> Array[T::Module[top]]
135
132
  def gather_non_discoverable_includers
136
133
  [].tap do |includers|
137
134
  if defined?(ActionController::TemplateAssertions) && defined?(ActionDispatch::IntegrationTest)
@@ -146,7 +143,7 @@ module Tapioca
146
143
 
147
144
  # Returns `true` if `mod` "directly" includes `helper`.
148
145
  # For classes, this method will return false if the `helper` is included only by a superclass
149
- #: (Module mod, Module helper) -> bool
146
+ #: (T::Module[top] mod, T::Module[top] helper) -> bool
150
147
  private def includes_helper?(mod, helper)
151
148
  ancestors = ancestors_of(mod)
152
149
 
@@ -161,11 +158,11 @@ module Tapioca
161
158
  end
162
159
  end
163
160
 
164
- NON_DISCOVERABLE_INCLUDERS = gather_non_discoverable_includers #: Array[Module]
161
+ NON_DISCOVERABLE_INCLUDERS = gather_non_discoverable_includers #: Array[T::Module[top]]
165
162
 
166
163
  private
167
164
 
168
- #: (RBI::Tree root, Module constant) -> void
165
+ #: (RBI::Tree root, T::Module[top] constant) -> void
169
166
  def generate_module_for(root, constant)
170
167
  root.create_module(T.must(constant.name)) do |mod|
171
168
  mod.create_include("::ActionDispatch::Routing::UrlFor")
@@ -181,7 +178,7 @@ module Tapioca
181
178
  end
182
179
  end
183
180
 
184
- #: (RBI::Scope mod, Module helper_module) -> void
181
+ #: (RBI::Scope mod, T::Module[top] helper_module) -> void
185
182
  def create_mixins_for(mod, helper_module)
186
183
  include_helper = constant.ancestors.include?(helper_module) || NON_DISCOVERABLE_INCLUDERS.include?(constant)
187
184
  extend_helper = constant.singleton_class.ancestors.include?(helper_module)
@@ -6,8 +6,6 @@ module Tapioca
6
6
  module Helpers
7
7
  module ActiveModelTypeHelper
8
8
  class << self
9
- extend T::Sig
10
-
11
9
  # Returns the type indicated by the custom ActiveModel::Type::Value.
12
10
  # Accepts subclasses of ActiveModel::Type::Value as well as classes that implement similar methods.
13
11
  #: (untyped type_value) -> String
@@ -7,12 +7,9 @@ module Tapioca
7
7
  module Dsl
8
8
  module Helpers
9
9
  class ActiveRecordColumnTypeHelper
10
- extend T::Sig
11
10
  include RBIHelper
12
11
 
13
12
  class ColumnTypeOption < T::Enum
14
- extend T::Sig
15
-
16
13
  enums do
17
14
  Untyped = new("untyped")
18
15
  Nilable = new("nilable")
@@ -20,9 +17,9 @@ module Tapioca
20
17
  end
21
18
 
22
19
  class << self
23
- extend T::Sig
24
-
25
- #: (Hash[String, untyped] options) { (String value, ColumnTypeOption default_column_type_option) -> void } -> ColumnTypeOption
20
+ #: (
21
+ #| Hash[String, untyped] options,
22
+ #| ) { (String value, ColumnTypeOption default_column_type_option) -> void } -> ColumnTypeOption
26
23
  def from_options(options, &block)
27
24
  column_type_option = Persisted
28
25
  value = options["ActiveRecordColumnTypes"]
@@ -5,8 +5,6 @@ module Tapioca
5
5
  module Dsl
6
6
  module Helpers
7
7
  module ActiveRecordConstantsHelper
8
- extend T::Sig
9
-
10
8
  ReflectionType = T.type_alias do
11
9
  T.any(::ActiveRecord::Reflection::ThroughReflection, ::ActiveRecord::Reflection::AssociationReflection)
12
10
  end
@@ -7,9 +7,10 @@ module Tapioca
7
7
  module GraphqlTypeHelper
8
8
  extend self
9
9
 
10
- extend T::Sig
11
-
12
- #: (GraphQL::Schema::Argument argument, (singleton(GraphQL::Schema::Mutation) | singleton(GraphQL::Schema::InputObject)) constant) -> String
10
+ #: (
11
+ #| GraphQL::Schema::Argument argument,
12
+ #| (singleton(GraphQL::Schema::Mutation) | singleton(GraphQL::Schema::InputObject)) constant
13
+ #| ) -> String
13
14
  def type_for_argument(argument, constant)
14
15
  type = if argument.loads
15
16
  loads_type = ::GraphQL::Schema::Wrapper.new(argument.loads)
@@ -34,7 +35,19 @@ module Tapioca
34
35
  )
35
36
  end
36
37
 
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
38
+ #: (
39
+ #| (
40
+ #| GraphQL::Schema::Wrapper |
41
+ #| singleton(GraphQL::Schema::Scalar) |
42
+ #| singleton(GraphQL::Schema::Enum) |
43
+ #| singleton(GraphQL::Schema::Union) |
44
+ #| singleton(GraphQL::Schema::Object) |
45
+ #| singleton(GraphQL::Schema::Interface) |
46
+ #| singleton(GraphQL::Schema::InputObject)
47
+ #| ) type,
48
+ #| ?ignore_nilable_wrapper: bool,
49
+ #| ?prepare_method: Method?
50
+ #| ) -> String
38
51
  def type_for(type, ignore_nilable_wrapper: false, prepare_method: nil)
39
52
  unwrapped_type = type.unwrap
40
53
 
@@ -97,7 +110,7 @@ module Tapioca
97
110
 
98
111
  private
99
112
 
100
- #: (Module constant) -> String
113
+ #: (T::Module[top] constant) -> String
101
114
  def type_for_constant(constant)
102
115
  if constant.instance_methods.include?(:prepare)
103
116
  prepare_method = constant.instance_method(:prepare)
@@ -4,18 +4,16 @@
4
4
  module Tapioca
5
5
  module Dsl
6
6
  class Pipeline
7
- extend T::Sig
8
-
9
- #: T::Enumerable[singleton(Compiler)]
7
+ #: Enumerable[singleton(Compiler)]
10
8
  attr_reader :active_compilers
11
9
 
12
- #: Array[Module]
10
+ #: Array[T::Module[top]]
13
11
  attr_reader :requested_constants
14
12
 
15
13
  #: Array[Pathname]
16
14
  attr_reader :requested_paths
17
15
 
18
- #: Array[Module]
16
+ #: Array[T::Module[top]]
19
17
  attr_reader :skipped_constants
20
18
 
21
19
  #: ^(String error) -> void
@@ -24,7 +22,17 @@ module Tapioca
24
22
  #: Array[String]
25
23
  attr_reader :errors
26
24
 
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
25
+ #: (
26
+ #| requested_constants: Array[T::Module[top]],
27
+ #| ?requested_paths: Array[Pathname],
28
+ #| ?requested_compilers: Array[singleton(Compiler)],
29
+ #| ?excluded_compilers: Array[singleton(Compiler)],
30
+ #| ?error_handler: ^(String error) -> void,
31
+ #| ?skipped_constants: Array[T::Module[top]],
32
+ #| ?number_of_workers: Integer?,
33
+ #| ?compiler_options: Hash[String, untyped],
34
+ #| ?lsp_addon: bool
35
+ #| ) -> void
28
36
  def initialize(
29
37
  requested_constants:,
30
38
  requested_paths: [],
@@ -48,7 +56,7 @@ module Tapioca
48
56
  @errors = [] #: Array[String]
49
57
  end
50
58
 
51
- #: [T] { (Module constant, RBI::File rbi) -> T } -> Array[T]
59
+ #: [R] { (T::Module[top] constant, RBI::File rbi) -> R } -> Array[R]
52
60
  def run(&blk)
53
61
  constants_to_process = gather_constants(requested_constants, requested_paths, skipped_constants)
54
62
  .select { |c| Module === c } # Filter value constants out
@@ -111,7 +119,7 @@ module Tapioca
111
119
 
112
120
  private
113
121
 
114
- #: (Array[singleton(Compiler)] requested_compilers, Array[singleton(Compiler)] excluded_compilers) -> T::Enumerable[singleton(Compiler)]
122
+ #: (Array[singleton(Compiler)] requested_compilers, Array[singleton(Compiler)] excluded_compilers) -> Enumerable[singleton(Compiler)]
115
123
  def gather_active_compilers(requested_compilers, excluded_compilers)
116
124
  active_compilers = compilers
117
125
  active_compilers -= excluded_compilers
@@ -119,7 +127,11 @@ module Tapioca
119
127
  active_compilers
120
128
  end
121
129
 
122
- #: (Array[Module] requested_constants, Array[Pathname] requested_paths, Array[Module] skipped_constants) -> Set[Module]
130
+ #: (
131
+ #| Array[T::Module[top]] requested_constants,
132
+ #| Array[Pathname] requested_paths,
133
+ #| Array[T::Module[top]] skipped_constants
134
+ #| ) -> Set[T::Module[top]]
123
135
  def gather_constants(requested_constants, requested_paths, skipped_constants)
124
136
  Compiler.requested_constants = requested_constants
125
137
  constants = Set.new.compare_by_identity
@@ -141,14 +153,14 @@ module Tapioca
141
153
  constants
142
154
  end
143
155
 
144
- #: (Set[Module] constants) -> Set[Module]
156
+ #: (Set[T::Module[top]] constants) -> Set[T::Module[top]]
145
157
  def filter_anonymous_and_reloaded_constants(constants)
146
158
  # Group constants by their names
147
159
  constants_by_name = constants
148
160
  .group_by { |c| Runtime::Reflection.name_of(c) }
149
161
  .select { |name, _| !name.nil? }
150
162
 
151
- constants_by_name = T.cast(constants_by_name, T::Hash[String, T::Array[Module]])
163
+ constants_by_name = T.cast(constants_by_name, T::Hash[String, T::Array[T::Module[T.anything]]])
152
164
 
153
165
  # Find the constants that have been reloaded
154
166
  reloaded_constants = constants_by_name.select { |_, constants| constants.size > 1 }.keys
@@ -164,13 +176,13 @@ module Tapioca
164
176
  # set of constants that are actually in memory with those names.
165
177
  filtered_constants = constants_by_name
166
178
  .keys
167
- .map { |name| T.cast(Runtime::Reflection.constantize(name), Module) }
179
+ .map { |name| T.cast(Runtime::Reflection.constantize(name), T::Module[T.anything]) }
168
180
  .select { |mod| Runtime::Reflection.constant_defined?(mod) }
169
181
 
170
182
  Set.new.compare_by_identity.merge(filtered_constants)
171
183
  end
172
184
 
173
- #: (Module constant) -> RBI::File?
185
+ #: (T::Module[top] constant) -> RBI::File?
174
186
  def rbi_for_constant(constant)
175
187
  file = RBI::File.new(strictness: "true")
176
188
 
@@ -3,8 +3,6 @@
3
3
 
4
4
  module Tapioca
5
5
  class Executor
6
- extend T::Sig
7
-
8
6
  MINIMUM_ITEMS_PER_WORKER = 2 #: Integer
9
7
 
10
8
  #: (Array[untyped] queue, ?number_of_workers: Integer?) -> void
@@ -5,12 +5,9 @@ module Tapioca
5
5
  module Gem
6
6
  # @abstract
7
7
  class Event
8
- extend T::Sig
9
8
  end
10
9
 
11
10
  class SymbolFound < Event
12
- extend T::Sig
13
-
14
11
  #: String
15
12
  attr_reader :symbol
16
13
 
@@ -22,8 +19,6 @@ module Tapioca
22
19
  end
23
20
 
24
21
  class ConstantFound < Event
25
- extend T::Sig
26
-
27
22
  #: String
28
23
  attr_reader :symbol
29
24
 
@@ -41,15 +36,13 @@ module Tapioca
41
36
  end
42
37
 
43
38
  class ForeignConstantFound < ConstantFound
44
- extend T::Sig
45
-
46
39
  # @override
47
- #: -> Module
40
+ #: -> T::Module[top]
48
41
  def constant
49
- T.cast(@constant, Module)
42
+ T.cast(@constant, T::Module[T.anything])
50
43
  end
51
44
 
52
- #: (String symbol, Module constant) -> void
45
+ #: (String symbol, T::Module[top] constant) -> void
53
46
  def initialize(symbol, constant)
54
47
  super
55
48
  end
@@ -57,15 +50,13 @@ module Tapioca
57
50
 
58
51
  # @abstract
59
52
  class NodeAdded < Event
60
- extend T::Sig
61
-
62
53
  #: String
63
54
  attr_reader :symbol
64
55
 
65
- #: Module
56
+ #: T::Module[top]
66
57
  attr_reader :constant
67
58
 
68
- #: (String symbol, Module constant) -> void
59
+ #: (String symbol, T::Module[top] constant) -> void
69
60
  def initialize(symbol, constant)
70
61
  super()
71
62
  @symbol = symbol
@@ -74,12 +65,10 @@ module Tapioca
74
65
  end
75
66
 
76
67
  class ConstNodeAdded < NodeAdded
77
- extend T::Sig
78
-
79
68
  #: RBI::Const
80
69
  attr_reader :node
81
70
 
82
- #: (String symbol, Module constant, RBI::Const node) -> void
71
+ #: (String symbol, T::Module[top] constant, RBI::Const node) -> void
83
72
  def initialize(symbol, constant, node)
84
73
  super(symbol, constant)
85
74
  @node = node
@@ -87,12 +76,10 @@ module Tapioca
87
76
  end
88
77
 
89
78
  class ScopeNodeAdded < NodeAdded
90
- extend T::Sig
91
-
92
79
  #: RBI::Scope
93
80
  attr_reader :node
94
81
 
95
- #: (String symbol, Module constant, RBI::Scope node) -> void
82
+ #: (String symbol, T::Module[top] constant, RBI::Scope node) -> void
96
83
  def initialize(symbol, constant, node)
97
84
  super(symbol, constant)
98
85
  @node = node
@@ -102,8 +89,6 @@ module Tapioca
102
89
  class ForeignScopeNodeAdded < ScopeNodeAdded; end
103
90
 
104
91
  class MethodNodeAdded < NodeAdded
105
- extend T::Sig
106
-
107
92
  #: UnboundMethod
108
93
  attr_reader :method
109
94
 
@@ -116,7 +101,14 @@ module Tapioca
116
101
  #: Array[[Symbol, String]]
117
102
  attr_reader :parameters
118
103
 
119
- #: (String symbol, Module constant, UnboundMethod method, RBI::Method node, untyped signature, Array[[Symbol, String]] parameters) -> void
104
+ #: (
105
+ #| String symbol,
106
+ #| T::Module[top] constant,
107
+ #| UnboundMethod method,
108
+ #| RBI::Method node,
109
+ #| untyped signature,
110
+ #| Array[[Symbol, String]] parameters
111
+ #| ) -> void
120
112
  def initialize(symbol, constant, method, node, signature, parameters) # rubocop:disable Metrics/ParameterLists
121
113
  super(symbol, constant)
122
114
  @node = node
@@ -6,7 +6,6 @@ module Tapioca
6
6
  module Listeners
7
7
  # @abstract
8
8
  class Base
9
- extend T::Sig
10
9
  #: (Pipeline pipeline) -> void
11
10
  def initialize(pipeline)
12
11
  @pipeline = pipeline
@@ -5,8 +5,6 @@ module Tapioca
5
5
  module Gem
6
6
  module Listeners
7
7
  class DynamicMixins < Base
8
- extend T::Sig
9
-
10
8
  include Runtime::Reflection
11
9
 
12
10
  private
@@ -5,8 +5,6 @@ module Tapioca
5
5
  module Gem
6
6
  module Listeners
7
7
  class ForeignConstants < Base
8
- extend T::Sig
9
-
10
8
  include Runtime::Reflection
11
9
 
12
10
  private
@@ -5,8 +5,6 @@ module Tapioca
5
5
  module Gem
6
6
  module Listeners
7
7
  class Methods < Base
8
- extend T::Sig
9
-
10
8
  include RBIHelper
11
9
  include Runtime::Reflection
12
10
 
@@ -24,7 +22,13 @@ module Tapioca
24
22
  compile_directly_owned_methods(node, symbol, singleton_class_of(constant), attached_class: constant)
25
23
  end
26
24
 
27
- #: (RBI::Tree tree, String module_name, Module mod, ?Array[Symbol] for_visibility, ?attached_class: Module?) -> void
25
+ #: (
26
+ #| RBI::Tree tree,
27
+ #| String module_name,
28
+ #| T::Module[top] mod,
29
+ #| ?Array[Symbol] for_visibility,
30
+ #| ?attached_class: T::Module[top]?
31
+ #| ) -> void
28
32
  def compile_directly_owned_methods(
29
33
  tree,
30
34
  module_name,
@@ -52,7 +56,13 @@ module Tapioca
52
56
  end
53
57
  end
54
58
 
55
- #: (RBI::Tree tree, String symbol_name, Module constant, UnboundMethod? method, ?RBI::Visibility visibility) -> void
59
+ #: (
60
+ #| RBI::Tree tree,
61
+ #| String symbol_name,
62
+ #| T::Module[top] constant,
63
+ #| UnboundMethod? method,
64
+ #| ?RBI::Visibility visibility
65
+ #| ) -> void
56
66
  def compile_method(tree, symbol_name, constant, method, visibility = RBI::Public.new)
57
67
  return unless method
58
68
  return unless method_owned_by_constant?(method, constant)
@@ -159,7 +169,7 @@ module Tapioca
159
169
  # This method implements a better way of checking whether a constant defines a method.
160
170
  # It walks up the ancestor tree via the `super_method` method; if any of the super
161
171
  # methods are owned by the constant, it means that the constant declares the method.
162
- #: (UnboundMethod method, Module constant) -> bool
172
+ #: (UnboundMethod method, T::Module[top] constant) -> bool
163
173
  def method_owned_by_constant?(method, constant)
164
174
  # Widen the type of `method` to be nilable
165
175
  method = method #: UnboundMethod?
@@ -173,7 +183,7 @@ module Tapioca
173
183
  false
174
184
  end
175
185
 
176
- #: (Module mod) -> Hash[Symbol, Array[Symbol]]
186
+ #: (T::Module[top] mod) -> Hash[Symbol, Array[Symbol]]
177
187
  def method_names_by_visibility(mod)
178
188
  {
179
189
  public: public_instance_methods_of(mod),
@@ -182,7 +192,7 @@ module Tapioca
182
192
  }
183
193
  end
184
194
 
185
- #: (Module constant, String method_name) -> bool
195
+ #: (T::Module[top] constant, String method_name) -> bool
186
196
  def struct_method?(constant, method_name)
187
197
  return false unless T::Props::ClassMethods === constant
188
198
 
@@ -192,7 +202,7 @@ module Tapioca
192
202
  .include?(method_name.gsub(/=$/, "").to_sym)
193
203
  end
194
204
 
195
- #: (Module? attached_class, Symbol method_name) -> bool?
205
+ #: (T::Module[top]? attached_class, Symbol method_name) -> bool?
196
206
  def method_new_in_abstract_class?(attached_class, method_name)
197
207
  attached_class &&
198
208
  method_name == :new &&
@@ -200,7 +210,7 @@ module Tapioca
200
210
  Class === attached_class.singleton_class
201
211
  end
202
212
 
203
- #: (Module constant) -> UnboundMethod?
213
+ #: (T::Module[top] constant) -> UnboundMethod?
204
214
  def initialize_method_for(constant)
205
215
  constant.instance_method(:initialize)
206
216
  rescue