tapioca 0.19.0 → 0.19.1

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tapioca/commands/abstract_dsl.rb +1 -1
  3. data/lib/tapioca/commands/check_shims.rb +3 -0
  4. data/lib/tapioca/commands/configure.rb +1 -0
  5. data/lib/tapioca/commands/todo.rb +8 -2
  6. data/lib/tapioca/dsl/compiler.rb +13 -13
  7. data/lib/tapioca/dsl/compilers/aasm.rb +1 -1
  8. data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +2 -2
  9. data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -1
  10. data/lib/tapioca/dsl/compilers/action_text.rb +1 -1
  11. data/lib/tapioca/dsl/compilers/active_job.rb +1 -1
  12. data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -1
  13. data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +1 -1
  14. data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +1 -1
  15. data/lib/tapioca/dsl/compilers/active_record_associations.rb +1 -1
  16. data/lib/tapioca/dsl/compilers/active_record_columns.rb +1 -1
  17. data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +1 -1
  18. data/lib/tapioca/dsl/compilers/active_record_enum.rb +1 -1
  19. data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +1 -1
  20. data/lib/tapioca/dsl/compilers/active_record_relations.rb +1 -1
  21. data/lib/tapioca/dsl/compilers/active_record_scope.rb +1 -1
  22. data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +1 -1
  23. data/lib/tapioca/dsl/compilers/active_record_store.rb +1 -1
  24. data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +1 -1
  25. data/lib/tapioca/dsl/compilers/active_resource.rb +1 -1
  26. data/lib/tapioca/dsl/compilers/active_storage.rb +2 -2
  27. data/lib/tapioca/dsl/compilers/active_support_concern.rb +6 -6
  28. data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +1 -1
  29. data/lib/tapioca/dsl/compilers/active_support_environment_inquirer.rb +1 -1
  30. data/lib/tapioca/dsl/compilers/active_support_time_ext.rb +1 -1
  31. data/lib/tapioca/dsl/compilers/config.rb +2 -2
  32. data/lib/tapioca/dsl/compilers/frozen_record.rb +1 -1
  33. data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -1
  34. data/lib/tapioca/dsl/compilers/graphql_mutation.rb +1 -1
  35. data/lib/tapioca/dsl/compilers/identity_cache.rb +2 -2
  36. data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +1 -1
  37. data/lib/tapioca/dsl/compilers/kredis.rb +1 -1
  38. data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +2 -2
  39. data/lib/tapioca/dsl/compilers/protobuf.rb +1 -1
  40. data/lib/tapioca/dsl/compilers/rails_generators.rb +1 -1
  41. data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -1
  42. data/lib/tapioca/dsl/compilers/smart_properties.rb +1 -1
  43. data/lib/tapioca/dsl/compilers/state_machines.rb +2 -2
  44. data/lib/tapioca/dsl/compilers/url_helpers.rb +7 -7
  45. data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +1 -1
  46. data/lib/tapioca/dsl/pipeline.rb +10 -10
  47. data/lib/tapioca/gem/events.rb +7 -7
  48. data/lib/tapioca/gem/listeners/methods.rb +8 -8
  49. data/lib/tapioca/gem/listeners/mixins.rb +3 -3
  50. data/lib/tapioca/gem/listeners/sorbet_signatures.rb +5 -3
  51. data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +1 -1
  52. data/lib/tapioca/gem/pipeline.rb +18 -18
  53. data/lib/tapioca/helpers/sorbet_helper.rb +19 -0
  54. data/lib/tapioca/helpers/test/dsl_compiler.rb +2 -9
  55. data/lib/tapioca/internal.rb +1 -0
  56. data/lib/tapioca/rbi_ext/model.rb +8 -5
  57. data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +6 -6
  58. data/lib/tapioca/runtime/generic_type_registry.rb +8 -8
  59. data/lib/tapioca/runtime/reflection.rb +20 -20
  60. data/lib/tapioca/runtime/trackers/constant_definition.rb +3 -3
  61. data/lib/tapioca/runtime/trackers/method_definition.rb +4 -4
  62. data/lib/tapioca/runtime/trackers/mixin.rb +5 -5
  63. data/lib/tapioca/runtime/trackers/required_ancestor.rb +2 -2
  64. data/lib/tapioca/runtime/trackers/tracker.rb +1 -1
  65. data/lib/tapioca/sorbet_ext/generic_name_patch.rb +1 -1
  66. data/lib/tapioca/sorbet_ext/void_patch.rb +29 -0
  67. data/lib/tapioca/static/symbol_loader.rb +19 -1
  68. data/lib/tapioca/version.rb +1 -1
  69. metadata +5 -4
@@ -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 #: T::Module[top]
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: T::Module[top]) -> BasicObject
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
- #: (T::Module[top] constant) -> Array[Symbol]
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
- #: (T::Module[top] constant) -> String?
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
- #: (T::Module[top] constant) -> Class[top]
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
- #: (T::Module[top] constant) -> Array[T::Module[top]]
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) -> T::Module[top]?
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
- #: (T::Module[top] constant) -> Array[Symbol]
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
- #: (T::Module[top] constant) -> Array[Symbol]
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
- #: (T::Module[top] constant) -> Array[Symbol]
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
- #: (T::Module[top] constant) -> Array[T::Module[top]]
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
- #: (T::Module[top] constant) -> String?
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
- #: (T::Module[top] constant, Symbol method) -> Method
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
- #: (T::Module[top] constant) -> Set[String]
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
- #: (T::Module[top] constant) -> untyped
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
- #: (T::Module[top] constant) -> bool
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
- #: (T::Module[top] constant) -> bool
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
- #: (T::Module[top] constant) -> Array[UnboundMethod]
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
- #: (T::Module[top] constant) -> Array[UnboundMethod]
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
- #: (T::Module[top] parent, String name) -> T::Module[top]?
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[T::Module[top], Set[SourceLocation]]
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
- #: (T::Module[top] klass) -> Set[String]
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
- #: (T::Module[top] klass) -> Set[SourceLocation]
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[T::Module[top], Hash[Symbol, Array[SourceLocation]]]
10
+ @method_definitions = {}.compare_by_identity #: Hash[Module[top], Hash[Symbol, Array[SourceLocation]]]
11
11
 
12
12
  class << self
13
- #: (Symbol method_name, T::Module[top] owner, Array[Thread::Backtrace::Location] locations) -> void
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, T::Module[top] owner) -> Array[SourceLocation]
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, T::Module[top] owner) -> Array[SourceLocation]
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
- #: (T::Module[top] constant, T::Module[top] mixin, Type mixin_type) -> void
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
- #: (T::Module[top] mixin) -> Hash[Type, Hash[T::Module[top], String]]
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
- #: (T::Module[top] mixin, Type mixin_type, T::Module[top] constant) -> String?
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
- #: (T::Module[top] constant, T::Module[top] mixin, Type mixin_type, String location) -> void
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
- #: (T::Module[top] mixin) -> Hash[Type, Hash[T::Module[top], String]]
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
- #: (T::Module[top] mod) -> Array[^-> void]
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
- #: (T::Module[top] mod) -> Array[untyped]
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|
@@ -7,7 +7,7 @@ module Tapioca
7
7
  # @abstract
8
8
  module Tracker
9
9
  class << self
10
- #: ((Tracker & T::Module[top]) base) -> void
10
+ #: ((Tracker & Module[top]) base) -> void
11
11
  def extended(base)
12
12
  Trackers.register_tracker(base)
13
13
  base.instance_exec do
@@ -133,7 +133,7 @@ module Tapioca
133
133
  #: Type
134
134
  attr_reader :type
135
135
 
136
- #: (T::Module[top] context, Type type, Symbol variance, (^-> Hash[Symbol, untyped])? bounds_proc) -> void
136
+ #: (Module[top] context, Type type, Symbol variance, (^-> Hash[Symbol, untyped])? bounds_proc) -> void
137
137
  def initialize(context, type, variance, bounds_proc)
138
138
  @context = context
139
139
  @type = type
@@ -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
- sorbet("--no-config", "--quiet", "--print=#{table_type}", input).out
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
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Tapioca
5
- VERSION = "0.19.0"
5
+ VERSION = "0.19.1"
6
6
  end
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.0
4
+ version: 0.19.1
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.5.11087
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.5.11087
112
+ version: 0.6.12698
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: thor
115
115
  requirement: !ruby/object:Gem::Requirement
@@ -307,6 +307,7 @@ files:
307
307
  - lib/tapioca/sorbet_ext/generic_name_patch.rb
308
308
  - lib/tapioca/sorbet_ext/name_patch.rb
309
309
  - lib/tapioca/sorbet_ext/proc_bind_patch.rb
310
+ - lib/tapioca/sorbet_ext/void_patch.rb
310
311
  - lib/tapioca/static/requires_compiler.rb
311
312
  - lib/tapioca/static/symbol_loader.rb
312
313
  - lib/tapioca/static/symbol_table_parser.rb
@@ -330,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
330
331
  - !ruby/object:Gem::Version
331
332
  version: '0'
332
333
  requirements: []
333
- rubygems_version: 4.0.3
334
+ rubygems_version: 4.0.6
334
335
  specification_version: 4
335
336
  summary: A Ruby Interface file generator for gems, core types and the Ruby standard
336
337
  library