Skip to content

Conversation

@apiology
Copy link
Contributor

@apiology apiology commented Aug 29, 2025

Fixes a bunch of similar strong level typechecking errors on the Solargraph codebase.

Typical example:

module Solargraph2
  module Pin
    class Base
      # @param other [self]
      # @param attr [::Symbol]
      #
      # @sg-ignore
      # @return [undefined]
      def assert_same(other, attr); end

      # @param other [self]
      # @param attrs [Hash{Symbol => Object}]
      #
      # @return [self]
      def combine_with(other, attrs={})
      end
    end

    class BaseVariable < Base
      def combine_with(other, attrs={})
        attrs.merge({
          # Wrong argument type for Solargraph2::Pin::Base#assert_same: other expected Solargraph2::Pin::Base, received self
          mass_assignment: assert_same(other, :mass_assignment),
        })
      end
    end
  end
end

Depends on and includes:

@apiology apiology changed the title Make 'self' types concrete while checking arguments Make 'self' types concrete while typechecking arguments Aug 29, 2025
@apiology apiology marked this pull request as ready for review August 31, 2025 02:12
YARD-parsed namespaces weren't correctly setting their gates, leading
to unresolved types from methods.
1) Prefer closures with more gates, to maximize compatibility
2) Look at basename of location, to make choice consistent
Found in the Solargraph::Pin::DelegatedMethod class in strong
typechecking in #12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant