Skip to content

Flow-sensitive typing - automatically downcast from is_a? calls #856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 56 commits into from
May 18, 2025

Conversation

apiology
Copy link
Contributor

No description provided.

@apiology apiology changed the title Flow-sensitive typing Flow-sensitive typing - automatically downcast from is_a? calls Apr 7, 2025
@apiology apiology marked this pull request as ready for review April 7, 2025 02:07
@apiology apiology marked this pull request as draft April 10, 2025 15:12
@apiology apiology marked this pull request as ready for review April 10, 2025 20:41
apiology added 15 commits April 11, 2025 09:51
* Populate location information from RBS files

The 'rbs' gem maps the location of different definitions to the
relevant point in the RGS files themselves - this change provides the
ability to jump into the right place in those files to see the type
definition via the LSP.

* Prefer source location in language server

* Resolve merge issue

* Fix Path vs String type error
* Consolidate parameter handling into Pin::Closure

* Clarify clobbered variable names

* Fix bug in to_rbs, add spec, then fix new bug found after running spec

* Catch one more Signature.new to translate from strict typechecking

* Introduce Pin::Callable

* Introduce Pin::Callable

* Introduce Pin::Callable

* Introduce Pin::Callable

* Introduce Pin::Callable

* Introduce Pin::Callable

* Introduce Pin::Callable

* Use Pin::Callable type in args_node.rb

* Select String#each_line overload with mandatory vs optional arg info
elsif n.type == :yield
args = n.children.map { |c| NodeChainer.chain(c, @filename, n) }
result.push Chain::Call.new('yield', args)
result.push Chain::Call.new('yield', Location.from_node(n), args)
elsif n.type == :const
const = unpack_name(n)
result.push Chain::Constant.new(const)
elsif [:lvasgn, :ivasgn, :gvasgn, :cvasgn].include?(n.type)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub won't let me highlight the entire code block, so I can't make a proper suggestion. Replacing lines 92-102 with this resolves the conflict and passes tests:

          elsif [:lvar, :lvasgn].include?(n.type)
            result.push Chain::Call.new(n.children[0].to_s, Location.from_node(n))
          elsif [:ivar, :ivasgn].include?(n.type)
            result.push Chain::InstanceVariable.new(n.children[0].to_s)
          elsif [:cvar, :cvasgn].include?(n.type)
            result.push Chain::ClassVariable.new(n.children[0].to_s)
          elsif [:gvar, :gvasgn].include?(n.type)
            result.push Chain::GlobalVariable.new(n.children[0].to_s)
          elsif n.type == :or_asgn

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Applied

@castwide
Copy link
Owner

Thanks again! :shipit:

@castwide castwide merged commit 98958db into castwide:master May 18, 2025
8 checks passed
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.

2 participants