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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/docs/handbook/01-getting-started.md +1 -1
- data/docs/handbook/04-tuples-and-shapes.md +6 -1
- data/docs/handbook/12-lightweight-hkt.md +1 -1
- data/docs/handbook/appendix-typescript.md +28 -17
- data/docs/manual/02-cli-reference.md +10 -0
- data/docs/manual/03-configuration.md +1 -1
- data/docs/manual/04-diagnostics.md +1 -1
- data/docs/manual/10-mcp-server.md +122 -10
- data/docs/manual/plugins/rigor-activerecord.md +7 -0
- data/lib/rigor/analysis/check_rules/always_raises.rb +95 -0
- data/lib/rigor/analysis/check_rules/always_truthy_condition_collector.rb +32 -2
- data/lib/rigor/analysis/check_rules/argument_type.rb +802 -0
- data/lib/rigor/analysis/check_rules/call_facts.rb +2 -2
- data/lib/rigor/analysis/check_rules/dead_assignment_collector.rb +30 -1
- data/lib/rigor/analysis/check_rules/declaration_sourced_guard.rb +4 -5
- data/lib/rigor/analysis/check_rules/duplicate_hash_key_collector.rb +34 -0
- data/lib/rigor/analysis/check_rules/ivar_write_collector.rb +131 -4
- data/lib/rigor/analysis/check_rules/nil_receiver.rb +195 -0
- data/lib/rigor/analysis/check_rules/override_param_narrowed.rb +111 -0
- data/lib/rigor/analysis/check_rules/override_return_widened.rb +88 -0
- data/lib/rigor/analysis/check_rules/override_support.rb +246 -0
- data/lib/rigor/analysis/check_rules/override_visibility.rb +135 -0
- data/lib/rigor/analysis/check_rules/published_constant_guard.rb +75 -31
- data/lib/rigor/analysis/check_rules/raise_non_exception.rb +198 -0
- data/lib/rigor/analysis/check_rules/receiver_predicates.rb +576 -0
- data/lib/rigor/analysis/check_rules/return_in_ensure_collector.rb +52 -4
- data/lib/rigor/analysis/check_rules/return_type.rb +225 -0
- data/lib/rigor/analysis/check_rules/rigor_testing.rb +119 -0
- data/lib/rigor/analysis/check_rules/rule_ids.rb +7 -7
- data/lib/rigor/analysis/check_rules/rule_walk.rb +4 -3
- data/lib/rigor/analysis/check_rules/self_closedness_scanner.rb +2 -0
- data/lib/rigor/analysis/check_rules/self_undefined_method.rb +165 -0
- data/lib/rigor/analysis/check_rules/shadowed_rescue_collector.rb +34 -0
- data/lib/rigor/analysis/check_rules/source_arity.rb +2 -2
- data/lib/rigor/analysis/check_rules/special_global_write.rb +256 -0
- data/lib/rigor/analysis/check_rules/suppression.rb +275 -0
- data/lib/rigor/analysis/check_rules/undefined_method.rb +882 -0
- data/lib/rigor/analysis/check_rules/unreachable_branch.rb +97 -0
- data/lib/rigor/analysis/check_rules/unreachable_clause_collector.rb +42 -0
- data/lib/rigor/analysis/check_rules/unresolved_toplevel.rb +140 -0
- data/lib/rigor/analysis/check_rules/visibility_mismatch.rb +252 -0
- data/lib/rigor/analysis/check_rules/void_value_use_collector.rb +27 -0
- data/lib/rigor/analysis/check_rules/wrong_arity.rb +303 -0
- data/lib/rigor/analysis/check_rules.rb +66 -4931
- data/lib/rigor/analysis/dependency_recorder.rb +1 -1
- data/lib/rigor/analysis/dependency_source_inference/builder.rb +2 -4
- data/lib/rigor/analysis/dependency_source_inference/gem_resolver.rb +1 -2
- data/lib/rigor/analysis/dependency_source_inference/walker.rb +15 -15
- data/lib/rigor/analysis/incremental_session.rb +4 -4
- data/lib/rigor/analysis/path_expansion.rb +1 -1
- data/lib/rigor/analysis/plugin_fact_fingerprint.rb +5 -5
- data/lib/rigor/analysis/reachability/graph.rb +2 -3
- data/lib/rigor/analysis/reachability/plugin_roots.rb +2 -2
- data/lib/rigor/analysis/reachability/scan.rb +2 -2
- data/lib/rigor/analysis/rule_catalog.rb +2 -1
- data/lib/rigor/analysis/run_cache_key.rb +9 -8
- data/lib/rigor/analysis/runner/buffer_pool_dispatcher.rb +2 -2
- data/lib/rigor/analysis/runner/dependency_rows.rb +206 -0
- data/lib/rigor/analysis/runner/diagnostic_aggregator.rb +24 -22
- data/lib/rigor/analysis/runner/effect_cache_entries.rb +69 -0
- data/lib/rigor/analysis/runner/pool_coordinator.rb +6 -8
- data/lib/rigor/analysis/runner/project_pre_passes.rb +3 -5
- data/lib/rigor/analysis/runner/scope_seed.rb +144 -0
- data/lib/rigor/analysis/runner.rb +49 -296
- data/lib/rigor/analysis/template_unit_collector.rb +1 -1
- data/lib/rigor/analysis/template_units.rb +10 -10
- data/lib/rigor/analysis/worker_session.rb +7 -7
- data/lib/rigor/bleeding_edge.rb +3 -2
- data/lib/rigor/builtins/hkt_builtins.rb +17 -17
- data/lib/rigor/builtins/imported_refinements.rb +8 -16
- data/lib/rigor/builtins/regex_refinement.rb +3 -3
- data/lib/rigor/builtins/static_return_refinements.rb +143 -19
- data/lib/rigor/cache/incremental_snapshot.rb +21 -8
- data/lib/rigor/cache/rbs_descriptor.rb +18 -1
- data/lib/rigor/cli/coverage_renderer.rb +15 -1
- data/lib/rigor/cli/coverage_report.rb +19 -1
- data/lib/rigor/cli/diagnostic_formats.rb +3 -2
- data/lib/rigor/cli/docs_command.rb +5 -5
- data/lib/rigor/cli/effects_command.rb +7 -6
- data/lib/rigor/cli/fused_protection_report.rb +7 -7
- data/lib/rigor/cli/lsp_command.rb +1 -1
- data/lib/rigor/cli/mcp_command.rb +5 -2
- data/lib/rigor/cli/options.rb +4 -0
- data/lib/rigor/cli/plugins_command.rb +1 -1
- data/lib/rigor/cli/sig_gen_command.rb +1 -1
- data/lib/rigor/cli/skill_command.rb +5 -4
- data/lib/rigor/cli/triage_renderer.rb +3 -2
- data/lib/rigor/cli/unused_command.rb +4 -4
- data/lib/rigor/cli.rb +14 -0
- data/lib/rigor/configuration/coercion.rb +418 -0
- data/lib/rigor/configuration/defaults.rb +248 -0
- data/lib/rigor/configuration/dependencies.rb +1 -1
- data/lib/rigor/configuration/loader.rb +354 -0
- data/lib/rigor/configuration/severity_profile.rb +4 -4
- data/lib/rigor/configuration.rb +51 -860
- data/lib/rigor/effects/attribution.rb +1 -1
- data/lib/rigor/effects/effect_table.rb +1 -1
- data/lib/rigor/effects/identity.rb +3 -3
- data/lib/rigor/effects/local_ownership.rb +2 -2
- data/lib/rigor/effects/snapshot.rb +1 -1
- data/lib/rigor/effects/summary.rb +5 -4
- data/lib/rigor/environment/member_consistency.rb +10 -0
- data/lib/rigor/environment/rbs_loader.rb +19 -22
- data/lib/rigor/environment/reflection.rb +1 -1
- data/lib/rigor/environment/unreadable_signature.rb +21 -0
- data/lib/rigor/environment.rb +8 -8
- data/lib/rigor/flow_contribution/merger.rb +1 -0
- data/lib/rigor/hashing/xxh3.rb +1 -1
- data/lib/rigor/inference/acceptance.rb +23 -2
- data/lib/rigor/inference/alias_mutation_floor/site_collector.rb +5 -0
- data/lib/rigor/inference/alias_mutation_floor.rb +0 -5
- data/lib/rigor/inference/anonymous_meta_class.rb +2 -2
- data/lib/rigor/inference/block_call_timing.rb +6 -0
- data/lib/rigor/inference/budget_trace.rb +3 -2
- data/lib/rigor/inference/builtins/date_catalog.rb +3 -3
- data/lib/rigor/inference/builtins/method_catalog.rb +3 -3
- data/lib/rigor/inference/builtins/time_catalog.rb +3 -3
- data/lib/rigor/inference/call_ladder/literal_send.rb +98 -0
- data/lib/rigor/inference/call_ladder/overriding_def.rb +98 -0
- data/lib/rigor/inference/call_ladder/project_singleton.rb +362 -0
- data/lib/rigor/inference/call_ladder/refined.rb +212 -0
- data/lib/rigor/inference/call_ladder/top_level_def.rb +222 -0
- data/lib/rigor/inference/call_ladder/user_method.rb +247 -0
- data/lib/rigor/inference/call_ladder.rb +219 -0
- data/lib/rigor/inference/callee_write_census.rb +2 -2
- data/lib/rigor/inference/captured_locals.rb +2 -2
- data/lib/rigor/inference/clause_widening.rb +63 -1
- data/lib/rigor/inference/declaration_walk/context.rb +12 -12
- data/lib/rigor/inference/declaration_walk/rules.rb +750 -0
- data/lib/rigor/inference/declaration_walk/traversal.rb +9 -8
- data/lib/rigor/inference/declaration_walk.rb +4 -3
- data/lib/rigor/inference/def_node_resolver.rb +2 -2
- data/lib/rigor/inference/def_return_typer.rb +14 -6
- data/lib/rigor/inference/deferred_mutation.rb +120 -0
- data/lib/rigor/inference/define_method_block_self.rb +1 -1
- data/lib/rigor/inference/definer_resolution.rb +4 -4
- data/lib/rigor/inference/error_info.rb +8 -8
- data/lib/rigor/inference/expression_typer/composites.rb +348 -0
- data/lib/rigor/inference/expression_typer/per_element_assemblers.rb +233 -0
- data/lib/rigor/inference/expression_typer/writes.rb +218 -0
- data/lib/rigor/inference/expression_typer.rb +275 -1825
- data/lib/rigor/inference/external_ancestor_resolution.rb +2 -2
- data/lib/rigor/inference/fallback.rb +1 -0
- data/lib/rigor/inference/for_yield_slots.rb +126 -0
- data/lib/rigor/inference/genuine_send.rb +92 -0
- data/lib/rigor/inference/global_write_census.rb +2 -2
- data/lib/rigor/inference/hkt_body.rb +2 -0
- data/lib/rigor/inference/in_effect_refinements/walk.rb +2 -2
- data/lib/rigor/inference/index_write_widening.rb +4 -4
- data/lib/rigor/inference/indexed_narrowing.rb +1 -1
- data/lib/rigor/inference/intervening_ivar_reset.rb +46 -9
- data/lib/rigor/inference/ivar_writer_census.rb +1 -1
- data/lib/rigor/inference/loop_store_sites.rb +239 -0
- data/lib/rigor/inference/macro_block_self_type.rb +4 -3
- data/lib/rigor/inference/method_dispatcher/block_folding.rb +3 -2
- data/lib/rigor/inference/method_dispatcher/call_context.rb +84 -14
- data/lib/rigor/inference/method_dispatcher/composite_receiver.rb +144 -0
- data/lib/rigor/inference/method_dispatcher/constant_folding.rb +7 -5
- data/lib/rigor/inference/method_dispatcher/declared_constructor.rb +1 -1
- data/lib/rigor/inference/method_dispatcher/dependency_source.rb +90 -0
- data/lib/rigor/inference/method_dispatcher/discovered_method.rb +78 -0
- data/lib/rigor/inference/method_dispatcher/file_folding.rb +2 -2
- data/lib/rigor/inference/method_dispatcher/hkt_builtin_return.rb +40 -0
- data/lib/rigor/inference/method_dispatcher/iterator_dispatch.rb +1 -6
- data/lib/rigor/inference/method_dispatcher/literal_string_folding.rb +4 -2
- data/lib/rigor/inference/method_dispatcher/match_data_folding.rb +1 -1
- data/lib/rigor/inference/method_dispatcher/meta_introspection.rb +506 -0
- data/lib/rigor/inference/method_dispatcher/overload_selector.rb +2 -0
- data/lib/rigor/inference/method_dispatcher/plugin_contribution.rb +134 -0
- data/lib/rigor/inference/method_dispatcher/project_patched.rb +134 -0
- data/lib/rigor/inference/method_dispatcher/rbs_dispatch.rb +125 -43
- data/lib/rigor/inference/method_dispatcher/reduce_folding.rb +3 -4
- data/lib/rigor/inference/method_dispatcher/regexp_folding.rb +1 -1
- data/lib/rigor/inference/method_dispatcher/set_folding.rb +1 -1
- data/lib/rigor/inference/method_dispatcher/shape_dispatch.rb +19 -6
- data/lib/rigor/inference/method_dispatcher/singleton_folding.rb +3 -3
- data/lib/rigor/inference/method_dispatcher/singleton_mixin_dispatch.rb +7 -4
- data/lib/rigor/inference/method_dispatcher/static_refinement.rb +106 -0
- data/lib/rigor/inference/method_dispatcher/synthesized_stub.rb +41 -0
- data/lib/rigor/inference/method_dispatcher/synthetic_method_dispatch.rb +133 -0
- data/lib/rigor/inference/method_dispatcher/universal_object_dispatch.rb +2 -1
- data/lib/rigor/inference/method_dispatcher/user_class_fallback.rb +216 -0
- data/lib/rigor/inference/method_dispatcher.rb +175 -1361
- data/lib/rigor/inference/method_parameter_binder.rb +18 -18
- data/lib/rigor/inference/module_function_state.rb +5 -4
- data/lib/rigor/inference/mutation_widening.rb +20 -7
- data/lib/rigor/inference/narrowing/case_literals.rb +58 -0
- data/lib/rigor/inference/narrowing/class_dispatch.rb +302 -0
- data/lib/rigor/inference/narrowing/complements.rb +322 -0
- data/lib/rigor/inference/narrowing/presence_predicates.rb +205 -0
- data/lib/rigor/inference/narrowing/regex_match.rb +499 -0
- data/lib/rigor/inference/narrowing.rb +86 -1269
- data/lib/rigor/inference/object_mixins.rb +2 -2
- data/lib/rigor/inference/opaque_mutation.rb +214 -0
- data/lib/rigor/inference/optimistic_origin.rb +52 -14
- data/lib/rigor/inference/parameter_inference_collector.rb +1 -1
- data/lib/rigor/inference/pre_eval_constants.rb +11 -9
- data/lib/rigor/inference/precision_scanner.rb +27 -2
- data/lib/rigor/inference/project_patched_methods.rb +3 -3
- data/lib/rigor/inference/range_constant.rb +3 -3
- data/lib/rigor/inference/rbs_type_translator.rb +2 -2
- data/lib/rigor/inference/refine_self.rb +8 -7
- data/lib/rigor/inference/refined_dispatch.rb +2 -2
- data/lib/rigor/inference/return_barrier.rb +24 -9
- data/lib/rigor/inference/scope_indexer/alias_def_nodes.rb +311 -0
- data/lib/rigor/inference/scope_indexer/census_scope.rb +47 -0
- data/lib/rigor/inference/scope_indexer/certainty.rb +2 -2
- data/lib/rigor/inference/scope_indexer/class_cvar_census.rb +282 -0
- data/lib/rigor/inference/scope_indexer/class_cvars_collector.rb +12 -5
- data/lib/rigor/inference/scope_indexer/class_declarations.rb +228 -0
- data/lib/rigor/inference/scope_indexer/class_ivar_index.rb +2028 -0
- data/lib/rigor/inference/scope_indexer/constant_ivar_value.rb +4 -3
- data/lib/rigor/inference/scope_indexer/constant_tables.rb +844 -0
- data/lib/rigor/inference/scope_indexer/cvar_hierarchy.rb +159 -0
- data/lib/rigor/inference/scope_indexer/declaration_artifacts.rb +219 -0
- data/lib/rigor/inference/scope_indexer/declaration_signature.rb +212 -0
- data/lib/rigor/inference/scope_indexer/def_nestings_collector.rb +2 -2
- data/lib/rigor/inference/scope_indexer/factory_call_resolver.rb +53 -0
- data/lib/rigor/inference/scope_indexer/literal_receiver_mutations.rb +266 -0
- data/lib/rigor/inference/scope_indexer/member_layouts_collector.rb +8 -7
- data/lib/rigor/inference/scope_indexer/mixin_accumulator.rb +1 -1
- data/lib/rigor/inference/scope_indexer/mixin_effects.rb +470 -0
- data/lib/rigor/inference/scope_indexer/mixin_tables.rb +388 -0
- data/lib/rigor/inference/scope_indexer/mutated_carrier_widening.rb +163 -0
- data/lib/rigor/inference/scope_indexer/mutated_element_census.rb +211 -0
- data/lib/rigor/inference/scope_indexer/node_propagation.rb +520 -0
- data/lib/rigor/inference/scope_indexer/program_globals.rb +154 -0
- data/lib/rigor/inference/scope_indexer/published_constant_cvars.rb +146 -0
- data/lib/rigor/inference/scope_indexer/published_constant_ivars.rb +181 -0
- data/lib/rigor/inference/scope_indexer/shared_walk_tables.rb +823 -0
- data/lib/rigor/inference/scope_indexer/singleton_class_sources.rb +85 -0
- data/lib/rigor/inference/scope_indexer/superclasses_collector.rb +5 -5
- data/lib/rigor/inference/scope_indexer.rb +2657 -9558
- data/lib/rigor/inference/self_call_ivar_writes.rb +22 -3
- data/lib/rigor/inference/set_mutation.rb +2 -2
- data/lib/rigor/inference/singleton_hook_definers.rb +185 -0
- data/lib/rigor/inference/statement_evaluator/def_arguments_and_assertions.rb +365 -0
- data/lib/rigor/inference/statement_evaluator/pattern_bindings.rb +581 -0
- data/lib/rigor/inference/statement_evaluator.rb +201 -1008
- data/lib/rigor/inference/synthetic_method_scanner.rb +0 -3
- data/lib/rigor/language_server/completion_provider.rb +8 -8
- data/lib/rigor/language_server/diagnostic_publisher.rb +6 -7
- data/lib/rigor/language_server/document_symbol_provider.rb +4 -6
- data/lib/rigor/language_server/folding_range_provider.rb +3 -3
- data/lib/rigor/language_server/hover_provider.rb +2 -2
- data/lib/rigor/language_server/loop.rb +2 -2
- data/lib/rigor/language_server/server.rb +3 -2
- data/lib/rigor/language_server/signature_help_provider.rb +7 -9
- data/lib/rigor/lens/document.rb +10 -1
- data/lib/rigor/lens/file_reader.rb +2 -1
- data/lib/rigor/mcp/loop.rb +48 -6
- data/lib/rigor/mcp/server.rb +248 -23
- data/lib/rigor/mcp/skill_catalog.rb +157 -0
- data/lib/rigor/plugin/base.rb +22 -4
- data/lib/rigor/plugin/effect_attribution.rb +1 -1
- data/lib/rigor/plugin/inflector.rb +2 -2
- data/lib/rigor/plugin/io_boundary.rb +1 -1
- data/lib/rigor/plugin/loader.rb +4 -4
- data/lib/rigor/plugin/macro/heredoc_template.rb +4 -3
- data/lib/rigor/plugin/optimistic_return.rb +20 -0
- data/lib/rigor/plugin/registry.rb +2 -2
- data/lib/rigor/plugin/template_unit.rb +4 -2
- data/lib/rigor/plugin/trust_policy.rb +2 -1
- data/lib/rigor/plugin.rb +1 -1
- data/lib/rigor/protection/mutator.rb +8 -9
- data/lib/rigor/rbs_extended/reporter.rb +2 -2
- data/lib/rigor/rbs_extended.rb +2 -2
- data/lib/rigor/reflection/constant_ancestors.rb +1 -1
- data/lib/rigor/reflection/project_method.rb +2 -2
- data/lib/rigor/reflection.rb +4 -4
- data/lib/rigor/scope/discovery_index.rb +15 -10
- data/lib/rigor/scope/resolution_chain.rb +29 -6
- data/lib/rigor/scope.rb +89 -32
- data/lib/rigor/sig_gen/generator.rb +5 -4
- data/lib/rigor/sig_gen/renderer.rb +3 -3
- data/lib/rigor/sig_gen/writer.rb +8 -6
- data/lib/rigor/source/parameter_envelope.rb +1 -1
- data/lib/rigor/triage/catalogue.rb +4 -4
- data/lib/rigor/type/combinator.rb +2 -2
- data/lib/rigor/type/data_instance.rb +2 -2
- data/lib/rigor/type/struct_instance.rb +3 -3
- data/lib/rigor/type_node/generic.rb +2 -1
- data/lib/rigor/type_of_memo.rb +2 -1
- data/lib/rigor/typing_state.rb +3 -2
- data/lib/rigor/version.rb +1 -1
- data/plugins/rigor-actioncable/lib/rigor/plugin/actioncable/analyzer.rb +2 -2
- data/plugins/rigor-actioncable/lib/rigor/plugin/actioncable/channel_discoverer.rb +1 -1
- data/plugins/rigor-actionmailer/lib/rigor/plugin/actionmailer/mailer_discoverer.rb +4 -4
- data/plugins/rigor-actionmailer/lib/rigor/plugin/actionmailer.rb +1 -1
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/controller_discoverer.rb +4 -3
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/effects.rb +7 -5
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/erb_compiler.rb +4 -2
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/render_locals.rb +1 -1
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/view_assigns.rb +3 -2
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack.rb +7 -7
- data/plugins/rigor-activejob/lib/rigor/plugin/activejob/job_discoverer.rb +1 -1
- data/plugins/rigor-activejob/lib/rigor/plugin/activejob.rb +2 -2
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/model_discoverer.rb +9 -8
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/model_index.rb +3 -2
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/schema_parser.rb +15 -7
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/schema_table.rb +10 -3
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/structure_sql_parser.rb +12 -1
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord.rb +20 -5
- data/plugins/rigor-activestorage/lib/rigor/plugin/activestorage/attachment_discoverer.rb +1 -1
- data/plugins/rigor-activestorage/lib/rigor/plugin/activestorage.rb +3 -2
- data/plugins/rigor-activesupport-core-ext/lib/rigor/plugin/activesupport_core_ext/effects.rb +1 -1
- data/plugins/rigor-activesupport-core-ext/lib/rigor/plugin/activesupport_core_ext.rb +8 -7
- data/plugins/rigor-dry-schema/lib/rigor/plugin/dry_schema.rb +1 -1
- data/plugins/rigor-dry-types/lib/rigor/plugin/dry_types/alias_scanner.rb +1 -1
- data/plugins/rigor-dry-types/lib/rigor/plugin/dry_types.rb +6 -7
- data/plugins/rigor-factorybot/lib/rigor/plugin/factorybot/factory_discoverer.rb +3 -2
- data/plugins/rigor-graphql/lib/rigor/plugin/graphql/type_scanner.rb +4 -3
- data/plugins/rigor-hanami/lib/rigor/plugin/hanami.rb +4 -2
- data/plugins/rigor-minitest/lib/rigor/plugin/minitest.rb +1 -1
- data/plugins/rigor-pundit/lib/rigor/plugin/pundit.rb +1 -1
- data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n/analyzer.rb +5 -3
- data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n.rb +1 -1
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/devise_routes.rb +4 -5
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/doorkeeper_routes.rb +2 -2
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/helper_discoverer.rb +5 -4
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/helper_table.rb +3 -2
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/routes_parser.rb +30 -31
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes.rb +13 -15
- data/plugins/rigor-rbnacl/lib/rigor/plugin/rbnacl.rb +1 -1
- data/plugins/rigor-rspec/lib/rigor/plugin/rspec/let_scope_index.rb +4 -3
- data/plugins/rigor-rspec/lib/rigor/plugin/rspec/matcher_analyzer.rb +16 -13
- data/plugins/rigor-rspec/lib/rigor/plugin/rspec/scope_walker.rb +3 -2
- data/plugins/rigor-shoulda-matchers/lib/rigor/plugin/shoulda_matchers/analyzer.rb +6 -6
- data/plugins/rigor-sidekiq/lib/rigor/plugin/sidekiq/analyzer.rb +3 -3
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/assertion_recognizer.rb +2 -2
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/catalog.rb +3 -2
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/catalog_walker.rb +6 -5
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/sig_parser.rb +2 -2
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/sigil_detector.rb +4 -5
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/type_translator.rb +1 -1
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet.rb +3 -4
- data/sig/rigor/analysis/check_rules/suppression.rbs +9 -0
- data/sig/rigor/analysis/dependency_recorder.rbs +9 -0
- data/sig/rigor/inference.rbs +275 -11
- data/sig/rigor/plugin/base.rbs +14 -5
- data/sig/rigor/plugin/optimistic_return.rbs +16 -0
- data/sig/rigor/scope.rbs +7 -1
- data/sig/rigor/source.rbs +4 -0
- data/skills/rigor-mcp-setup/SKILL.md +20 -6
- data/skills/rigor-plugin-review/SKILL.md +3 -3
- data/skills/rigor-type-oracle/references/01-oracle-commands.md +1 -1
- metadata +90 -3
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rigor
|
|
4
|
+
module Inference
|
|
5
|
+
module ScopeIndexer
|
|
6
|
+
# Issue #3219 — Ruby keeps one class-variable slot for a class and its subclasses: a subclass's `@@x` reads and
|
|
7
|
+
# writes the slot a superclass created, and a slot a subclass created first is overtaken (a `RuntimeError`) once
|
|
8
|
+
# the superclass writes the name. The class-cvar census keys each class on its own, so this joins, into each
|
|
9
|
+
# entry a class's own `def` write created, every write of the same cvar that another class of its in-file
|
|
10
|
+
# superclass tree makes, `join_only` writes (a class body's, `class_variable_set`) included.
|
|
11
|
+
#
|
|
12
|
+
# The tree is the classes linked by `class Sub < Base` headers whose superclass names a class this file
|
|
13
|
+
# declares. When the topmost class names a superclass the file does not declare (a class another file or a
|
|
14
|
+
# signature declares, one nothing declares, or a non-constant expression such as `Struct.new(:a)`), the writes
|
|
15
|
+
# that superclass makes are unseen, so every entry of the tree also joins `Dynamic[top]`. An implicit or
|
|
16
|
+
# explicit `Object` / `BasicObject` superclass ends the tree. A module's entries stay as they are: a module's
|
|
17
|
+
# cvar is shared with its includers, which this does not follow (#3222).
|
|
18
|
+
module CvarHierarchy
|
|
19
|
+
# The superclass a header names that the tree cannot follow.
|
|
20
|
+
OPEN = :open
|
|
21
|
+
# The superclasses that end a tree, as an implicit superclass does.
|
|
22
|
+
ROOTS = %w[Object BasicObject].freeze
|
|
23
|
+
private_constant :OPEN, :ROOTS
|
|
24
|
+
|
|
25
|
+
module_function
|
|
26
|
+
|
|
27
|
+
# `{ declared: { name => :class | :module }, superclasses: { name => [[raw, nesting], ...] } }`, filled by
|
|
28
|
+
# {.record} as the census walk enters each header.
|
|
29
|
+
def headers = { declared: {}, superclasses: {} }
|
|
30
|
+
|
|
31
|
+
# A header's declared name and kind, and a class header's superclass: `raw` is the as-written name
|
|
32
|
+
# ({SharedWalkTables.recorded_ancestor_name}, nil for a non-constant expression) and `nesting` the
|
|
33
|
+
# `Module.nesting` outside the header, where Ruby resolves it (nil when the walk lost it). A header below
|
|
34
|
+
# `class <<` that names no class records under the empty name, which no candidate and no census entry spells.
|
|
35
|
+
def record(headers, node, context, body)
|
|
36
|
+
name = body.prefix.join("::")
|
|
37
|
+
klass = node.is_a?(Prism::ClassNode)
|
|
38
|
+
headers[:declared][name] = klass ? :class : (headers[:declared][name] || :module)
|
|
39
|
+
return unless klass && node.superclass
|
|
40
|
+
|
|
41
|
+
(headers[:superclasses][name] ||= []) << [SharedWalkTables.recorded_ancestor_name(node.superclass),
|
|
42
|
+
context.nesting]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# `accumulator` (the census before {ClassCvarCensus.finished_cvar_census}) with each class's entries
|
|
46
|
+
# joined along its tree, as a new Hash; `scope` answers whether a name is declared outside the file.
|
|
47
|
+
def join(accumulator, headers, scope)
|
|
48
|
+
return accumulator if accumulator.empty?
|
|
49
|
+
|
|
50
|
+
parents = headers[:superclasses].to_h { |name, sites| [name, parent(sites, headers, scope)] }
|
|
51
|
+
roots = {}
|
|
52
|
+
root = ->(name) { root_of(name, parents, headers, scope, roots) }
|
|
53
|
+
trees = (accumulator.keys | parents.keys).group_by(&root)
|
|
54
|
+
unions = {}
|
|
55
|
+
accumulator.to_h do |class_name, entries|
|
|
56
|
+
key = root.call(class_name)
|
|
57
|
+
tree = trees.fetch(key)
|
|
58
|
+
next [class_name, entries] if tree.size == 1 && !key[1]
|
|
59
|
+
|
|
60
|
+
[class_name, joined_entries(entries, key, tree, accumulator, unions)]
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# The entries a creating write made, each replaced by its tree's union, which `unions` holds once per tree
|
|
65
|
+
# (`key`) and cvar for every member to share.
|
|
66
|
+
def joined_entries(entries, key, tree, accumulator, unions)
|
|
67
|
+
entries.to_h do |cvar, type|
|
|
68
|
+
next [cvar, type] if type.is_a?(ClassCvarCensus::JoinOnlyCvarWrite)
|
|
69
|
+
|
|
70
|
+
[cvar, unions[[key, cvar]] ||= tree_union(tree, cvar, accumulator, key[1])]
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Every write of `cvar` in `tree`, `Dynamic[top]` too when the tree is open: the one seed each entry of the
|
|
75
|
+
# tree a creating write made joins to, built once per tree and cvar.
|
|
76
|
+
def tree_union(tree, cvar, accumulator, open)
|
|
77
|
+
writes = tree.filter_map do |member|
|
|
78
|
+
write = accumulator.dig(member, cvar)
|
|
79
|
+
write.is_a?(ClassCvarCensus::JoinOnlyCvarWrite) ? write.type : write
|
|
80
|
+
end
|
|
81
|
+
writes << Type::Combinator.untyped if open
|
|
82
|
+
Type::Combinator.union(*writes)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# `[root, open]`: the topmost class above `name` and whether the tree cannot see all of its superclass's
|
|
86
|
+
# writes: the topmost class names a superclass {.parent} cannot follow, or names none in this file while
|
|
87
|
+
# another source declares it ({.reopened_elsewhere?}), so its superclass is not known to be `Object`.
|
|
88
|
+
def root_of(name, parents, headers, scope, roots)
|
|
89
|
+
path = {}
|
|
90
|
+
current = name
|
|
91
|
+
result = nil
|
|
92
|
+
until result
|
|
93
|
+
result = roots[current]
|
|
94
|
+
break if result
|
|
95
|
+
|
|
96
|
+
path[current] = true
|
|
97
|
+
up = parents[current]
|
|
98
|
+
result =
|
|
99
|
+
if up.nil? then [current, !parents.key?(current) && reopened_elsewhere?(current, headers, scope)]
|
|
100
|
+
elsif up == OPEN || path.key?(up) then [current, true]
|
|
101
|
+
end
|
|
102
|
+
current = up
|
|
103
|
+
end
|
|
104
|
+
# Every class on the walked path shares the root, so a deep chain is walked once per `join`.
|
|
105
|
+
path.each_key { |member| roots[member] = result }
|
|
106
|
+
result
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Whether a class this file reopens without a superclass header is declared elsewhere with one it may
|
|
110
|
+
# name: another file's header (`discovered_superclasses`) or a bundled signature (core, stdlib, a gem).
|
|
111
|
+
# A class only the project's own `sig/` declares stays rooted, as that signature mirrors the source.
|
|
112
|
+
def reopened_elsewhere?(name, headers, scope)
|
|
113
|
+
return false unless headers[:declared][name] == :class
|
|
114
|
+
|
|
115
|
+
return true if scope.discovered_superclasses.key?(name)
|
|
116
|
+
|
|
117
|
+
loader = scope.environment&.rbs_loader
|
|
118
|
+
!loader.nil? && loader.class_known?(name) && !loader.project_declared_class?(name)
|
|
119
|
+
rescue StandardError
|
|
120
|
+
true
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# The in-file class every header of a class names as its superclass, nil for `Object` / `BasicObject`, or
|
|
124
|
+
# {OPEN}: for a superclass outside the file, a non-constant one, or headers that disagree.
|
|
125
|
+
def parent(sites, headers, scope)
|
|
126
|
+
resolved = sites.map { |raw, nesting| resolve(raw, nesting, headers, scope) }.uniq
|
|
127
|
+
resolved.size == 1 ? resolved.first : OPEN
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# A superclass name resolved against declarations only: the `Module.nesting` outside the header, innermost
|
|
131
|
+
# first, then the top level. The first candidate this file declares is the superclass (a module is {OPEN}),
|
|
132
|
+
# and one only something outside the file declares is {OPEN}. Ruby's lookup also searches the innermost
|
|
133
|
+
# cref's ancestors before the top level and finds a constant an assignment binds; neither is followed.
|
|
134
|
+
def resolve(raw, nesting, headers, scope)
|
|
135
|
+
return OPEN if raw.nil? || nesting.nil?
|
|
136
|
+
|
|
137
|
+
candidates = raw.start_with?("::") ? [raw.delete_prefix("::")] : [*nesting.map { "#{it}::#{raw}" }, raw]
|
|
138
|
+
candidates.each do |candidate|
|
|
139
|
+
kind = headers[:declared][candidate]
|
|
140
|
+
return kind == :class ? candidate : OPEN if kind
|
|
141
|
+
return nil if ROOTS.include?(candidate)
|
|
142
|
+
return OPEN if declared_elsewhere?(scope, candidate)
|
|
143
|
+
end
|
|
144
|
+
OPEN
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def declared_elsewhere?(scope, name)
|
|
148
|
+
scope.discovered_classes.key?(name) || scope.discovered_superclasses.key?(name) ||
|
|
149
|
+
scope.environment&.rbs_loader&.class_known?(name) || false
|
|
150
|
+
rescue StandardError
|
|
151
|
+
true
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
private_class_method :joined_entries, :tree_union, :root_of, :reopened_elsewhere?, :parent, :resolve,
|
|
155
|
+
:declared_elsewhere?
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "prism"
|
|
4
|
+
|
|
5
|
+
require_relative "../../type"
|
|
6
|
+
require_relative "../../source/constant_path"
|
|
7
|
+
require_relative "../../source/node_children"
|
|
8
|
+
require_relative "../declaration_walk/rules"
|
|
9
|
+
require_relative "class_declarations"
|
|
10
|
+
require_relative "factory_call_resolver"
|
|
11
|
+
|
|
12
|
+
module Rigor
|
|
13
|
+
module Inference
|
|
14
|
+
module ScopeIndexer
|
|
15
|
+
# The declaration artifacts of one file, moved out of `scope_indexer.rb` whole (ADR-116 WD9, #3400): the
|
|
16
|
+
# identity table that types the outermost path node of each `class` / `module` header as the singleton of the
|
|
17
|
+
# class it declares, and the classes the file declares by qualified name, a constant write that creates a class
|
|
18
|
+
# among them. {.build_declaration_artifacts} is the entry: `ScopeIndexer.index` calls it first, with the names
|
|
19
|
+
# the project declares, and {PreEvalConstants} calls it with none. The other five functions are private: the
|
|
20
|
+
# file's share of the compact-header re-anchoring (#722), the walk, and its three arms.
|
|
21
|
+
#
|
|
22
|
+
# It asks {DeclarationWalk::Rules} for each declaration context, {ClassDeclarations} for the file's compact
|
|
23
|
+
# headers and {FactoryCallResolver} for the factory call a constant write unwinds to. It calls three functions
|
|
24
|
+
# left in `scope_indexer.rb`, the cross-file fold's, at one site each: `ScopeIndexer.compact_header_renames`
|
|
25
|
+
# (the compact headers the project's names re-anchor), `ScopeIndexer.rename_compact_name` (the name one has
|
|
26
|
+
# under those) and `ScopeIndexer.synthesize_namespace_prefixes` (the namespaces a compact name implies, #528).
|
|
27
|
+
# One constant moved with it, the one only it read: {EMPTY_RENAMES}, public as it was. It reads
|
|
28
|
+
# `ScopeIndexer::EMPTY_PREFIX` and `RECEIVER_EVAL_CALLS` lexically, as {NodePropagation} reads the indexer's
|
|
29
|
+
# constants: other rows of `scope_indexer.rb` and other modules read each.
|
|
30
|
+
#
|
|
31
|
+
# `scope_indexer.rb` requires this file, and this file does not require it back. It requires the file of what
|
|
32
|
+
# else it names. So the file loads alone, and until `scope_indexer.rb` has loaded the entry answers for no
|
|
33
|
+
# program: the last thing it does is call `ScopeIndexer.synthesize_namespace_prefixes`, a `NoMethodError`.
|
|
34
|
+
module DeclarationArtifacts
|
|
35
|
+
module_function
|
|
36
|
+
|
|
37
|
+
# The no-op re-anchoring table (#722 residue 2): shared so the overwhelmingly common
|
|
38
|
+
# nothing-to-re-anchor walk allocates none.
|
|
39
|
+
EMPTY_RENAMES = {}.freeze
|
|
40
|
+
|
|
41
|
+
# Walks the program once for `Prism::ModuleNode` and `Prism::ClassNode`, recording the `Singleton[<qualified>]`
|
|
42
|
+
# type for the outermost `constant_path` node of each declaration. Inner segments of a `class Foo::Bar::Baz`
|
|
43
|
+
# path remain real references (resolved through the ordinary lexical walk), so we annotate ONLY the topmost path
|
|
44
|
+
# node. Nested declarations contribute their fully qualified path: `class A::B; class C; ...` produces `A::B`
|
|
45
|
+
# for the outer and `A::B::C` for the inner.
|
|
46
|
+
# @param declared_names — the project's RAW declared-class names, the oracle
|
|
47
|
+
# {ScopeIndexer.compact_header_renames} adjudicates this file's compact headers against.
|
|
48
|
+
def build_declaration_artifacts(root, declared_names = nil)
|
|
49
|
+
identity_table = {}.compare_by_identity
|
|
50
|
+
discovered = {}
|
|
51
|
+
record_declarations(root, [], identity_table, discovered,
|
|
52
|
+
file_compact_header_renames(root, declared_names))
|
|
53
|
+
[identity_table.freeze, ScopeIndexer.synthesize_namespace_prefixes(discovered).freeze]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Issue #722 residue 2 — this file's share of the fold's re-anchoring, adjudicated against the project
|
|
57
|
+
# names the fold has already settled. Empty (so the per-node answer stands) whenever the caller has no
|
|
58
|
+
# project table to consult: a `Scope.empty` probe sees one file and cannot know what else declares
|
|
59
|
+
# `Wrap::Outer`, and guessing there is the false positive the whole rule is bounded to avoid.
|
|
60
|
+
def file_compact_header_renames(root, declared_names)
|
|
61
|
+
return EMPTY_RENAMES if declared_names.nil? || declared_names.empty?
|
|
62
|
+
|
|
63
|
+
compacts = {}
|
|
64
|
+
ClassDeclarations.collect_class_decls(root, [], {}, compacts)
|
|
65
|
+
return EMPTY_RENAMES if compacts.empty?
|
|
66
|
+
|
|
67
|
+
ScopeIndexer.compact_header_renames(compacts, declared_names)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# `self_prefix` names a REBOUND self for `self::`-anchored declarations — a meta-new
|
|
71
|
+
# block's named class, or `[]` for a self nothing names. nil leaves `self` lexical.
|
|
72
|
+
def record_declarations(node, qualified_prefix, identity_table, discovered, renames = EMPTY_RENAMES,
|
|
73
|
+
self_prefix = nil, singleton_cref: false)
|
|
74
|
+
return unless node.is_a?(Prism::Node)
|
|
75
|
+
|
|
76
|
+
case node
|
|
77
|
+
when Prism::ModuleNode, Prism::ClassNode
|
|
78
|
+
return if record_class_or_module?(node, qualified_prefix, identity_table, discovered, renames,
|
|
79
|
+
self_prefix, singleton_cref: singleton_cref)
|
|
80
|
+
when Prism::SingletonClassNode
|
|
81
|
+
# The expression evaluates in the enclosing cref; the body's cref is unnameable —
|
|
82
|
+
# and `self` below it is the singleton class, which `self::` headers decline on.
|
|
83
|
+
record_declarations(node.expression, qualified_prefix, identity_table, discovered, renames,
|
|
84
|
+
self_prefix, singleton_cref: singleton_cref)
|
|
85
|
+
if node.body
|
|
86
|
+
record_declarations(node.body, qualified_prefix, identity_table, discovered, renames,
|
|
87
|
+
EMPTY_PREFIX, singleton_cref: true)
|
|
88
|
+
end
|
|
89
|
+
return
|
|
90
|
+
when Prism::ConstantWriteNode, Prism::ConstantPathWriteNode, Prism::ConstantOrWriteNode,
|
|
91
|
+
Prism::ConstantPathOrWriteNode
|
|
92
|
+
return if record_meta_new_constant?(node, qualified_prefix, identity_table, discovered,
|
|
93
|
+
self_prefix, singleton_cref: singleton_cref)
|
|
94
|
+
when Prism::CallNode
|
|
95
|
+
return if record_eval_declarations?(node, qualified_prefix, identity_table, discovered,
|
|
96
|
+
renames, self_prefix, singleton_cref)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
node.rigor_each_child do |child|
|
|
100
|
+
record_declarations(child, qualified_prefix, identity_table, discovered, renames,
|
|
101
|
+
self_prefix, singleton_cref: singleton_cref)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def record_class_or_module?(node, qualified_prefix, identity_table, discovered, renames = EMPTY_RENAMES,
|
|
106
|
+
self_prefix = nil, singleton_cref: false)
|
|
107
|
+
self_decl = DeclarationWalk::Rules.self_anchored_decl_prefix(node.constant_path, self_prefix)
|
|
108
|
+
child_prefix = self_decl ||
|
|
109
|
+
Source::ConstantPath.declaration_prefix(qualified_prefix, node.constant_path)
|
|
110
|
+
return false unless child_prefix
|
|
111
|
+
|
|
112
|
+
if self_decl&.empty? ||
|
|
113
|
+
(singleton_cref && !DeclarationWalk::Rules.decl_nameable_under_cref?(node) && !self_decl&.any?)
|
|
114
|
+
# `class D` below `class <<` opens `#<singleton>::D` — a real class nothing can
|
|
115
|
+
# name — so nothing is registered; the body still walks so nameable headers
|
|
116
|
+
# below it re-anchor at a real cref. The same holds for `class self::D` where
|
|
117
|
+
# `self` is opaque (`REGISTRY.first.class_eval { … }`): `self_decl` is `[]`.
|
|
118
|
+
if node.body
|
|
119
|
+
record_declarations(node.body, [], identity_table, discovered, renames,
|
|
120
|
+
nil, singleton_cref: true)
|
|
121
|
+
end
|
|
122
|
+
return true
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Issue #722 residue 2 — the per-file twin of the fold's re-anchoring. The file's own declaration
|
|
126
|
+
# table merges OVER the project seed, so without this a compact header would re-publish the key the
|
|
127
|
+
# fold already moved and a reference written INSIDE the enclosing namespace would resolve to it
|
|
128
|
+
# again. The adjudication itself is the project's: `renames` arrives already settled.
|
|
129
|
+
full = ScopeIndexer.rename_compact_name(renames, child_prefix.join("::"))
|
|
130
|
+
child_prefix = full.split("::")
|
|
131
|
+
singleton = Type::Combinator.singleton_of(full)
|
|
132
|
+
identity_table[node.constant_path] = singleton
|
|
133
|
+
discovered[full] = singleton
|
|
134
|
+
record_declarations(node.body, child_prefix, identity_table, discovered, renames) if node.body
|
|
135
|
+
true
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Recognises class-creating meta calls at constant-write rvalue position and registers `Const` (qualified by the
|
|
139
|
+
# surrounding class/module path) as a discovered class. `Const.new(...)` then resolves to a fresh
|
|
140
|
+
# `Nominal[Const]` via `meta_new`, instead of the un-narrowed `Dynamic[top]` returned by the default `Class#new`
|
|
141
|
+
# envelope.
|
|
142
|
+
#
|
|
143
|
+
# The recognised meta forms are {DeclarationWalk::Rules.meta_new_constant_rvalue?}'s four —
|
|
144
|
+
# `Data.define`, `Struct.new`, `Class.new`, `Module.new` — plus the
|
|
145
|
+
# `Class.new(<factory>)` wrapper {FactoryCallResolver.resolve_meta_factory_call} unwraps:
|
|
146
|
+
#
|
|
147
|
+
# - `Const = Data.define(*Symbol) [do ... end]`
|
|
148
|
+
# - `Const = Struct.new(*Symbol [, keyword_init: ...]) [do ... end]`
|
|
149
|
+
# - `Const = Class.new [(super)] [do ... end]` / `Const = Module.new [do ... end]`
|
|
150
|
+
#
|
|
151
|
+
# Issue [#703](https://github.com/rigortype/rigor/issues/703) — and their `Holder::Const = …` spellings, which
|
|
152
|
+
# name a class just as unconditionally. Until this arm took them, `Holder::Thing.new(1)` fell to the default
|
|
153
|
+
# `Class#new` envelope on `singleton(Struct)` and handed every reader a bare `Struct`.
|
|
154
|
+
#
|
|
155
|
+
# The block body, if present, is recursed into so any nested class/module declarations in the override block
|
|
156
|
+
# (rare but legal) still feed the discovered table.
|
|
157
|
+
def record_meta_new_constant?(node, qualified_prefix, identity_table, discovered,
|
|
158
|
+
self_prefix = nil, singleton_cref: false)
|
|
159
|
+
rvalue = DeclarationWalk::Rules.meta_new_rvalue(node)
|
|
160
|
+
factory_call = rvalue.is_a?(Prism::CallNode) &&
|
|
161
|
+
(FactoryCallResolver.resolve_meta_factory_call(rvalue) ||
|
|
162
|
+
DeclarationWalk::Rules.meta_new_constant_rvalue?(rvalue))
|
|
163
|
+
return false unless factory_call
|
|
164
|
+
|
|
165
|
+
child_prefix = DeclarationWalk::Rules.meta_new_child_prefix(node, qualified_prefix, self_prefix)
|
|
166
|
+
return false if child_prefix.nil?
|
|
167
|
+
# A bare write below `class <<` lands on the singleton's own constant table —
|
|
168
|
+
# `#<singleton>::K` names nothing — so the discovered-class entry is declined.
|
|
169
|
+
# A path write (`::K`, `C::K`, `Foo::F`) resolves its base lexically and stays nameable.
|
|
170
|
+
return false if singleton_cref && !DeclarationWalk::Rules.meta_new_path_target_nameable?(node, self_prefix)
|
|
171
|
+
|
|
172
|
+
full = child_prefix.join("::")
|
|
173
|
+
discovered[full] = Type::Combinator.singleton_of(full) unless full.empty?
|
|
174
|
+
# The rvalue's receiver and arguments evaluate BEFORE the write lands — under the
|
|
175
|
+
# enclosing self — while the block runs with `self` rebound to the class the write
|
|
176
|
+
# names (`K = Class.new(class self::Y; self; end)` opens `C::Y`, not `C::K::Y`).
|
|
177
|
+
[rvalue.receiver, *rvalue.arguments&.arguments.to_a].compact.each do |part|
|
|
178
|
+
record_declarations(part, qualified_prefix, identity_table, discovered,
|
|
179
|
+
EMPTY_RENAMES, self_prefix, singleton_cref: singleton_cref)
|
|
180
|
+
end
|
|
181
|
+
if (body = rvalue.block.is_a?(Prism::BlockNode) && rvalue.block.body)
|
|
182
|
+
record_declarations(body, qualified_prefix, identity_table, discovered,
|
|
183
|
+
EMPTY_RENAMES, child_prefix, singleton_cref: singleton_cref)
|
|
184
|
+
end
|
|
185
|
+
true
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# The eval-family arm of {.record_declarations}: the receiver and arguments keep the
|
|
189
|
+
# enclosing self; the block's `self` is the receiver for `self::` headers —
|
|
190
|
+
# `Foo.class_eval { class self::Inner }` opens `Foo::Inner`, never `M::Inner` — while
|
|
191
|
+
# `Module.nesting`, and so every bare header, stays lexical. `instance_eval` belongs
|
|
192
|
+
# too: it rebinds `self` for constant anchoring even though its `def`s bind on the
|
|
193
|
+
# receiver's singleton.
|
|
194
|
+
def record_eval_declarations?(node, qualified_prefix, identity_table, discovered, renames,
|
|
195
|
+
self_prefix, singleton_cref)
|
|
196
|
+
return false unless node.block.is_a?(Prism::BlockNode) &&
|
|
197
|
+
RECEIVER_EVAL_CALLS.include?(node.name)
|
|
198
|
+
|
|
199
|
+
[node.receiver, *node.arguments&.arguments.to_a].compact.each do |part|
|
|
200
|
+
record_declarations(part, qualified_prefix, identity_table, discovered, renames,
|
|
201
|
+
self_prefix, singleton_cref: singleton_cref)
|
|
202
|
+
end
|
|
203
|
+
unnameable = DeclarationWalk::Rules.unnameable_eval_self?(false, self_prefix, qualified_prefix,
|
|
204
|
+
singleton_cref)
|
|
205
|
+
eval_self = DeclarationWalk::Rules.eval_receiver_prefix(node, self_prefix || qualified_prefix,
|
|
206
|
+
qualified_prefix, unnameable_self: unnameable) || []
|
|
207
|
+
if (body = node.block.body)
|
|
208
|
+
record_declarations(body, qualified_prefix, identity_table, discovered, renames,
|
|
209
|
+
eval_self, singleton_cref: singleton_cref)
|
|
210
|
+
end
|
|
211
|
+
true
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
private_class_method :file_compact_header_renames, :record_declarations, :record_class_or_module?,
|
|
215
|
+
:record_meta_new_constant?, :record_eval_declarations?
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
end
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "digest"
|
|
4
|
+
require "prism"
|
|
5
|
+
|
|
6
|
+
module Rigor
|
|
7
|
+
module Inference
|
|
8
|
+
module ScopeIndexer
|
|
9
|
+
# ADR-89 WD1's declaration signature of one file, moved out of `scope_indexer.rb` whole (ADR-116 WD9, L1).
|
|
10
|
+
# {.declaration_signature} renders the cross-file declaration surfaces of a single file's index into parts
|
|
11
|
+
# and digests them; every other function here is one of its parts. It reads the index it is handed and,
|
|
12
|
+
# lexically, `ScopeIndexer::CONSTANT_MEMO`, and calls nothing else of the indexer: `scope_indexer.rb` requires
|
|
13
|
+
# this file, and this file does not require it back. So the file loads alone but answers only once
|
|
14
|
+
# `scope_indexer.rb` has loaded: rendering a constant write that publishes no literal reads `CONSTANT_MEMO`, a
|
|
15
|
+
# `NameError` until then, as the indexer's constants are for {NodePropagation}, which reads them the same way.
|
|
16
|
+
module DeclarationSignature
|
|
17
|
+
module_function
|
|
18
|
+
|
|
19
|
+
# ADR-89 WD1 — a per-file digest of every cross-file DECLARATION surface an ancestry / file-level
|
|
20
|
+
# dependent consumes, EXCLUDING method bodies (which only symbol dependents consume, via the ADR-46
|
|
21
|
+
# symbol edges the change-detection already fingerprints per method). A body edit that touches no
|
|
22
|
+
# signature leaves this equal, so the session drops the file's ancestry / file-level dependents; an
|
|
23
|
+
# arity / visibility / added-or-removed-method / ancestry / member-layout edit moves it. Deliberately
|
|
24
|
+
# SYNTACTIC (parameter structure from the def node, not inferred types).
|
|
25
|
+
#
|
|
26
|
+
# It captures, from a single file's live def-index: declared class/module names, superclass + include
|
|
27
|
+
# ancestry, Data/Struct member layouts, the accessor/alias/define_method existence table, per-method
|
|
28
|
+
# visibilities, and per method (instance + singleton) its name, parameter signature, AND def-start LINE.
|
|
29
|
+
# The line is load-bearing for soundness: a body edit that SHIFTS a later def's line moves the ADR-17
|
|
30
|
+
# `project_definition_site` a `call.undefined-method` consumer embeds, so a line shift must invalidate
|
|
31
|
+
# the declaration (the file's dependents re-check) — this is why the signature is a superset of B1's
|
|
32
|
+
# comment-stripped code fingerprint on line-moving edits, and strictly more permissive only on
|
|
33
|
+
# same-line body edits (a local rename, an internal literal), which is the collapse WD1 exists for.
|
|
34
|
+
def declaration_signature(file_index)
|
|
35
|
+
parts = []
|
|
36
|
+
append_ancestry_signature(parts, file_index)
|
|
37
|
+
append_constant_signature(parts, file_index)
|
|
38
|
+
append_declaration_tables(parts, file_index)
|
|
39
|
+
append_def_signatures(parts, file_index[:def_nodes], "#")
|
|
40
|
+
append_def_signatures(parts, file_index[:singleton_def_nodes], ".")
|
|
41
|
+
append_envelope_signature(parts, file_index[:parameter_envelopes] || {})
|
|
42
|
+
append_certainty_signature(parts, file_index[:siblings] || {})
|
|
43
|
+
Digest::SHA256.hexdigest(parts.join("\x00"))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# ADR-119 WD3 — which of the file's contributions are possible is a declaration surface too: a `… end if X`
|
|
47
|
+
# modifier, or moving a `def` into a block, keeps every def line and envelope and moves only this, while a
|
|
48
|
+
# dependent's candidate-set read now declines where it answered.
|
|
49
|
+
def append_certainty_signature(parts, siblings)
|
|
50
|
+
certainty = []
|
|
51
|
+
siblings.each do |name, table|
|
|
52
|
+
next if table.empty?
|
|
53
|
+
|
|
54
|
+
if name == :possible_discovered_methods
|
|
55
|
+
table.each do |class_name, row|
|
|
56
|
+
row.each { |method_name, kind| certainty << "P:#{class_name}##{method_name}=#{kind}" }
|
|
57
|
+
end
|
|
58
|
+
else
|
|
59
|
+
table.each { |path| certainty << "C:#{name}:#{path.inspect}" }
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
parts.concat(certainty.sort)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Issue #992 — the joined envelope table is a declaration surface the per-def signatures above cannot
|
|
66
|
+
# reconstruct: they keep the LAST `def` of a name, and they see neither a second `def` with another
|
|
67
|
+
# shape nor a `memoize :f` beside it, either of which moves a dependent's `call.wrong-arity` verdict.
|
|
68
|
+
def append_envelope_signature(parts, envelopes)
|
|
69
|
+
envelopes.sort_by { |cn, _| cn.to_s }.each do |class_name, entries|
|
|
70
|
+
entries.map { |key, envelope| "a:#{class_name}#{key.inspect}=#{envelope.inspect}" }.sort.each do |part|
|
|
71
|
+
parts << part
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Issue #644 — the cross-file VALUE-constant surface. Load-bearing for soundness, not precision: a
|
|
77
|
+
# file's published constants are a declaration-level fact its file-level dependents consume, so
|
|
78
|
+
# `FOO = :sym` becoming `FOO = :other` MUST move this signature or the reader would be declaration-
|
|
79
|
+
# stable, dropped from the closure, and served the pre-edit `:sym`. Both halves are here: the write
|
|
80
|
+
# NAMES (an added / removed / renamed assignment) and the published VALUES (a same-name value edit).
|
|
81
|
+
def append_constant_signature(parts, file_index)
|
|
82
|
+
parts.concat((file_index[:constant_writes] || {}).sort.map do |name, by_path|
|
|
83
|
+
"k:#{name}=#{constant_descriptor_signature(by_path.values.first)}"
|
|
84
|
+
end)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# `[literal]` renders its value, a `||=`-only name `||`, and an unpublishable write `?`. All three halves
|
|
88
|
+
# matter: a write appearing or vanishing moves the signature, and so does the same name's value or
|
|
89
|
+
# memo status changing.
|
|
90
|
+
def constant_descriptor_signature(descriptor)
|
|
91
|
+
return descriptor.first.inspect if descriptor.is_a?(Array)
|
|
92
|
+
|
|
93
|
+
descriptor == CONSTANT_MEMO ? "||" : "?"
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# The class-declaration + ancestry + member-layout surface of the declaration signature (declared class
|
|
97
|
+
# names, superclass / include ancestry, Data/Struct member layouts). Kept out of
|
|
98
|
+
# {#declaration_signature} to hold its ABC budget.
|
|
99
|
+
def append_ancestry_signature(parts, file_index)
|
|
100
|
+
parts.concat(file_index[:class_sources].keys.sort_by(&:to_s).map { |cn| "c:#{cn}" })
|
|
101
|
+
parts.concat(sorted_by_class(file_index[:superclasses]).map { |cn, sc| "s:#{cn}<#{sc}" })
|
|
102
|
+
append_mixin_signature(parts, file_index)
|
|
103
|
+
parts.concat(sorted_by_class(file_index[:data_member_layouts]).map { |cn, l| "d:#{cn}=#{l.inspect}" })
|
|
104
|
+
parts.concat(sorted_by_class(file_index[:struct_member_layouts]).map { |cn, l| "t:#{cn}=#{l.inspect}" })
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# The mixin surface of {#append_ancestry_signature}. The lists keep SOURCE order: this is one file's own
|
|
108
|
+
# index, so the order is deterministic, and it is a fact an ancestor-order reader consumes, so an edit
|
|
109
|
+
# that only reorders an `include` must move the signature. The unpositioned table is there for the same
|
|
110
|
+
# reason: guarding an `include` changes no name and no order, only whether the order is known.
|
|
111
|
+
def append_mixin_signature(parts, file_index)
|
|
112
|
+
{ "i" => :includes, "p" => :prepends, "x" => :extends }.each do |tag, key|
|
|
113
|
+
sorted_by_class(file_index[key] || {}).each { |cn, mods| parts << "#{tag}:#{cn}=#{Array(mods).join(',')}" }
|
|
114
|
+
end
|
|
115
|
+
sorted_by_class(file_index[:unpositioned_mixins] || {}).each do |cn, sides|
|
|
116
|
+
sides.sort_by { |side, _| side.to_s }.each do |side, names|
|
|
117
|
+
parts << "u:#{cn}.#{side}=#{names.sort.join(',')}"
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# A class-keyed table's pairs sorted by class name (stringified) for a deterministic signature.
|
|
123
|
+
def sorted_by_class(table)
|
|
124
|
+
table.sort_by { |cn, _| cn.to_s }
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# The method-existence and visibility surfaces of the declaration signature (kept out of
|
|
128
|
+
# {#declaration_signature} to hold its ABC budget). Both are consumed cross-file — the existence table
|
|
129
|
+
# by undefined-method suppression, the visibilities by the ADR-35 override-visibility rule.
|
|
130
|
+
def append_declaration_tables(parts, file_index)
|
|
131
|
+
file_index[:methods].sort_by { |cn, _| cn.to_s }.each do |cn, table|
|
|
132
|
+
table.sort_by { |m, _| m.to_s }.each { |m, kind| parts << "e:#{cn}##{m}=#{kind}" }
|
|
133
|
+
end
|
|
134
|
+
file_index[:method_visibilities].sort_by { |cn, _| cn.to_s }.each do |cn, table|
|
|
135
|
+
table.sort_by { |m, _| m.to_s }.each { |m, vis| parts << "v:#{cn}##{m}=#{vis}" }
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Appends one def-node table's per-method signature entries (name + parameter structure + def-start
|
|
140
|
+
# line) under `separator` (`#` instance / `.` singleton). Nodes here are always LIVE (both call sites —
|
|
141
|
+
# {ScopeIndexer#scan_summary_for_paths} and {ScopeIndexer#build_seed_bundle} — pass a freshly parsed
|
|
142
|
+
# single-file index), so the parameter structure and location are read directly.
|
|
143
|
+
def append_def_signatures(parts, defs, separator)
|
|
144
|
+
defs.sort_by { |cn, _| cn.to_s }.each do |class_name, methods|
|
|
145
|
+
methods.sort_by { |m, _| m.to_s }.each do |method_name, node|
|
|
146
|
+
parts << "m:#{class_name}#{separator}#{method_name}#{parameter_signature(node)}@#{def_start_line(node)}"
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# ADR-89 WD1 — a compact, order-preserving descriptor of a def node's parameter STRUCTURE: each
|
|
152
|
+
# parameter's kind (required / optional / rest / post / keyword-required / keyword-optional /
|
|
153
|
+
# keyword-rest / block / forwarding) and name, plus default-PRESENCE (implied by the optional kinds).
|
|
154
|
+
# Names are included for all parameter positions: soundness-first (a keyword-name change is Liskov-
|
|
155
|
+
# visible to overriders; a positional-name change is rare and only over-conservatively keeps a
|
|
156
|
+
# dependent). Not the inferred parameter TYPE — this gate is deliberately syntactic.
|
|
157
|
+
def parameter_signature(node)
|
|
158
|
+
return "()" unless node.respond_to?(:parameters)
|
|
159
|
+
|
|
160
|
+
params = node.parameters
|
|
161
|
+
return "()" if params.nil?
|
|
162
|
+
|
|
163
|
+
parts = []
|
|
164
|
+
parts.concat(labelled_params(params.requireds, "r"))
|
|
165
|
+
parts.concat(labelled_params(params.optionals, "o"))
|
|
166
|
+
parts.concat(labelled_params(params.posts, "p"))
|
|
167
|
+
parts.concat(labelled_params(params.keywords) { |p| keyword_param_kind(p) })
|
|
168
|
+
parts.concat(rest_param_parts(params))
|
|
169
|
+
"(#{parts.join(',')})"
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# The `<kind>:<name>` labels for a list of parameter nodes (nil → none). `kind` is a fixed String or a
|
|
173
|
+
# block computing it per node (for the keyword-required / keyword-optional split).
|
|
174
|
+
def labelled_params(nodes, kind = nil)
|
|
175
|
+
(nodes || []).map { |p| "#{kind || yield(p)}:#{param_label(p)}" }
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# The single rest / keyword-rest / block parameter labels (each present at most once).
|
|
179
|
+
def rest_param_parts(params)
|
|
180
|
+
parts = []
|
|
181
|
+
parts << "*:#{param_label(params.rest)}" if params.rest
|
|
182
|
+
parts << "**:#{param_label(params.keyword_rest)}" if params.keyword_rest
|
|
183
|
+
parts << "&:#{param_label(params.block)}" if params.block
|
|
184
|
+
parts
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def keyword_param_kind(param)
|
|
188
|
+
param.is_a?(Prism::OptionalKeywordParameterNode) ? "ko" : "kr"
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# A parameter node's name, or a class-tagged sentinel for the nameless / destructuring forms
|
|
192
|
+
# (`MultiTargetNode`, an anonymous `*` / `**` / `&`, `NoKeywordsParameterNode`, `ForwardingParameterNode`).
|
|
193
|
+
def param_label(param)
|
|
194
|
+
return "" if param.nil?
|
|
195
|
+
|
|
196
|
+
param.respond_to?(:name) && param.name ? param.name.to_s : param.class.name.split("::").last
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# The 1-based start line of a live def node (the `project_definition_site` an ADR-17 consumer embeds).
|
|
200
|
+
def def_start_line(node)
|
|
201
|
+
node.respond_to?(:location) ? node.location.start_line : 0
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
private_class_method :append_certainty_signature, :append_envelope_signature, :append_constant_signature,
|
|
205
|
+
:constant_descriptor_signature, :append_ancestry_signature, :append_mixin_signature,
|
|
206
|
+
:sorted_by_class, :append_declaration_tables, :append_def_signatures,
|
|
207
|
+
:parameter_signature, :labelled_params, :rest_param_parts, :keyword_param_kind,
|
|
208
|
+
:param_label, :def_start_line
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|
|
@@ -11,8 +11,8 @@ module Rigor
|
|
|
11
11
|
class DefNestingsCollector
|
|
12
12
|
include DeclarationWalk::Collector
|
|
13
13
|
|
|
14
|
-
# The rules
|
|
15
|
-
# byte-identical (ADR-116 WD5). Each is a legacy answer, and #1521 tracks converging it:
|
|
14
|
+
# The rules {SharedWalkTables.walk_def_nestings} answered differently from the walk, kept so the table
|
|
15
|
+
# stays byte-identical (ADR-116 WD5). Each is a legacy answer, and #1521 tracks converging it:
|
|
16
16
|
#
|
|
17
17
|
# - `factory_block: :ordinary_call` — no bare-factory arm, so a `self::` header in a `Class.new { … }`
|
|
18
18
|
# block anchors on the enclosing `self` and the block's parameters are walked (#1521 item 8).
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../declaration_walk/rules"
|
|
4
|
+
|
|
5
|
+
module Rigor
|
|
6
|
+
module Inference
|
|
7
|
+
module ScopeIndexer
|
|
8
|
+
# The factory call an expression unwinds to, moved out of `scope_indexer.rb` whole (ADR-116 WD9, #3400).
|
|
9
|
+
# {.resolve_meta_factory_call} answers the `Data.define` or `Struct.new` call under any `Class.new(...)`
|
|
10
|
+
# wrappers, or nil; the other two functions are its private steps.
|
|
11
|
+
#
|
|
12
|
+
# Three files call it, at four sites: `scope_indexer.rb` from the methods table
|
|
13
|
+
# (`ScopeIndexer.record_meta_members`), {DeclarationArtifacts} from the arm that takes a constant write
|
|
14
|
+
# (`DeclarationArtifacts.record_meta_new_constant?`), and {SharedWalkTables} from its two layout recorders. It
|
|
15
|
+
# asks {DeclarationWalk::Rules} which call is which factory, calls nothing left in `scope_indexer.rb` and reads
|
|
16
|
+
# none of the indexer's constants. Each caller requires this file, and it requires none back, so it loads and
|
|
17
|
+
# answers alone.
|
|
18
|
+
module FactoryCallResolver
|
|
19
|
+
module_function
|
|
20
|
+
|
|
21
|
+
# Unwinds nested single-parent `Class.new(...)` calls to a root `Struct.new(...)` / `Data.define(...)`.
|
|
22
|
+
# A nested wrapper or factory block is declined because its method overrides belong to the intermediate
|
|
23
|
+
# superclass and cannot be attributed to the outer class's reader-override guard.
|
|
24
|
+
def resolve_meta_factory_call(call_node, allow_outer_block: true)
|
|
25
|
+
wrapped = false
|
|
26
|
+
while DeclarationWalk::Rules.class_new_call?(call_node)
|
|
27
|
+
return nil if intermediate_factory_block?(call_node, wrapped, allow_outer_block)
|
|
28
|
+
|
|
29
|
+
arguments = call_node.arguments&.arguments
|
|
30
|
+
return nil unless arguments&.one?
|
|
31
|
+
|
|
32
|
+
call_node = arguments.first
|
|
33
|
+
wrapped = true
|
|
34
|
+
end
|
|
35
|
+
return nil unless meta_factory_call?(call_node)
|
|
36
|
+
return nil if intermediate_factory_block?(call_node, wrapped, allow_outer_block)
|
|
37
|
+
|
|
38
|
+
call_node
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def intermediate_factory_block?(call_node, wrapped, allow_outer_block)
|
|
42
|
+
(wrapped || !allow_outer_block) && !call_node.block.nil?
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def meta_factory_call?(call_node)
|
|
46
|
+
DeclarationWalk::Rules.data_define_call?(call_node) || DeclarationWalk::Rules.struct_new_call?(call_node)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private_class_method :intermediate_factory_block?, :meta_factory_call?
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|