rigortype 0.4.8 → 0.4.9

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 (349) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/docs/handbook/01-getting-started.md +1 -1
  4. data/docs/handbook/04-tuples-and-shapes.md +6 -1
  5. data/docs/handbook/12-lightweight-hkt.md +1 -1
  6. data/docs/handbook/appendix-typescript.md +28 -17
  7. data/docs/manual/02-cli-reference.md +10 -0
  8. data/docs/manual/03-configuration.md +1 -1
  9. data/docs/manual/04-diagnostics.md +1 -1
  10. data/docs/manual/10-mcp-server.md +122 -10
  11. data/docs/manual/plugins/rigor-activerecord.md +7 -0
  12. data/lib/rigor/analysis/check_rules/always_raises.rb +95 -0
  13. data/lib/rigor/analysis/check_rules/always_truthy_condition_collector.rb +32 -2
  14. data/lib/rigor/analysis/check_rules/argument_type.rb +802 -0
  15. data/lib/rigor/analysis/check_rules/call_facts.rb +2 -2
  16. data/lib/rigor/analysis/check_rules/dead_assignment_collector.rb +30 -1
  17. data/lib/rigor/analysis/check_rules/declaration_sourced_guard.rb +4 -5
  18. data/lib/rigor/analysis/check_rules/duplicate_hash_key_collector.rb +34 -0
  19. data/lib/rigor/analysis/check_rules/ivar_write_collector.rb +131 -4
  20. data/lib/rigor/analysis/check_rules/nil_receiver.rb +195 -0
  21. data/lib/rigor/analysis/check_rules/override_param_narrowed.rb +111 -0
  22. data/lib/rigor/analysis/check_rules/override_return_widened.rb +88 -0
  23. data/lib/rigor/analysis/check_rules/override_support.rb +246 -0
  24. data/lib/rigor/analysis/check_rules/override_visibility.rb +135 -0
  25. data/lib/rigor/analysis/check_rules/published_constant_guard.rb +75 -31
  26. data/lib/rigor/analysis/check_rules/raise_non_exception.rb +198 -0
  27. data/lib/rigor/analysis/check_rules/receiver_predicates.rb +576 -0
  28. data/lib/rigor/analysis/check_rules/return_in_ensure_collector.rb +52 -4
  29. data/lib/rigor/analysis/check_rules/return_type.rb +225 -0
  30. data/lib/rigor/analysis/check_rules/rigor_testing.rb +119 -0
  31. data/lib/rigor/analysis/check_rules/rule_ids.rb +7 -7
  32. data/lib/rigor/analysis/check_rules/rule_walk.rb +4 -3
  33. data/lib/rigor/analysis/check_rules/self_closedness_scanner.rb +2 -0
  34. data/lib/rigor/analysis/check_rules/self_undefined_method.rb +165 -0
  35. data/lib/rigor/analysis/check_rules/shadowed_rescue_collector.rb +34 -0
  36. data/lib/rigor/analysis/check_rules/source_arity.rb +2 -2
  37. data/lib/rigor/analysis/check_rules/special_global_write.rb +256 -0
  38. data/lib/rigor/analysis/check_rules/suppression.rb +275 -0
  39. data/lib/rigor/analysis/check_rules/undefined_method.rb +882 -0
  40. data/lib/rigor/analysis/check_rules/unreachable_branch.rb +97 -0
  41. data/lib/rigor/analysis/check_rules/unreachable_clause_collector.rb +42 -0
  42. data/lib/rigor/analysis/check_rules/unresolved_toplevel.rb +140 -0
  43. data/lib/rigor/analysis/check_rules/visibility_mismatch.rb +252 -0
  44. data/lib/rigor/analysis/check_rules/void_value_use_collector.rb +27 -0
  45. data/lib/rigor/analysis/check_rules/wrong_arity.rb +303 -0
  46. data/lib/rigor/analysis/check_rules.rb +66 -4931
  47. data/lib/rigor/analysis/dependency_recorder.rb +1 -1
  48. data/lib/rigor/analysis/dependency_source_inference/builder.rb +2 -4
  49. data/lib/rigor/analysis/dependency_source_inference/gem_resolver.rb +1 -2
  50. data/lib/rigor/analysis/dependency_source_inference/walker.rb +15 -15
  51. data/lib/rigor/analysis/incremental_session.rb +4 -4
  52. data/lib/rigor/analysis/path_expansion.rb +1 -1
  53. data/lib/rigor/analysis/plugin_fact_fingerprint.rb +5 -5
  54. data/lib/rigor/analysis/reachability/graph.rb +2 -3
  55. data/lib/rigor/analysis/reachability/plugin_roots.rb +2 -2
  56. data/lib/rigor/analysis/reachability/scan.rb +2 -2
  57. data/lib/rigor/analysis/rule_catalog.rb +2 -1
  58. data/lib/rigor/analysis/run_cache_key.rb +9 -8
  59. data/lib/rigor/analysis/runner/buffer_pool_dispatcher.rb +2 -2
  60. data/lib/rigor/analysis/runner/dependency_rows.rb +206 -0
  61. data/lib/rigor/analysis/runner/diagnostic_aggregator.rb +24 -22
  62. data/lib/rigor/analysis/runner/effect_cache_entries.rb +69 -0
  63. data/lib/rigor/analysis/runner/pool_coordinator.rb +6 -8
  64. data/lib/rigor/analysis/runner/project_pre_passes.rb +3 -5
  65. data/lib/rigor/analysis/runner/scope_seed.rb +144 -0
  66. data/lib/rigor/analysis/runner.rb +49 -296
  67. data/lib/rigor/analysis/template_unit_collector.rb +1 -1
  68. data/lib/rigor/analysis/template_units.rb +10 -10
  69. data/lib/rigor/analysis/worker_session.rb +7 -7
  70. data/lib/rigor/bleeding_edge.rb +3 -2
  71. data/lib/rigor/builtins/hkt_builtins.rb +17 -17
  72. data/lib/rigor/builtins/imported_refinements.rb +8 -16
  73. data/lib/rigor/builtins/regex_refinement.rb +3 -3
  74. data/lib/rigor/builtins/static_return_refinements.rb +143 -19
  75. data/lib/rigor/cache/incremental_snapshot.rb +21 -8
  76. data/lib/rigor/cache/rbs_descriptor.rb +18 -1
  77. data/lib/rigor/cli/coverage_renderer.rb +15 -1
  78. data/lib/rigor/cli/coverage_report.rb +19 -1
  79. data/lib/rigor/cli/diagnostic_formats.rb +3 -2
  80. data/lib/rigor/cli/docs_command.rb +5 -5
  81. data/lib/rigor/cli/effects_command.rb +7 -6
  82. data/lib/rigor/cli/fused_protection_report.rb +7 -7
  83. data/lib/rigor/cli/lsp_command.rb +1 -1
  84. data/lib/rigor/cli/mcp_command.rb +5 -2
  85. data/lib/rigor/cli/options.rb +4 -0
  86. data/lib/rigor/cli/plugins_command.rb +1 -1
  87. data/lib/rigor/cli/sig_gen_command.rb +1 -1
  88. data/lib/rigor/cli/skill_command.rb +5 -4
  89. data/lib/rigor/cli/triage_renderer.rb +3 -2
  90. data/lib/rigor/cli/unused_command.rb +4 -4
  91. data/lib/rigor/cli.rb +14 -0
  92. data/lib/rigor/configuration/coercion.rb +418 -0
  93. data/lib/rigor/configuration/defaults.rb +248 -0
  94. data/lib/rigor/configuration/dependencies.rb +1 -1
  95. data/lib/rigor/configuration/loader.rb +354 -0
  96. data/lib/rigor/configuration/severity_profile.rb +4 -4
  97. data/lib/rigor/configuration.rb +51 -860
  98. data/lib/rigor/effects/attribution.rb +1 -1
  99. data/lib/rigor/effects/effect_table.rb +1 -1
  100. data/lib/rigor/effects/identity.rb +3 -3
  101. data/lib/rigor/effects/local_ownership.rb +2 -2
  102. data/lib/rigor/effects/snapshot.rb +1 -1
  103. data/lib/rigor/effects/summary.rb +5 -4
  104. data/lib/rigor/environment/member_consistency.rb +10 -0
  105. data/lib/rigor/environment/rbs_loader.rb +19 -22
  106. data/lib/rigor/environment/reflection.rb +1 -1
  107. data/lib/rigor/environment/unreadable_signature.rb +21 -0
  108. data/lib/rigor/environment.rb +8 -8
  109. data/lib/rigor/flow_contribution/merger.rb +1 -0
  110. data/lib/rigor/hashing/xxh3.rb +1 -1
  111. data/lib/rigor/inference/acceptance.rb +23 -2
  112. data/lib/rigor/inference/alias_mutation_floor/site_collector.rb +5 -0
  113. data/lib/rigor/inference/alias_mutation_floor.rb +0 -5
  114. data/lib/rigor/inference/anonymous_meta_class.rb +2 -2
  115. data/lib/rigor/inference/block_call_timing.rb +6 -0
  116. data/lib/rigor/inference/budget_trace.rb +3 -2
  117. data/lib/rigor/inference/builtins/date_catalog.rb +3 -3
  118. data/lib/rigor/inference/builtins/method_catalog.rb +3 -3
  119. data/lib/rigor/inference/builtins/time_catalog.rb +3 -3
  120. data/lib/rigor/inference/call_ladder/literal_send.rb +98 -0
  121. data/lib/rigor/inference/call_ladder/overriding_def.rb +98 -0
  122. data/lib/rigor/inference/call_ladder/project_singleton.rb +362 -0
  123. data/lib/rigor/inference/call_ladder/refined.rb +212 -0
  124. data/lib/rigor/inference/call_ladder/top_level_def.rb +222 -0
  125. data/lib/rigor/inference/call_ladder/user_method.rb +247 -0
  126. data/lib/rigor/inference/call_ladder.rb +219 -0
  127. data/lib/rigor/inference/callee_write_census.rb +2 -2
  128. data/lib/rigor/inference/captured_locals.rb +2 -2
  129. data/lib/rigor/inference/clause_widening.rb +63 -1
  130. data/lib/rigor/inference/declaration_walk/context.rb +12 -12
  131. data/lib/rigor/inference/declaration_walk/rules.rb +750 -0
  132. data/lib/rigor/inference/declaration_walk/traversal.rb +9 -8
  133. data/lib/rigor/inference/declaration_walk.rb +4 -3
  134. data/lib/rigor/inference/def_node_resolver.rb +2 -2
  135. data/lib/rigor/inference/def_return_typer.rb +14 -6
  136. data/lib/rigor/inference/deferred_mutation.rb +120 -0
  137. data/lib/rigor/inference/define_method_block_self.rb +1 -1
  138. data/lib/rigor/inference/definer_resolution.rb +4 -4
  139. data/lib/rigor/inference/error_info.rb +8 -8
  140. data/lib/rigor/inference/expression_typer/composites.rb +348 -0
  141. data/lib/rigor/inference/expression_typer/per_element_assemblers.rb +233 -0
  142. data/lib/rigor/inference/expression_typer/writes.rb +218 -0
  143. data/lib/rigor/inference/expression_typer.rb +275 -1825
  144. data/lib/rigor/inference/external_ancestor_resolution.rb +2 -2
  145. data/lib/rigor/inference/fallback.rb +1 -0
  146. data/lib/rigor/inference/for_yield_slots.rb +126 -0
  147. data/lib/rigor/inference/genuine_send.rb +92 -0
  148. data/lib/rigor/inference/global_write_census.rb +2 -2
  149. data/lib/rigor/inference/hkt_body.rb +2 -0
  150. data/lib/rigor/inference/in_effect_refinements/walk.rb +2 -2
  151. data/lib/rigor/inference/index_write_widening.rb +4 -4
  152. data/lib/rigor/inference/indexed_narrowing.rb +1 -1
  153. data/lib/rigor/inference/intervening_ivar_reset.rb +46 -9
  154. data/lib/rigor/inference/ivar_writer_census.rb +1 -1
  155. data/lib/rigor/inference/loop_store_sites.rb +239 -0
  156. data/lib/rigor/inference/macro_block_self_type.rb +4 -3
  157. data/lib/rigor/inference/method_dispatcher/block_folding.rb +3 -2
  158. data/lib/rigor/inference/method_dispatcher/call_context.rb +84 -14
  159. data/lib/rigor/inference/method_dispatcher/composite_receiver.rb +144 -0
  160. data/lib/rigor/inference/method_dispatcher/constant_folding.rb +7 -5
  161. data/lib/rigor/inference/method_dispatcher/declared_constructor.rb +1 -1
  162. data/lib/rigor/inference/method_dispatcher/dependency_source.rb +90 -0
  163. data/lib/rigor/inference/method_dispatcher/discovered_method.rb +78 -0
  164. data/lib/rigor/inference/method_dispatcher/file_folding.rb +2 -2
  165. data/lib/rigor/inference/method_dispatcher/hkt_builtin_return.rb +40 -0
  166. data/lib/rigor/inference/method_dispatcher/iterator_dispatch.rb +1 -6
  167. data/lib/rigor/inference/method_dispatcher/literal_string_folding.rb +4 -2
  168. data/lib/rigor/inference/method_dispatcher/match_data_folding.rb +1 -1
  169. data/lib/rigor/inference/method_dispatcher/meta_introspection.rb +506 -0
  170. data/lib/rigor/inference/method_dispatcher/overload_selector.rb +2 -0
  171. data/lib/rigor/inference/method_dispatcher/plugin_contribution.rb +134 -0
  172. data/lib/rigor/inference/method_dispatcher/project_patched.rb +134 -0
  173. data/lib/rigor/inference/method_dispatcher/rbs_dispatch.rb +125 -43
  174. data/lib/rigor/inference/method_dispatcher/reduce_folding.rb +3 -4
  175. data/lib/rigor/inference/method_dispatcher/regexp_folding.rb +1 -1
  176. data/lib/rigor/inference/method_dispatcher/set_folding.rb +1 -1
  177. data/lib/rigor/inference/method_dispatcher/shape_dispatch.rb +19 -6
  178. data/lib/rigor/inference/method_dispatcher/singleton_folding.rb +3 -3
  179. data/lib/rigor/inference/method_dispatcher/singleton_mixin_dispatch.rb +7 -4
  180. data/lib/rigor/inference/method_dispatcher/static_refinement.rb +106 -0
  181. data/lib/rigor/inference/method_dispatcher/synthesized_stub.rb +41 -0
  182. data/lib/rigor/inference/method_dispatcher/synthetic_method_dispatch.rb +133 -0
  183. data/lib/rigor/inference/method_dispatcher/universal_object_dispatch.rb +2 -1
  184. data/lib/rigor/inference/method_dispatcher/user_class_fallback.rb +216 -0
  185. data/lib/rigor/inference/method_dispatcher.rb +175 -1361
  186. data/lib/rigor/inference/method_parameter_binder.rb +18 -18
  187. data/lib/rigor/inference/module_function_state.rb +5 -4
  188. data/lib/rigor/inference/mutation_widening.rb +20 -7
  189. data/lib/rigor/inference/narrowing/case_literals.rb +58 -0
  190. data/lib/rigor/inference/narrowing/class_dispatch.rb +302 -0
  191. data/lib/rigor/inference/narrowing/complements.rb +322 -0
  192. data/lib/rigor/inference/narrowing/presence_predicates.rb +205 -0
  193. data/lib/rigor/inference/narrowing/regex_match.rb +499 -0
  194. data/lib/rigor/inference/narrowing.rb +86 -1269
  195. data/lib/rigor/inference/object_mixins.rb +2 -2
  196. data/lib/rigor/inference/opaque_mutation.rb +214 -0
  197. data/lib/rigor/inference/optimistic_origin.rb +52 -14
  198. data/lib/rigor/inference/parameter_inference_collector.rb +1 -1
  199. data/lib/rigor/inference/pre_eval_constants.rb +11 -9
  200. data/lib/rigor/inference/precision_scanner.rb +27 -2
  201. data/lib/rigor/inference/project_patched_methods.rb +3 -3
  202. data/lib/rigor/inference/range_constant.rb +3 -3
  203. data/lib/rigor/inference/rbs_type_translator.rb +2 -2
  204. data/lib/rigor/inference/refine_self.rb +8 -7
  205. data/lib/rigor/inference/refined_dispatch.rb +2 -2
  206. data/lib/rigor/inference/return_barrier.rb +24 -9
  207. data/lib/rigor/inference/scope_indexer/alias_def_nodes.rb +311 -0
  208. data/lib/rigor/inference/scope_indexer/census_scope.rb +47 -0
  209. data/lib/rigor/inference/scope_indexer/certainty.rb +2 -2
  210. data/lib/rigor/inference/scope_indexer/class_cvar_census.rb +282 -0
  211. data/lib/rigor/inference/scope_indexer/class_cvars_collector.rb +12 -5
  212. data/lib/rigor/inference/scope_indexer/class_declarations.rb +228 -0
  213. data/lib/rigor/inference/scope_indexer/class_ivar_index.rb +2028 -0
  214. data/lib/rigor/inference/scope_indexer/constant_ivar_value.rb +4 -3
  215. data/lib/rigor/inference/scope_indexer/constant_tables.rb +844 -0
  216. data/lib/rigor/inference/scope_indexer/cvar_hierarchy.rb +159 -0
  217. data/lib/rigor/inference/scope_indexer/declaration_artifacts.rb +219 -0
  218. data/lib/rigor/inference/scope_indexer/declaration_signature.rb +212 -0
  219. data/lib/rigor/inference/scope_indexer/def_nestings_collector.rb +2 -2
  220. data/lib/rigor/inference/scope_indexer/factory_call_resolver.rb +53 -0
  221. data/lib/rigor/inference/scope_indexer/literal_receiver_mutations.rb +266 -0
  222. data/lib/rigor/inference/scope_indexer/member_layouts_collector.rb +8 -7
  223. data/lib/rigor/inference/scope_indexer/mixin_accumulator.rb +1 -1
  224. data/lib/rigor/inference/scope_indexer/mixin_effects.rb +470 -0
  225. data/lib/rigor/inference/scope_indexer/mixin_tables.rb +388 -0
  226. data/lib/rigor/inference/scope_indexer/mutated_carrier_widening.rb +163 -0
  227. data/lib/rigor/inference/scope_indexer/mutated_element_census.rb +211 -0
  228. data/lib/rigor/inference/scope_indexer/node_propagation.rb +520 -0
  229. data/lib/rigor/inference/scope_indexer/program_globals.rb +154 -0
  230. data/lib/rigor/inference/scope_indexer/published_constant_cvars.rb +146 -0
  231. data/lib/rigor/inference/scope_indexer/published_constant_ivars.rb +181 -0
  232. data/lib/rigor/inference/scope_indexer/shared_walk_tables.rb +823 -0
  233. data/lib/rigor/inference/scope_indexer/singleton_class_sources.rb +85 -0
  234. data/lib/rigor/inference/scope_indexer/superclasses_collector.rb +5 -5
  235. data/lib/rigor/inference/scope_indexer.rb +2657 -9558
  236. data/lib/rigor/inference/self_call_ivar_writes.rb +22 -3
  237. data/lib/rigor/inference/set_mutation.rb +2 -2
  238. data/lib/rigor/inference/singleton_hook_definers.rb +185 -0
  239. data/lib/rigor/inference/statement_evaluator/def_arguments_and_assertions.rb +365 -0
  240. data/lib/rigor/inference/statement_evaluator/pattern_bindings.rb +581 -0
  241. data/lib/rigor/inference/statement_evaluator.rb +201 -1008
  242. data/lib/rigor/inference/synthetic_method_scanner.rb +0 -3
  243. data/lib/rigor/language_server/completion_provider.rb +8 -8
  244. data/lib/rigor/language_server/diagnostic_publisher.rb +6 -7
  245. data/lib/rigor/language_server/document_symbol_provider.rb +4 -6
  246. data/lib/rigor/language_server/folding_range_provider.rb +3 -3
  247. data/lib/rigor/language_server/hover_provider.rb +2 -2
  248. data/lib/rigor/language_server/loop.rb +2 -2
  249. data/lib/rigor/language_server/server.rb +3 -2
  250. data/lib/rigor/language_server/signature_help_provider.rb +7 -9
  251. data/lib/rigor/lens/document.rb +10 -1
  252. data/lib/rigor/lens/file_reader.rb +2 -1
  253. data/lib/rigor/mcp/loop.rb +48 -6
  254. data/lib/rigor/mcp/server.rb +248 -23
  255. data/lib/rigor/mcp/skill_catalog.rb +157 -0
  256. data/lib/rigor/plugin/base.rb +22 -4
  257. data/lib/rigor/plugin/effect_attribution.rb +1 -1
  258. data/lib/rigor/plugin/inflector.rb +2 -2
  259. data/lib/rigor/plugin/io_boundary.rb +1 -1
  260. data/lib/rigor/plugin/loader.rb +4 -4
  261. data/lib/rigor/plugin/macro/heredoc_template.rb +4 -3
  262. data/lib/rigor/plugin/optimistic_return.rb +20 -0
  263. data/lib/rigor/plugin/registry.rb +2 -2
  264. data/lib/rigor/plugin/template_unit.rb +4 -2
  265. data/lib/rigor/plugin/trust_policy.rb +2 -1
  266. data/lib/rigor/plugin.rb +1 -1
  267. data/lib/rigor/protection/mutator.rb +8 -9
  268. data/lib/rigor/rbs_extended/reporter.rb +2 -2
  269. data/lib/rigor/rbs_extended.rb +2 -2
  270. data/lib/rigor/reflection/constant_ancestors.rb +1 -1
  271. data/lib/rigor/reflection/project_method.rb +2 -2
  272. data/lib/rigor/reflection.rb +4 -4
  273. data/lib/rigor/scope/discovery_index.rb +15 -10
  274. data/lib/rigor/scope/resolution_chain.rb +29 -6
  275. data/lib/rigor/scope.rb +89 -32
  276. data/lib/rigor/sig_gen/generator.rb +5 -4
  277. data/lib/rigor/sig_gen/renderer.rb +3 -3
  278. data/lib/rigor/sig_gen/writer.rb +8 -6
  279. data/lib/rigor/source/parameter_envelope.rb +1 -1
  280. data/lib/rigor/triage/catalogue.rb +4 -4
  281. data/lib/rigor/type/combinator.rb +2 -2
  282. data/lib/rigor/type/data_instance.rb +2 -2
  283. data/lib/rigor/type/struct_instance.rb +3 -3
  284. data/lib/rigor/type_node/generic.rb +2 -1
  285. data/lib/rigor/type_of_memo.rb +2 -1
  286. data/lib/rigor/typing_state.rb +3 -2
  287. data/lib/rigor/version.rb +1 -1
  288. data/plugins/rigor-actioncable/lib/rigor/plugin/actioncable/analyzer.rb +2 -2
  289. data/plugins/rigor-actioncable/lib/rigor/plugin/actioncable/channel_discoverer.rb +1 -1
  290. data/plugins/rigor-actionmailer/lib/rigor/plugin/actionmailer/mailer_discoverer.rb +4 -4
  291. data/plugins/rigor-actionmailer/lib/rigor/plugin/actionmailer.rb +1 -1
  292. data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/controller_discoverer.rb +4 -3
  293. data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/effects.rb +7 -5
  294. data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/erb_compiler.rb +4 -2
  295. data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/render_locals.rb +1 -1
  296. data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/view_assigns.rb +3 -2
  297. data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack.rb +7 -7
  298. data/plugins/rigor-activejob/lib/rigor/plugin/activejob/job_discoverer.rb +1 -1
  299. data/plugins/rigor-activejob/lib/rigor/plugin/activejob.rb +2 -2
  300. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/model_discoverer.rb +9 -8
  301. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/model_index.rb +3 -2
  302. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/schema_parser.rb +15 -7
  303. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/schema_table.rb +10 -3
  304. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/structure_sql_parser.rb +12 -1
  305. data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord.rb +20 -5
  306. data/plugins/rigor-activestorage/lib/rigor/plugin/activestorage/attachment_discoverer.rb +1 -1
  307. data/plugins/rigor-activestorage/lib/rigor/plugin/activestorage.rb +3 -2
  308. data/plugins/rigor-activesupport-core-ext/lib/rigor/plugin/activesupport_core_ext/effects.rb +1 -1
  309. data/plugins/rigor-activesupport-core-ext/lib/rigor/plugin/activesupport_core_ext.rb +8 -7
  310. data/plugins/rigor-dry-schema/lib/rigor/plugin/dry_schema.rb +1 -1
  311. data/plugins/rigor-dry-types/lib/rigor/plugin/dry_types/alias_scanner.rb +1 -1
  312. data/plugins/rigor-dry-types/lib/rigor/plugin/dry_types.rb +6 -7
  313. data/plugins/rigor-factorybot/lib/rigor/plugin/factorybot/factory_discoverer.rb +3 -2
  314. data/plugins/rigor-graphql/lib/rigor/plugin/graphql/type_scanner.rb +4 -3
  315. data/plugins/rigor-hanami/lib/rigor/plugin/hanami.rb +4 -2
  316. data/plugins/rigor-minitest/lib/rigor/plugin/minitest.rb +1 -1
  317. data/plugins/rigor-pundit/lib/rigor/plugin/pundit.rb +1 -1
  318. data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n/analyzer.rb +5 -3
  319. data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n.rb +1 -1
  320. data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/devise_routes.rb +4 -5
  321. data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/doorkeeper_routes.rb +2 -2
  322. data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/helper_discoverer.rb +5 -4
  323. data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/helper_table.rb +3 -2
  324. data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/routes_parser.rb +30 -31
  325. data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes.rb +13 -15
  326. data/plugins/rigor-rbnacl/lib/rigor/plugin/rbnacl.rb +1 -1
  327. data/plugins/rigor-rspec/lib/rigor/plugin/rspec/let_scope_index.rb +4 -3
  328. data/plugins/rigor-rspec/lib/rigor/plugin/rspec/matcher_analyzer.rb +16 -13
  329. data/plugins/rigor-rspec/lib/rigor/plugin/rspec/scope_walker.rb +3 -2
  330. data/plugins/rigor-shoulda-matchers/lib/rigor/plugin/shoulda_matchers/analyzer.rb +6 -6
  331. data/plugins/rigor-sidekiq/lib/rigor/plugin/sidekiq/analyzer.rb +3 -3
  332. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/assertion_recognizer.rb +2 -2
  333. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/catalog.rb +3 -2
  334. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/catalog_walker.rb +6 -5
  335. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/sig_parser.rb +2 -2
  336. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/sigil_detector.rb +4 -5
  337. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/type_translator.rb +1 -1
  338. data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet.rb +3 -4
  339. data/sig/rigor/analysis/check_rules/suppression.rbs +9 -0
  340. data/sig/rigor/analysis/dependency_recorder.rbs +9 -0
  341. data/sig/rigor/inference.rbs +275 -11
  342. data/sig/rigor/plugin/base.rbs +14 -5
  343. data/sig/rigor/plugin/optimistic_return.rbs +16 -0
  344. data/sig/rigor/scope.rbs +7 -1
  345. data/sig/rigor/source.rbs +4 -0
  346. data/skills/rigor-mcp-setup/SKILL.md +20 -6
  347. data/skills/rigor-plugin-review/SKILL.md +3 -3
  348. data/skills/rigor-type-oracle/references/01-oracle-commands.md +1 -1
  349. metadata +90 -3
@@ -0,0 +1,802 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "prism"
4
+ require "rbs"
5
+ require_relative "../../reflection"
6
+ require_relative "../../rbs_extended"
7
+ require_relative "../../type"
8
+ require_relative "../../inference/acceptance"
9
+ require_relative "../../inference/rbs_type_translator"
10
+ require_relative "../../inference/method_dispatcher/singleton_type_params"
11
+ require_relative "../diagnostic"
12
+ require_relative "declaration_sourced_guard"
13
+ require_relative "nil_receiver"
14
+ require_relative "receiver_predicates"
15
+ require_relative "rule_ids"
16
+ require_relative "wrong_arity"
17
+
18
+ module Rigor
19
+ module Analysis
20
+ module CheckRules
21
+ # ADR-116 WD1 — `call.argument-type-mismatch` (v0.0.2 #4): an explicit-receiver call whose positional
22
+ # argument the RBS parameter at its position provably rejects, on the single-overload exact channel and
23
+ # the multi-overload nil / non-nil channels, with the declines the rule has accumulated.
24
+ #
25
+ # The entry point is {.diagnostic}, called by `CheckRules.call_node_diagnostics`. It reads
26
+ # {ReceiverPredicates}, {DeclarationSourcedGuard}, {NilReceiver} (`union_contains_nil?`,
27
+ # `nil_class_has_method?`) and {WrongArity} (`plain_positional_call?`), and calls nothing in
28
+ # `CheckRules`.
29
+ # rubocop:disable-next Metrics/ModuleLength
30
+ module ArgumentType
31
+ module_function
32
+
33
+ # v0.0.2 #4 — argument-type-mismatch diagnostic.
34
+ # Walks a call's positional arguments and checks each
35
+ # against the matching parameter's RBS type via
36
+ # `Rigor::Inference::Acceptance`. Emits an `:error`
37
+ # for the first argument whose type the parameter
38
+ # does NOT accept under the gradual mode.
39
+ #
40
+ # Conservative envelope (matches the wrong-arity rule
41
+ # plus a few additional skips):
42
+ # - Receiver must be Nominal / Singleton / Constant
43
+ # (the same `concrete_class_name` test).
44
+ # - Method must be in RBS.
45
+ # - Overloads: a single method type is checked exactly; with several, an argument is a mismatch only
46
+ # when every overload rejects it ({#multi_overload_argument_mismatch}).
47
+ # - The overload checked must have NO
48
+ # rest_positionals and NO trailing positionals —
49
+ # the two shapes under which argument N no longer
50
+ # binds to positional parameter N. Keyword
51
+ # parameters do not disqualify it (#673).
52
+ # - The call must use plain positional arguments
53
+ # (no splat / kw / block-pass / forwarded).
54
+ # - Per-argument: skip when EITHER side is `Dynamic`
55
+ # (the call cannot be statically refuted).
56
+ # Ruby's universal-equality methods accept any object
57
+ # per the `Object#==(other) → bool` /
58
+ # `Object#eql?(other) → bool` contract. Even when a
59
+ # subclass overrides `==` to compare specific shapes
60
+ # (URI::Generic#==(URI::Generic), Time#==(Time), …),
61
+ # the runtime convention is to RETURN false for
62
+ # type-mismatched arguments rather than raise. RBS sigs
63
+ # that declare a tight parameter type therefore over-
64
+ # specify; checking arguments against them produces
65
+ # spurious mismatches such as
66
+ # `URI::Generic#==(URI::Generic)`
67
+ # called with `URI::HTTP | nil`
68
+ # tdiary-core's `config_uri == referer_uri` (where
69
+ # `referer_uri` is `URI.parse(...) if condition`, hence
70
+ # union-with-nil) is the canonical case. Skip arg
71
+ # checking on these methods entirely; the call is
72
+ # well-formed by Ruby's contract.
73
+ UNIVERSAL_EQUALITY_METHODS = %i[== != eql? equal? <=>].to_set.freeze
74
+ private_constant :UNIVERSAL_EQUALITY_METHODS
75
+
76
+ # ADR-64 WD1 — the binary arithmetic / bit / ordering operators
77
+ # dispatch through Ruby's `coerce` protocol (and `<=>` for the
78
+ # comparisons): `5 + Money.new` is valid at runtime because
79
+ # `Integer#+` calls `Money#coerce(5)`, even though no RBS `Integer#+`
80
+ # overload lists `Money`. A non-`Numeric` argument to them is therefore
81
+ # NOT statically refutable — any user type may define `coerce` — so the
82
+ # *non-nil* argument-type-mismatch channel excludes them (a fixed
83
+ # allow-list, modelled on {UNIVERSAL_EQUALITY_METHODS}, not `coerce`
84
+ # detection). `nil` never coerces, so the nil channel stays in force
85
+ # here; the exclusion applies to the non-nil case only. `<=>` and the
86
+ # `==` family are already excluded wholesale by
87
+ # {UNIVERSAL_EQUALITY_METHODS}.
88
+ COERCE_DISPATCH_METHODS = %i[+ - * / % ** & | ^ << >> < > <= >=].to_set.freeze
89
+ private_constant :COERCE_DISPATCH_METHODS
90
+
91
+ def diagnostic(path, call_node, facts, lexical_sites = nil)
92
+ return nil if call_node.receiver.nil?
93
+ return nil if UNIVERSAL_EQUALITY_METHODS.include?(call_node.name)
94
+ return nil unless WrongArity.plain_positional_call?(call_node)
95
+
96
+ scope = facts.scope
97
+ return nil if scope.nil?
98
+
99
+ receiver_type = facts.receiver_type
100
+ class_name = ReceiverPredicates.concrete_class_name(receiver_type)
101
+ return nil if class_name.nil?
102
+
103
+ # NOTE: unlike the undefined-method / wrong-arity
104
+ # rules, we deliberately do NOT skip when
105
+ # `discovered_method?` matches. When the user
106
+ # supplies BOTH a `def` and an RBS sig, the sig is
107
+ # the authoritative parameter contract and we
108
+ # should validate calls against it.
109
+ return nil unless Rigor::Reflection.rbs_class_known?(class_name, scope: scope)
110
+ return nil unless ReceiverPredicates.definition_available?(receiver_type, class_name, scope)
111
+
112
+ method_def = ReceiverPredicates.receiver_signature(facts)
113
+ return nil if method_def.nil?
114
+
115
+ param_overrides = Rigor::RbsExtended.param_type_override_map(method_def, environment: scope.environment)
116
+ mismatch = argument_mismatch(method_def.method_types, call_node, scope, param_overrides, facts.scope_index)
117
+ return nil if mismatch.nil?
118
+ return nil if argument_report_withheld?(receiver_type, class_name, call_node, mismatch, scope, lexical_sites)
119
+
120
+ build_argument_type_diagnostic(path, call_node, class_name, mismatch)
121
+ end
122
+
123
+ # The declines `call.argument-type-mismatch` asks only once an argument mismatches.
124
+ def argument_report_withheld?(receiver_type, class_name, call_node, mismatch, scope, lexical_sites)
125
+ return true if inferred_param_mismatch_verdict?(call_node, mismatch, scope)
126
+
127
+ kind = receiver_type.is_a?(Type::Singleton) ? :singleton : :instance
128
+ ReceiverPredicates.refined_redefinition_in_effect?(class_name, call_node, scope, kind, lexical_sites)
129
+ end
130
+
131
+ # ADR-67 WD6b — an argument-type-mismatch verdict resting on an open-call-site lower bound, on
132
+ # either side of the call. The ARGUMENT side: the mismatching argument is an inferred-parameter
133
+ # local, so firing against it is an FP by construction. The RECEIVER side: when the receiver roots
134
+ # at an inferred parameter, the method whose parameter contract the argument was checked against
135
+ # was itself resolved through a lower-bound type, so the whole verdict is speculative. The 2026-07-30
136
+ # self-check surfaced the receiver half as a guard hole: seeding `env : RBS::Environment` activated
137
+ # this rule on `env.unload(culprits)` and flagged a correct Array argument against `unload`'s
138
+ # declared `Set[Pathname]` — an upstream signature stricter than its implementation, exactly the FP
139
+ # class WD6b exists to suppress. The other guarded rules already declined on a param-rooted
140
+ # receiver; this brings argument-type-mismatch in line.
141
+ def inferred_param_mismatch_verdict?(call_node, mismatch, scope)
142
+ ReceiverPredicates.inferred_param_argument?(mismatch[:node], scope) ||
143
+ ReceiverPredicates.inferred_param_receiver?(call_node, scope)
144
+ end
145
+
146
+ # Single overload → the exact per-argument acceptance (unchanged).
147
+ # Multiple overloads → the nil channel (a pure-`nil` argument every
148
+ # overload rejects) plus, on non-coerce methods, the non-nil channel
149
+ # (a single-concrete-class argument every overload rejects). See
150
+ # {#multi_overload_argument_mismatch}.
151
+ #
152
+ # Each argument is typed from its own index entry, which is the call's unless an earlier operand moved
153
+ # the scope it was entered from (issue #1256): `(k = 0; 5)[k]` checks `k` as the `0` it holds there.
154
+ def argument_mismatch(method_types, call_node, scope, param_overrides, scope_index)
155
+ mismatch =
156
+ if method_types.size == 1
157
+ first_argument_mismatch(method_types.first, call_node, scope, param_overrides, scope_index)
158
+ else
159
+ multi_overload_argument_mismatch(method_types, call_node, scope, param_overrides, scope_index)
160
+ end
161
+ return nil if mismatch && keyword_bearing?(method_types) && nil_tainted?(mismatch[:actual])
162
+
163
+ mismatch
164
+ end
165
+
166
+ # Issue #673 widened {#argument_check_eligible?} to admit keyword-bearing signatures, whose
167
+ # POSITIONAL arguments had gone unchecked. The widening is staged, and this is the half held
168
+ # back: on such a signature only an argument refuted on its CLASS fires; one carrying `nil`
169
+ # does not.
170
+ #
171
+ # Measured, not assumed. Across redmine, mastodon, tdiary-core, faraday, liquid and
172
+ # rubocop-ast the widening produced exactly two new verdicts, both on correct code and both
173
+ # resting on nullability: `Addrinfo.foreach(host, nil, nil, :STREAM)` (redmine — a nil service
174
+ # is legal at runtime; rbs declares the parameter `String | ::Integer`) and
175
+ # `Nokogiri::HTML5(html)` guarded by `return if html.nil?` one line above (mastodon — the guard
176
+ # is on a method call, so the type stays `Dynamic[top]?`). Zero class-refuted new verdicts were
177
+ # false. Nullability is the property a hand-written signature most often over-declares, so it
178
+ # stays behind the old envelope until it has evidence of its own.
179
+ #
180
+ # Signatures WITHOUT keywords are untouched: `"a" + nil` fires exactly as before.
181
+ def keyword_bearing?(method_types)
182
+ method_types.any? do |method_type|
183
+ function = method_type.type
184
+ next false unless function.respond_to?(:required_keywords)
185
+
186
+ !function.required_keywords.empty? || !function.optional_keywords.empty? ||
187
+ !function.rest_keywords.nil?
188
+ end
189
+ end
190
+
191
+ def nil_tainted?(actual)
192
+ ReceiverPredicates.nil_member?(actual) ||
193
+ (actual.is_a?(Type::Union) && NilReceiver.union_contains_nil?(actual))
194
+ end
195
+
196
+ # Multi-overload argument-type-mismatch. The dispatcher's per-overload
197
+ # acceptance plumbing is not run here; instead the FP-safe shape mirrors
198
+ # the "absent on every arm" union-undefined-method rule: an argument is
199
+ # a mismatch only when EVERY overload's matching positional param
200
+ # rejects it.
201
+ #
202
+ # Two channels, both gated on a positively-refuted argument:
203
+ # - **nil** (any method): a pure `nil` no overload admits is a
204
+ # guaranteed `TypeError` — `nil` never coerces.
205
+ # - **non-nil** (ADR-64, non-coerce methods only): an argument that
206
+ # types to a single concrete RBS-known class that no overload admits.
207
+ # Excludes {COERCE_DISPATCH_METHODS} (`5 + Money.new` is valid via
208
+ # `coerce`), restricts to a single concrete class (WD3 — a union arg
209
+ # stays deferred), and decides acceptance on the RBS param type
210
+ # ({#param_accepts_arg_class?}) so it sees through the `int` / `string`
211
+ # interface-aliases the translator degrades.
212
+ def multi_overload_argument_mismatch(method_types, call_node, scope, param_overrides, scope_index)
213
+ functions = method_types.map(&:type)
214
+ return nil unless functions.all? { |function| argument_check_eligible?(function) }
215
+
216
+ coerce_method = COERCE_DISPATCH_METHODS.include?(call_node.name)
217
+ arguments = call_node.arguments&.arguments || []
218
+ arguments.each_with_index do |arg, index|
219
+ params = checkable_overload_params(method_types, index, param_overrides, scope)
220
+ next if params.nil?
221
+
222
+ mismatch = overload_argument_mismatch(arg, params, param_overrides,
223
+ argument_scope(arg, scope, scope_index), coerce_method)
224
+ return mismatch if mismatch
225
+ end
226
+ nil
227
+ end
228
+
229
+ # The mismatch (or nil) for one argument against the parameter every overload has at its position. Issue
230
+ # #1362 — a builtin global's seed, or its copy, is judged by the file's writes to the global.
231
+ def overload_argument_mismatch(arg, params, param_overrides, arg_scope, coerce_method)
232
+ written = DeclarationSourcedGuard.written_type(arg, arg_scope)
233
+ arg_type = written || arg_scope.type_of(arg)
234
+ if ReceiverPredicates.nil_member?(arg_type) # pure nil only — not a `T | nil` union
235
+ nil_arg_overload_mismatch(arg, arg_type, params, param_overrides, arg_scope, written: !written.nil?)
236
+ elsif !coerce_method
237
+ non_nil_arg_overload_mismatch(arg, arg_type, params, param_overrides, arg_scope)
238
+ end
239
+ end
240
+
241
+ # The parameter set at `index` that a verdict may rest on, or nil when there is none — the two
242
+ # reasons being arity divergence (an overload with no param there, which is `call.wrong-arity`'s
243
+ # concern) and an overload whose param names a class carrying no definition ({#stub_typed_param?},
244
+ # issue #661). Both channels below fire only when EVERY overload rejects, so either one is enough
245
+ # to unseat that premise.
246
+ def checkable_overload_params(method_types, index, param_overrides, scope)
247
+ params = overload_positional_params(method_types, index)
248
+ return nil if params.nil?
249
+ return nil if params.any? { |param| stub_typed_param?(param, param_overrides, scope) }
250
+
251
+ params
252
+ end
253
+
254
+ # The nil channel: a pure `nil` argument no overload admits (ADR-58
255
+ # parity excuses a declaration-sourced ivar nil).
256
+ def nil_arg_overload_mismatch(arg, arg_type, params, param_overrides, scope, written: false)
257
+ return nil if !written && declaration_sourced_nil_argument?(arg, scope)
258
+ return nil if params.any? { |param| param_admits_nil?(param, param_overrides, scope) }
259
+
260
+ { node: arg, name: nil, expected: overload_param_expected_label(params), actual: arg_type }
261
+ end
262
+
263
+ # The non-nil channel (ADR-64 WD2/WD3): a single-concrete-class
264
+ # argument no overload admits, on a non-coerce method.
265
+ def non_nil_arg_overload_mismatch(arg, arg_type, params, param_overrides, scope)
266
+ return class_object_overload_mismatch(arg, arg_type, params, param_overrides, scope) if
267
+ arg_type.is_a?(Type::Singleton)
268
+ return nil unless single_concrete_arg_class?(arg_type, scope)
269
+ return nil if params.any? { |param| param_accepts_arg_class?(param, arg_type, param_overrides, scope) }
270
+
271
+ { node: arg, name: nil, expected: overload_param_expected_label(params), actual: arg_type }
272
+ end
273
+
274
+ # Issue #2828 — the class-object twin of the non-nil channel. A `singleton(T)` overload the `resolv` overlay
275
+ # prepends turned `getresources(d, String)`'s one-overload check (`expected singleton(Resolv::DNS::Query)`)
276
+ # into this multi-overload one, which declined every class object. It fires only when every overload's
277
+ # parameter at the position is a `singleton(...)` (a `singleton(T)` read through its class bound, see
278
+ # `SingletonTypeParams.selection_param`) that provably refuses the argument's class; any other parameter
279
+ # shape admits.
280
+ def class_object_overload_mismatch(arg, arg_type, params, param_overrides, scope)
281
+ return nil unless Rigor::Reflection.rbs_class_known?(arg_type.class_name, scope: scope)
282
+ return nil unless params.all? do |param|
283
+ !param_overrides[param.name] && param.type.is_a?(RBS::Types::ClassSingleton)
284
+ end
285
+ return nil unless params.all? { |param| class_singleton_refuses?(param.type, arg_type, scope) }
286
+
287
+ expected = params.map { |param| param.type.to_s.sub("singleton(::", "singleton(") }.uniq.join(" | ")
288
+ { node: arg, name: nil, expected: expected, actual: arg_type }
289
+ end
290
+
291
+ def class_singleton_refuses?(rbs_type, arg_type, scope)
292
+ translated = translate_param_type(rbs_type, scope.environment)
293
+ translated.is_a?(Type::Singleton) && Inference::Acceptance.accepts(translated, arg_type, mode: :gradual).no?
294
+ end
295
+
296
+ # The matching positional RBS param across every overload, or nil when
297
+ # any overload has no param at `index` (arity divergence — the
298
+ # wrong-arity rule's concern, not this one's).
299
+ def overload_positional_params(method_types, index)
300
+ params = method_types.map do |method_type|
301
+ function = method_type.type
302
+ param = (function.required_positionals + function.optional_positionals)[index]
303
+ param && resolve_param_bounds(param, method_type)
304
+ end
305
+ params.any?(&:nil?) ? nil : params
306
+ end
307
+
308
+ # Substitutes each bounded method-level type parameter for its bound, so
309
+ # `[I < _ToInt] (I index) -> …` is walked as `(_ToInt index) -> …`. A bare
310
+ # `Variable` is undecidable to the acceptance walk and admits everything,
311
+ # which silently disables both channels for the whole overload; the bound
312
+ # constrains the argument exactly as an ordinary param of that type would.
313
+ # Load-bearing since rbs 4.1 rewrote core signatures into this form
314
+ # (`Array#fetch`'s block overload is `[I < _ToInt, T] (I index) { … }`).
315
+ def resolve_param_bounds(param, method_type)
316
+ param = Inference::MethodDispatcher::SingletonTypeParams.selection_param(param, method_type)
317
+ bounded = method_type.type_params.select(&:upper_bound)
318
+ return param if bounded.empty?
319
+
320
+ substitution = RBS::Substitution.build(bounded.map(&:name), bounded.map(&:upper_bound))
321
+ param.map_type { |type| type.sub(substitution) }
322
+ end
323
+
324
+ # ADR-26 WD8's PARAMETER-side twin (issue #661). `sig/app.rbs` declaring
325
+ # `(ActiveSupport::TimeWithZone) -> void` in a project that never brings ActiveSupport's RBS in
326
+ # names a class that carries no definition anywhere in the environment. Rigor still refuted
327
+ # `App.take_twz(Time.now)` against it — `expected ActiveSupport::TimeWithZone, got Time` on a call
328
+ # that works — because the acceptance walk compares nominals and `Time`'s ancestry does not list a
329
+ # name nothing declares.
330
+ #
331
+ # WD8 already declines the two signature rules on such a RECEIVER, on the ground that there is
332
+ # nothing authoritative to check the call against. It is the same one position over: with no
333
+ # ancestry there is no fact that could make an argument satisfy the parameter either, so the
334
+ # rejection is the missing signature restated as an error rather than a finding about the program.
335
+ # Under AGENTS.md's false-positives-outrank-worst-case rule the honest answer is to decline, and
336
+ # the report it costs is one the analyzer never had evidence for.
337
+ #
338
+ # Both shapes the missing name arrives in are covered, deliberately as ONE criterion. A name an
339
+ # INSTANCE-method signature references is minted as an empty stub so the class builds
340
+ # ({Environment::RbsLoader.stub_missing_referenced_types}) and reads back as RBS-known; the same
341
+ # name in a SINGLETON signature is not, because that pass mirrors rbs's own membership test and
342
+ # `validate_type_params` never reaches singleton members. That asymmetry is an artifact of which
343
+ # pass ran, not of what is knowable, and the issue's own repro is the singleton half.
344
+ #
345
+ # A `rigor:v1:param` override is a real Rigor type the author wrote against the call site's own
346
+ # method, so it is consulted first and checked normally.
347
+ def stub_typed_param?(param, param_overrides, scope)
348
+ return false if param_overrides[param.name]
349
+
350
+ undefined_param_class?(param.type, scope)
351
+ end
352
+
353
+ # Only the arms a verdict can rest on directly: a union member, an optional's inner type, an
354
+ # expanded alias, and the class instance / singleton itself. Deliberately NOT recursive into type
355
+ # ARGUMENTS — `Array[Missing]` is still refuted by an `Integer` argument on the `Array` alone, and
356
+ # declining there would be a lost report bought for nothing.
357
+ def undefined_param_class?(rbs_type, scope)
358
+ case rbs_type
359
+ when RBS::Types::Union then rbs_type.types.any? { |member| undefined_param_class?(member, scope) }
360
+ when RBS::Types::Optional then undefined_param_class?(rbs_type.type, scope)
361
+ when RBS::Types::Alias
362
+ expanded = scope.environment&.rbs_loader&.expand_type_alias(rbs_type)
363
+ !expanded.nil? && undefined_param_class?(expanded, scope)
364
+ when RBS::Types::ClassInstance, RBS::Types::ClassSingleton
365
+ name = rbs_type.name
366
+ ReceiverPredicates.synthesized_stub_receiver?(name, scope) ||
367
+ !Rigor::Reflection.rbs_class_known?(name.to_s, scope: scope)
368
+ else false
369
+ end
370
+ end
371
+
372
+ # The class names whose instances `nil` IS — `NilClass` and every
373
+ # ancestor. A parameter typed as any other class instance rejects nil.
374
+ NIL_COMPATIBLE_CLASS_NAMES = %w[NilClass Object BasicObject Kernel].to_set.freeze
375
+ private_constant :NIL_COMPATIBLE_CLASS_NAMES
376
+
377
+ # Does this parameter admit a `nil` argument? Decided on the RBS
378
+ # parameter type (a `rigor:v1:param` override takes precedence).
379
+ # Conservative throughout: any case we cannot decide returns true
380
+ # (admits → do not fire), so the rule never fires on uncertainty.
381
+ def param_admits_nil?(param, param_overrides, scope)
382
+ override = param_overrides[param.name]
383
+ return rigor_type_admits_nil?(override) if override
384
+
385
+ rbs_type_admits_nil?(param.type, scope)
386
+ end
387
+
388
+ # The `rigor:v1:param` override variant — a refinement
389
+ # (`non-empty-string`) rejects nil; an explicit nil / nilable union /
390
+ # gradual override admits it.
391
+ def rigor_type_admits_nil?(type)
392
+ return true if type.is_a?(Type::Dynamic) || type.is_a?(Type::Top)
393
+ return true if ReceiverPredicates.nil_member?(type)
394
+ return NilReceiver.union_contains_nil?(type) if type.is_a?(Type::Union)
395
+
396
+ false
397
+ end
398
+
399
+ # Walks the RBS parameter type. The load-bearing cases are `Alias`
400
+ # (`string` = `String | _ToStr`) and `Interface` (`_ToStr`), which
401
+ # {Inference::RbsTypeTranslator} degrades to `untyped` — the reason a
402
+ # `nil` argument is invisible after translation (the interface-alias
403
+ # gap). Resolving them here recovers the rejection. Only a concrete
404
+ # class instance that is not a `nil` ancestor, and an interface
405
+ # NilClass does not satisfy, return false; everything else admits.
406
+ def rbs_type_admits_nil?(rbs_type, scope)
407
+ case rbs_type
408
+ when RBS::Types::Union then rbs_type.types.any? { |member| rbs_type_admits_nil?(member, scope) }
409
+ when RBS::Types::Alias
410
+ expanded = scope.environment&.rbs_loader&.expand_type_alias(rbs_type)
411
+ expanded.nil? || rbs_type_admits_nil?(expanded, scope)
412
+ when RBS::Types::ClassInstance
413
+ NIL_COMPATIBLE_CLASS_NAMES.include?(rbs_type.name.to_s.delete_prefix("::"))
414
+ when RBS::Types::Interface then interface_admits_nil?(rbs_type, scope)
415
+ else true # Optional / bases / variable / tuple / record / proc / literal / intersection → conservative admit
416
+ end
417
+ end
418
+
419
+ # An interface parameter (`_ToStr`) admits nil only when NilClass
420
+ # implements every method it requires (`to_str`, `to_int`, … — which
421
+ # NilClass does not, so `string` / `int` params reject nil; a
422
+ # hypothetical `_ToS` would admit, since NilClass#to_s exists).
423
+ # Unresolvable → conservative true.
424
+ def interface_admits_nil?(rbs_type, scope)
425
+ loader = scope.environment&.rbs_loader
426
+ return true if loader.nil?
427
+
428
+ methods = loader.interface_method_names(rbs_type.name.to_s)
429
+ return true if methods.nil? || methods.empty?
430
+
431
+ methods.all? { |method_name| NilReceiver.nil_class_has_method?(method_name, scope) }
432
+ end
433
+
434
+ # ADR-64 WD3 — the non-nil channel fires only on an argument that types
435
+ # to a single concrete, RBS-known class. A union arg mirrors the
436
+ # union-receiver story and stays deferred; a class/module object
437
+ # (`Singleton`) has a special acceptance surface and is skipped; a
438
+ # non-RBS project class is skipped because its conversion protocol (a
439
+ # duck-typed `to_int` / `to_str`) is invisible to us, so we cannot
440
+ # refute acceptance.
441
+ def single_concrete_arg_class?(arg_type, scope)
442
+ return false if arg_type.is_a?(Type::Union)
443
+ return false if arg_type.is_a?(Type::Singleton)
444
+
445
+ class_name = ReceiverPredicates.concrete_class_name(arg_type)
446
+ return false if class_name.nil?
447
+
448
+ Rigor::Reflection.rbs_class_known?(class_name, scope: scope)
449
+ end
450
+
451
+ # ADR-64 WD2 — does this parameter accept the (non-nil) argument?
452
+ # The non-nil generalization of {#param_admits_nil?}: decided on the RBS
453
+ # parameter type (a `rigor:v1:param` override takes precedence) so it
454
+ # sees through the `int` / `string` interface-aliases the translator
455
+ # degrades to gradual. Conservative throughout — any case we cannot
456
+ # decide returns true (accepts → do not fire).
457
+ def param_accepts_arg_class?(param, arg_type, param_overrides, scope)
458
+ override = param_overrides[param.name]
459
+ return rigor_type_accepts_arg?(override, arg_type) if override
460
+
461
+ rbs_type_accepts_arg?(param.type, arg_type, scope)
462
+ end
463
+
464
+ # The `rigor:v1:param` override variant — a Rigor `Type`, so the
465
+ # acceptance engine decides directly (gradual; only a proven rejection
466
+ # refutes). Dynamic / Top admit unconditionally.
467
+ def rigor_type_accepts_arg?(param_type, arg_type)
468
+ return true if param_type.is_a?(Type::Dynamic) || param_type.is_a?(Type::Top)
469
+
470
+ !Inference::Acceptance.accepts(param_type, arg_type, mode: :gradual).no?
471
+ end
472
+
473
+ # Walks the RBS parameter type, mirroring {#rbs_type_admits_nil?}. The
474
+ # load-bearing cases are `Alias` / `Interface` (`int` = `Integer |
475
+ # _ToInt`), which the translator degrades to gradual — resolving them
476
+ # here recovers the rejection. A faithfully-translated `ClassInstance`
477
+ # is handed to the acceptance engine; everything undecidable admits.
478
+ def rbs_type_accepts_arg?(rbs_type, arg_type, scope)
479
+ case rbs_type
480
+ when RBS::Types::Union then rbs_type.types.any? { |member| rbs_type_accepts_arg?(member, arg_type, scope) }
481
+ when RBS::Types::Alias
482
+ expanded = scope.environment&.rbs_loader&.expand_type_alias(rbs_type)
483
+ expanded.nil? || rbs_type_accepts_arg?(expanded, arg_type, scope)
484
+ when RBS::Types::ClassInstance then class_instance_accepts_arg?(rbs_type, arg_type, scope)
485
+ when RBS::Types::Interface then interface_accepts_arg?(rbs_type, arg_type, scope)
486
+ else true # bases / variable / tuple / record / proc / literal / intersection / optional → conservative admit
487
+ end
488
+ end
489
+
490
+ # A `ClassInstance` param (`Integer`, `Numeric`, …) is translated
491
+ # faithfully (no interface degradation), so the acceptance engine — the
492
+ # canonical RBS-ancestry / generic-aware subtype check — decides it.
493
+ # Only a proven rejection refutes; an unresolvable class is `:maybe`,
494
+ # which admits.
495
+ def class_instance_accepts_arg?(rbs_type, arg_type, scope)
496
+ translated = translate_param_type(rbs_type, scope.environment)
497
+ return true if translated.is_a?(Type::Dynamic) || translated.is_a?(Type::Top)
498
+
499
+ !Inference::Acceptance.accepts(translated, arg_type, mode: :gradual).no?
500
+ end
501
+
502
+ # An interface param (`_ToInt`) accepts the arg only when the arg's
503
+ # class implements every method it requires (`to_int`, …). The non-nil
504
+ # mirror of {#interface_admits_nil?}: ask the arg class, not NilClass.
505
+ # Unresolvable anywhere → conservative true (admit).
506
+ def interface_accepts_arg?(rbs_type, arg_type, scope)
507
+ loader = scope.environment&.rbs_loader
508
+ return true if loader.nil?
509
+
510
+ methods = loader.interface_method_names(rbs_type.name.to_s)
511
+ return true if methods.nil? || methods.empty?
512
+
513
+ class_name = ReceiverPredicates.concrete_class_name(arg_type)
514
+ return true if class_name.nil?
515
+
516
+ methods.all? { |method_name| arg_class_has_method?(class_name, method_name, scope) }
517
+ end
518
+
519
+ # The non-nil mirror of {NilReceiver.nil_class_has_method?}, but conservative on
520
+ # the unknown side: an unresolvable definition returns true (the class
521
+ # *might* implement the method — e.g. a metaprogrammed conversion), so
522
+ # the channel never fires on uncertainty.
523
+ def arg_class_has_method?(class_name, method_name, scope)
524
+ definition = Rigor::Reflection.instance_definition(class_name, scope: scope)
525
+ return true if definition.nil?
526
+
527
+ !definition.methods[method_name.to_sym].nil?
528
+ end
529
+
530
+ # A readable "expected" label for a multi-overload mismatch — the RBS
531
+ # parameter type(s) as written (`string`, or the per-overload set), since
532
+ # the translated Rigor type degrades the interface-alias the rejection
533
+ # hinges on. Shared by the nil and non-nil channels.
534
+ def overload_param_expected_label(params)
535
+ params.map { |param| param.type.to_s.delete_prefix("::") }.uniq.join(" | ")
536
+ end
537
+
538
+ # ADR-58 parity for the nil channel: a declaration-sourced read that
539
+ # types as nil is the same not-diagnostic-fuel case the union path
540
+ # gates in {#declaration_sourced_nil_only_mismatch?}; suppress it here
541
+ # too so a ctor-seeded `@x = nil` read passed as an argument does not
542
+ # fire on a working program's cross-method invariant. Issue #324 —
543
+ # delegates to {DeclarationSourcedGuard}, so a local copy of the ivar
544
+ # (`c = @count`) is excused on the same terms `possible-nil-receiver`
545
+ # already excused it.
546
+ def declaration_sourced_nil_argument?(arg, scope)
547
+ DeclarationSourcedGuard.marked?(arg, scope)
548
+ end
549
+
550
+ def first_argument_mismatch(method_type, call_node, scope, param_overrides, scope_index)
551
+ function = method_type.type
552
+ return nil unless argument_check_eligible?(function)
553
+
554
+ params = function.required_positionals + function.optional_positionals
555
+ arguments = call_node.arguments&.arguments || []
556
+ arguments.each_with_index do |arg, index|
557
+ param = params[index]
558
+ next if param.nil? # arity mismatch is the wrong-arity rule's concern.
559
+
560
+ mismatch = single_argument_mismatch(param, arg, argument_scope(arg, scope, scope_index), param_overrides)
561
+ return mismatch if mismatch
562
+ end
563
+ nil
564
+ end
565
+
566
+ # The scope `arg` is checked from: its own index entry ({#argument_mismatch}), else the call's.
567
+ def argument_scope(arg, call_scope, scope_index)
568
+ scope_index[arg] || call_scope
569
+ end
570
+
571
+ # The mismatch (or nil) for one positional argument against one
572
+ # parameter. The nil channel decides a pure `nil` argument on the RBS
573
+ # parameter type — seeing through the `string` / `int` interface-alias
574
+ # the translator degrades to gradual (so `"a" + nil` fires), excusing a
575
+ # declaration-sourced ivar nil (ADR-58 parity). The non-nil channel is
576
+ # the original translated-acceptance check, with a `rigor:v1:param`
577
+ # override taking precedence over the RBS-declared type.
578
+ def single_argument_mismatch(param, arg, scope, param_overrides)
579
+ return nil if stub_typed_param?(param, param_overrides, scope)
580
+
581
+ # Issue #1362 (ADR-58 parity, ADR-117 Decision point 2) — a read of a builtin global still on its declared
582
+ # seed, or a local copied from one, is judged by the file's writes to the global, as the argument was
583
+ # before the join: the declared members are not diagnostic fuel.
584
+ written = DeclarationSourcedGuard.written_type(arg, scope)
585
+ return written_argument_mismatch(param, arg, written, scope, param_overrides) if written
586
+
587
+ read_argument_mismatch(param, arg, scope, param_overrides)
588
+ end
589
+
590
+ # {#single_argument_mismatch} for an argument that reads no builtin global's seed directly.
591
+ def read_argument_mismatch(param, arg, scope, param_overrides)
592
+ arg_type = scope.type_of(arg)
593
+
594
+ if ReceiverPredicates.nil_member?(arg_type)
595
+ return nil if declaration_sourced_nil_argument?(arg, scope)
596
+ return nil if param_admits_nil?(param, param_overrides, scope)
597
+
598
+ return { node: arg, name: param.name, expected: overload_param_expected_label([param]), actual: arg_type }
599
+ end
600
+
601
+ param_type = param_overrides[param.name] || translate_param_type(param.type, scope.environment)
602
+ return nil if param_type.is_a?(Type::Dynamic) || param_type.is_a?(Type::Top)
603
+ return nil if arg_type.is_a?(Type::Dynamic) || arg_type.is_a?(Type::Top)
604
+ return nil if gradual_narrowing_accepted?(arg, arg_type, param_type, scope)
605
+ return nil unless argument_genuinely_mismatches?(arg, arg_type, param_type, scope)
606
+ # Issue #1362 — a value that mixes such a global with something else (`c ? $stdout : StringIO.new`) is judged
607
+ # without the declared members the file never writes, as it was before the join.
608
+ return nil if DeclarationSourcedGuard.declared_only_rejection?(arg_type, param_type, scope) do |stripped|
609
+ !plain_argument_rejects?(param, stripped, scope, param_overrides)
610
+ end
611
+
612
+ { node: arg, name: param.name, expected: param_type, actual: arg_type }
613
+ end
614
+
615
+ # The mismatch for an argument judged by `written`, the file's writes to the builtin globals it reads the
616
+ # seeds of, through the channels {#single_argument_mismatch} runs, without the ADR-58 withholding: before
617
+ # the join the global carried no mark.
618
+ def written_argument_mismatch(param, arg, written, scope, param_overrides)
619
+ return nil unless plain_argument_rejects?(param, written, scope, param_overrides)
620
+
621
+ expected =
622
+ if ReceiverPredicates.nil_member?(written)
623
+ overload_param_expected_label([param])
624
+ else
625
+ param_overrides[param.name] || translate_param_type(param.type, scope.environment)
626
+ end
627
+ { node: arg, name: param.name, expected: expected, actual: written }
628
+ end
629
+
630
+ # True when `param` rejects an argument of type `type` on the terms of {#single_argument_mismatch}'s nil and
631
+ # non-nil channels, without the ADR-58 withholding.
632
+ def plain_argument_rejects?(param, type, scope, param_overrides)
633
+ return !param_admits_nil?(param, param_overrides, scope) if ReceiverPredicates.nil_member?(type)
634
+
635
+ param_type = param_overrides[param.name] || translate_param_type(param.type, scope.environment)
636
+ return false if param_type.is_a?(Type::Dynamic) || param_type.is_a?(Type::Top)
637
+ return false if type.is_a?(Type::Dynamic) || type.is_a?(Type::Top)
638
+
639
+ Inference::Acceptance.accepts(param_type, type, mode: :gradual).no?
640
+ end
641
+
642
+ # Issue #2656 — a local a class guard narrowed from a `Dynamic` value
643
+ # ({DeclarationSourcedGuard.gradual_narrowed?}) is judged by its class, not by the literals the parameter
644
+ # names: `mode(x) if x.is_a?(String)` with `mode: ("r" | "w")` is accepted, as the gradual value was, while
645
+ # `num(x) if x.is_a?(String)` with `num: (1 | 2)` still reports, since no String is ever `1` or `2`. The
646
+ # parameter's value-pinned members are widened to their classes ({Type::Combinator.widen_value_pinned}) and
647
+ # the narrowed type is judged against that. The overload path ({#non_nil_arg_overload_mismatch}) already
648
+ # judges by class, so it needs no such reading.
649
+ #
650
+ # A literal member of the narrowed type did not come from the gradual value (`x = h[:m] || "r"` narrows to
651
+ # `"r" | String`), so it is judged against the parameter as written.
652
+ def gradual_narrowing_accepted?(arg, arg_type, param_type, scope)
653
+ return false unless DeclarationSourcedGuard.gradual_narrowed?(arg, scope)
654
+
655
+ members = arg_type.is_a?(Type::Union) ? arg_type.members : [arg_type]
656
+ literals, rest = members.partition { |member| member.is_a?(Type::Constant) }
657
+ if literals.any? { |member| Inference::Acceptance.accepts(param_type, member, mode: :gradual).no? }
658
+ return false
659
+ end
660
+ return true if rest.empty?
661
+
662
+ widened = Type::Combinator.widen_value_pinned(param_type)
663
+ !Inference::Acceptance.accepts(widened, Type::Combinator.union(*rest), mode: :gradual).no?
664
+ end
665
+
666
+ # The parameter rejects the argument AND the rejection is not a
667
+ # withheld declaration-sourced-nil case.
668
+ def argument_genuinely_mismatches?(arg, arg_type, param_type, scope)
669
+ return false unless rejects_beyond_class_objects?(param_type, arg_type)
670
+
671
+ # ADR-58 (N2 extension) — the same declaration-sourced-nil-is-not-
672
+ # diagnostic-fuel criterion that governs `possible-nil-receiver`
673
+ # applies here. When the only reason the argument is rejected is a
674
+ # *declaration-sourced* nil constituent (the class-ivar index seed
675
+ # of a ctor `@x = nil` / a non-definitely-assigned ivar read), and
676
+ # the argument type with that nil removed WOULD be accepted, the
677
+ # working program's cross-method invariant is assumed and we do not
678
+ # fire. Flow-live nil (a method-local `@x = nil` write, a failed-
679
+ # guard narrowing) drops the provenance mark upstream and still
680
+ # fires. The argument's type is unchanged — only the firing
681
+ # decision is gated.
682
+ !declaration_sourced_nil_only_mismatch?(arg, arg_type, param_type, scope)
683
+ end
684
+
685
+ # Issue #2855 — the parameter rejects the argument, and not only for its `Class` / `Module` members. An
686
+ # unparameterised `Class` or `Module` nominal ({Acceptance.class_or_module_nominal?}) against a parameter
687
+ # that admits class objects (`singleton(X)`, alone or in a union) is a class object whose identity inference
688
+ # lost — a `const_get` result kept by `is_a?(Class)`, an `is_a?(Module)` guard — so it is withheld. The rest
689
+ # of the argument is still judged: `Class | Integer` against `singleton(X)` reports for its `Integer`.
690
+ # Acceptance itself keeps answering `no`, so overload selection is unchanged.
691
+ def rejects_beyond_class_objects?(param_type, arg_type)
692
+ return false unless Inference::Acceptance.accepts(param_type, arg_type, mode: :gradual).no?
693
+ return true unless admits_class_objects?(param_type)
694
+
695
+ members = arg_type.is_a?(Type::Union) ? arg_type.members : [arg_type]
696
+ rest = members.reject { |member| Inference::Acceptance.class_or_module_nominal?(member) }
697
+ return true if rest.size == members.size
698
+
699
+ Inference::Acceptance.accepts(param_type, Type::Combinator.union(*rest), mode: :gradual).no?
700
+ end
701
+
702
+ def admits_class_objects?(param_type)
703
+ case param_type
704
+ when Type::Singleton then true
705
+ when Type::Union then param_type.members.any?(Type::Singleton)
706
+ else false
707
+ end
708
+ end
709
+
710
+ # True when `arg` is a declaration-sourced read whose rejection is
711
+ # caused solely by its nil constituent: stripping nil from the argument
712
+ # type yields a type the parameter accepts (gradual mode). Mirrors the
713
+ # `possible-nil-receiver` WD1 gate — since issue #324 through the very
714
+ # same {DeclarationSourcedGuard} predicate, so the ivar read and its
715
+ # local copy (`c = @count`) are one case rather than two spellings that
716
+ # can drift apart again.
717
+ def declaration_sourced_nil_only_mismatch?(arg, arg_type, param_type, scope)
718
+ return false unless DeclarationSourcedGuard.marked?(arg, scope)
719
+ return false unless arg_type.is_a?(Type::Union)
720
+ return false unless NilReceiver.union_contains_nil?(arg_type)
721
+
722
+ non_nil = Type::Combinator.union(*arg_type.members.reject { |m| ReceiverPredicates.nil_member?(m) })
723
+ return false if non_nil.is_a?(Type::Bot)
724
+
725
+ result = Inference::Acceptance.accepts(param_type, non_nil, mode: :gradual)
726
+ # Issue #2855 — a `Class?` ivar against `singleton(X)` is withheld as its `Class` alone would be.
727
+ # Issue #2863 — a `maybe` (a project class the host process has not loaded, so its ancestry is unresolved:
728
+ # `singleton(Circle)` against `singleton(Shape)`) is not a rejection either: the non-nil part alone would not
729
+ # fire, so the nil is the only reason and it is withheld.
730
+ !result.no? || !rejects_beyond_class_objects?(param_type, non_nil)
731
+ end
732
+
733
+ # What this rule needs is that argument N binds to positional
734
+ # parameter N, so the only disqualifiers are the two shapes that
735
+ # break that mapping: a rest positional (arguments past it belong
736
+ # to the rest, not to a later parameter) and trailing positionals
737
+ # (the last arguments bind backwards from the end).
738
+ #
739
+ # Issue #673 — a keyword parameter used to disqualify the whole
740
+ # signature, which silently unchecked the POSITIONAL arguments of
741
+ # every keyword-bearing signature in the bundle:
742
+ # `time.beginning_of_week("monday")` fired while
743
+ # `time.next_week("monday")`, `(?Symbol, ?same_time: bool)`, did not,
744
+ # though both raise the same way at runtime. Keywords cannot shift a
745
+ # positional argument's index, and a call that PASSES keywords never
746
+ # reaches here at all — `WrongArity.plain_positional_call?` rejects a
747
+ # `KeywordHashNode` argument (`**opts` included) before the signature
748
+ # is consulted.
749
+ def argument_check_eligible?(function)
750
+ # See `WrongArity.arity_eligible?`: `UntypedFunction` lacks
751
+ # the per-arity accessors. Treat it as ineligible
752
+ # for argument-type-mismatch diagnostics.
753
+ return false unless function.respond_to?(:required_keywords)
754
+
755
+ function.rest_positionals.nil? && function.trailing_positionals.empty?
756
+ end
757
+
758
+ def translate_param_type(rbs_type, environment)
759
+ Inference::RbsTypeTranslator.translate(rbs_type, alias_expander: environment&.rbs_loader)
760
+ rescue StandardError
761
+ Type::Combinator.untyped
762
+ end
763
+
764
+ def build_argument_type_diagnostic(path, call_node, class_name, mismatch)
765
+ method_label = "`#{call_node.name}' on #{class_name}"
766
+ parameter_label = mismatch[:name] ? "parameter `#{mismatch[:name]}' of #{method_label}" : method_label
767
+ expected = mismatch[:expected]
768
+ expected_description = expected.is_a?(String) ? expected : expected.describe(:short)
769
+ message = "argument type mismatch at #{parameter_label}: " \
770
+ "expected #{expected_description}, " \
771
+ "got #{mismatch[:actual].describe(:short)}"
772
+ Diagnostic.from_node(
773
+ mismatch[:node],
774
+ rule: RULE_ARGUMENT_TYPE,
775
+ path: path,
776
+ message: message,
777
+ severity: :error,
778
+ receiver_type: class_name,
779
+ method_name: call_node.name.to_s
780
+ )
781
+ end
782
+
783
+ private_class_method :argument_report_withheld?, :inferred_param_mismatch_verdict?, :argument_mismatch,
784
+ :keyword_bearing?, :nil_tainted?, :multi_overload_argument_mismatch,
785
+ :overload_argument_mismatch, :checkable_overload_params, :nil_arg_overload_mismatch,
786
+ :non_nil_arg_overload_mismatch, :class_object_overload_mismatch,
787
+ :class_singleton_refuses?, :overload_positional_params, :resolve_param_bounds,
788
+ :stub_typed_param?, :undefined_param_class?, :param_admits_nil?, :rigor_type_admits_nil?,
789
+ :rbs_type_admits_nil?, :interface_admits_nil?, :single_concrete_arg_class?,
790
+ :param_accepts_arg_class?, :rigor_type_accepts_arg?, :rbs_type_accepts_arg?,
791
+ :class_instance_accepts_arg?, :interface_accepts_arg?, :arg_class_has_method?,
792
+ :overload_param_expected_label, :declaration_sourced_nil_argument?,
793
+ :first_argument_mismatch, :argument_scope, :single_argument_mismatch,
794
+ :read_argument_mismatch, :written_argument_mismatch, :plain_argument_rejects?,
795
+ :gradual_narrowing_accepted?, :argument_genuinely_mismatches?,
796
+ :rejects_beyond_class_objects?, :admits_class_objects?,
797
+ :declaration_sourced_nil_only_mismatch?, :argument_check_eligible?,
798
+ :translate_param_type, :build_argument_type_diagnostic
799
+ end
800
+ end
801
+ end
802
+ end