Skip to content

Reduce use of ComplexType.parse() to preserve rooted? information #870

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 31 commits into from
Apr 24, 2025

Conversation

apiology
Copy link
Contributor

@apiology apiology commented Apr 2, 2025

No description provided.

apiology and others added 30 commits March 23, 2025 15:50
* Consolidate the code that generates substrings to a single place
* Clean up more paths to pass through 'rooted' flag unchanged
* [breaking] Drop special-case interpretation of, e.g., `Array<(String)>` as
  'one element tuple' for future consistency with
  https://yardoc.org/types

  * (String) is a one element tuple in https://yardoc.org/types
  * <String> is an array of zero or more Strings in https://yardoc.org/types
  * Array<(String)> could be an Array of one-element tuples or a
    one element tuple.  https://yardoc.org/types treats it
    as the former.
  * Array<(String), Integer> is not ambiguous if we accept
    (String) as a tuple type, but not currently understood
    by Solargraph.
@castwide
Copy link
Owner

Looks great, thanks!

Interesting side note: based on some rough benchmarks of the spec suite, this branch seems to generate ComplexType instances more often than master, which surprised me. It might be due to ComplexType.new skipping the caching mechanism in ComplexType.parse. Nevertheless, the benefits of preserving rooted? information appear to be much more valuable.

@castwide castwide merged commit 97dfd31 into castwide:master Apr 24, 2025
8 checks passed
apiology added a commit to apiology/solargraph that referenced this pull request Apr 28, 2025
…stwide#870)

* [breaking] Fix more complex_type_spec.rb cases

* Consolidate the code that generates substrings to a single place
* Clean up more paths to pass through 'rooted' flag unchanged
* [breaking] Drop special-case interpretation of, e.g., `Array<(String)>` as
  'one element tuple' for future consistency with
  https://yardoc.org/types

  * (String) is a one element tuple in https://yardoc.org/types
  * <String> is an array of zero or more Strings in https://yardoc.org/types
  * Array<(String)> could be an Array of one-element tuples or a
    one element tuple.  https://yardoc.org/types treats it
    as the former.
  * Array<(String), Integer> is not ambiguous if we accept
    (String) as a tuple type, but not currently understood
    by Solargraph.

* Close out complex_type_spec @todos for better RBS output

* Simplify qualify() with transform()

* Reduce use of ComplexType.parse() to preserve rooted? information

* Make TypeMethods#rooted? more aggressive

* Fix flaky rename specs

* Reduce use of ComplexType.parse() to preserve rooted? information

* Reduce use of ComplexType.parse() to preserve rooted? information

* Fix merge issue

* Fix merge issue

* Use rooted_tag, remove two more parse() calls

* Preserve types in attr_accessor

* Reassure TypeMethods that implementers will have all_params

* Add regression test around assignment in return position

* Fix merge

* Separate the semantics of Type#rooted? and (new) Type#all_rooted?

* Test and fix issues keeping types from RBS input rooted

* Handle addiitional RBS types explicitly for type safety

---------

Co-authored-by: Fred Snyder <[email protected]>
castwide added a commit that referenced this pull request Jun 24, 2025
* Infer literal types and use them for signature selection

* Introduce tuple type via an RBS-based fill

* Use methods from the new tuple type for Array()

* Hold back on representing literal strings

* Resolve merge

* Update spec/source_map/clip_spec.rb

* Resolve merge issues

* Update test expectations

* [regression] Restore 'Unresolved call' typecheck for stdlib objects (#849)

The 'Unresolved call to' typecheck suppresses warnings for calls
against non-RBS-origin pins.  However, the labeling assigning :rbs as
the source of pins from conversions.rb was recently removed as part of
an unrelated cleanup.

* Lazy dynamic rebinding (#851)

* Lazy dynamic rebinding

* Stub failing test

* Move rebinding to Clip

* Restore fill for Class#allocate (#848)

* [regression] Ensure YardMap gems have return type for Class<T>.new (#850)

* [regression] Ensure YardMap gems have return type for Class<T>.new

* Handle self return-type-setting at lower level

* Fix bug where signature return type was based only on annotation

* Create implicit .new pins in namespace method queries (#853)

* Create implicit .new pins in namespace method queries

* Comment for Host#locate_pins exception

* Release 0.53.3

* Use logger in Solargraph::YardMap::Mapper spec

* Add support for simple block argument destructuring (#821)

* Add support for simple block argument destructuring

* Add spec for Array<Array(String, Integer)>#each

* Internal typechecking-driven annotations and code changes (#838)

* Internal typechecking-driven annotations and code changes

* Add @todo for predicate method return type issue

* Internal typechecking-driven annotations and code changes

* Benchmark the typecheck command (#852)

* Enable passing tests (#854)

* Send Gem Caching Progress Notifications to LSP Clients (#855)

* Send gem caching notifications

* LanguageServer::Progress

* DRY progress notifications

* Refactor

* added failing tests (#573)

* [breaking] Fix more complex_type_spec.rb cases (#813)

* [breaking] Fix more complex_type_spec.rb cases

* Consolidate the code that generates substrings to a single place
* Clean up more paths to pass through 'rooted' flag unchanged
* [breaking] Drop special-case interpretation of, e.g., `Array<(String)>` as
  'one element tuple' for future consistency with
  https://yardoc.org/types

  * (String) is a one element tuple in https://yardoc.org/types
  * <String> is an array of zero or more Strings in https://yardoc.org/types
  * Array<(String)> could be an Array of one-element tuples or a
    one element tuple.  https://yardoc.org/types treats it
    as the former.
  * Array<(String), Integer> is not ambiguous if we accept
    (String) as a tuple type, but not currently understood
    by Solargraph.

* Close out complex_type_spec @todos for better RBS output

* Simplify qualify() with transform()

* Resolve merge issue

* Mass assignment support - e.g., a, b = ['1', '2'] (#843)

* Memoize result of Chain#infer (#857)

* Memoize result of Chain#infer

* Add links to cache key

* Add node.location separately to cache key

https://github.com/whitequark/ast/blob/master/lib/ast/node.rb

https://github.com/whitequark/parser/blob/05b88aa0468ce29dfa21e1aff2f0506b1d5d82e1/lib/parser/ast/node.rb#L17

Parser::AST adds 'location' in Parser::AST::Node to its superclass
AST::Node, but doesn't overwrite the #hash and #eql? methods

* Fall back to using links.map(&:word)

* Implement eql? and hash for ApiMap for cache coherency

* Remove @cache from ApiMap#equality_fields

* Remove clip caches (#860)

* Add rbs_collection to maps (#858)

* Fix flaky rename specs (#869)

* Ignore malformed mixins and overloads (#862)

* Ignore malformed mixins

* Ignore malformed overload tags

* Add internal type annotations needed for strict-level typechecking (#865)

* Add internal type annotations needed for strict-level typechecking

* Fix annotations

* Add internal type annotations needed for strict-level typechecking

* Fix flaky rename specs

* Move to untyped as Hash value

---------

Co-authored-by: Fred Snyder <[email protected]>

* Drop Parser::ParserGem::ClassMethods#returns_from_node (#866)

* Refactor TypeChecker#argument_problems_for for type safety (#867)

* Refactor TypeChecker#argument_problems_for for type safety

This should put it in a state that it can pass type checking once we
have another feature or two

* Editor compatibility hack

* Fix class name

* Fix flaky rename specs

---------

Co-authored-by: Fred Snyder <[email protected]>

* Specify more type behavior for variable reassignment (#863)

* One-step source synchronization (#871)

* One-step source synchronization

* Synchronize libraries

* Fix progress notification timing (#873)

* Show cache progress in shell commands (#874)

* Show cache progress in shell commands

* Typecheck error

* Update spec/source_map/clip_spec.rb

* Resolve merge issues

* Update test expectations

* Update test expectations

* Fix merge issue

* Add regression test around assignment in return position

* Adjust spec expectations

* Fix merge

* Resolve merge issue

* Reduce use of ComplexType.parse() to preserve rooted? information (#870)

* [breaking] Fix more complex_type_spec.rb cases

* Consolidate the code that generates substrings to a single place
* Clean up more paths to pass through 'rooted' flag unchanged
* [breaking] Drop special-case interpretation of, e.g., `Array<(String)>` as
  'one element tuple' for future consistency with
  https://yardoc.org/types

  * (String) is a one element tuple in https://yardoc.org/types
  * <String> is an array of zero or more Strings in https://yardoc.org/types
  * Array<(String)> could be an Array of one-element tuples or a
    one element tuple.  https://yardoc.org/types treats it
    as the former.
  * Array<(String), Integer> is not ambiguous if we accept
    (String) as a tuple type, but not currently understood
    by Solargraph.

* Close out complex_type_spec @todos for better RBS output

* Simplify qualify() with transform()

* Reduce use of ComplexType.parse() to preserve rooted? information

* Make TypeMethods#rooted? more aggressive

* Fix flaky rename specs

* Reduce use of ComplexType.parse() to preserve rooted? information

* Reduce use of ComplexType.parse() to preserve rooted? information

* Fix merge issue

* Fix merge issue

* Use rooted_tag, remove two more parse() calls

* Preserve types in attr_accessor

* Reassure TypeMethods that implementers will have all_params

* Add regression test around assignment in return position

* Fix merge

* Separate the semantics of Type#rooted? and (new) Type#all_rooted?

* Test and fix issues keeping types from RBS input rooted

* Handle addiitional RBS types explicitly for type safety

---------

Co-authored-by: Fred Snyder <[email protected]>

* Ensure yield return types are qualified (#886)

* Ensure yield return types are qualified

* Add regression test around assignment in return position

* Understand type of 'def foo; @foo ||= bar; end' reader methods (#888)

* Improvements to #inspect output on pins and chains (#895)

* Remove redundant extend in Parser (#900)

* Remove redundant extend in Parser

* Update lib/solargraph/parser.rb

Co-authored-by: Vince Broz <[email protected]>

---------

Co-authored-by: Vince Broz <[email protected]>

* Block method resolution improvements (#885)

* Block method resolution improvements

* Add regression test around assignment in return position

* Fix merge issue

* Fix merge issue

* Understand mass assignment into instance variables (#893)

* Library sync and cache invalidation (#903)

* Library sync and cache invalidation

* Stop sleeping in catalog threads in mingw

* JIT library sync without threads

* MessageWorker prioritizes messages

* Unused instance variable

* JIT source parsing

* Fix JIT source parsing

* Avoid unnecessary parsing in library

* JIT source mapping

* Specs

* Stale code

* Library#map! finds external requires

* Preserve SourceMap#try_merge!

* Force catalog after caching gemspecs

* Synchronize count check in Library#sync_catalog

* Handle super and yield scenarios from blocks (#891)

* Handle super and yield scenarios from blocks

* Update spec/source_map/clip_spec.rb

Co-authored-by: Fred Snyder <[email protected]>

---------

Co-authored-by: Fred Snyder <[email protected]>

* Allow core and stdlib documentation to be uncached (#899)

* Allow core and stdlib documentation to be uncached

* Fix typo

* Surface variable names in documentation (#910)

* Surface variable names in documentation

* Documentation

* Keep idle progress notifications alive (#911)

* Release 0.54.1

* Release 0.54.1 patch: remove mutex from Library sync_count check

* Resolve generics correctly on mixin inclusion (#898)

* Resolve generics correctly on mixin inclusion

* Reduce expectations pending merge of another fix

* Fix merge issue

* Add alias-related regression test that now passes

* Method alias fixes

* Ensure method aliases are processed with resolve_generics()
* Avoid an extra hop in get_methods() resulting in no alias resolution

* Resolve merge issue

* Pick correct String#split overload (#905)

* Pick correct String#split overload

* Look for parameter types in superclasses too when resolving overloads
* Look at all unique types on parameters when resolving overloads

* Add @sg-ignore

* Fix type sent into YARD method (#912)

While it declares itself wanting a String, in reality the YARD method
takes #to_s, so this change just squashes a typechecking warning

* Early CancelRequest handling (#914)

* Destructure partial yield types (#915)

* Dependency versions (#916)

* Release 0.54.2

* Generic superclasses and defaulted type parameters via RBS

Enables scenarios using typed Array<A | B |C> methods from Array(A, B, C)

* Fix qualify_superclass's treatment of namespaces vs tags

* Render string literals from RBS in a useful way

* Treat literal nil as NilClass for method resolution and vice versa

Apply same for true/TrueClass and false/FalseClass

* Fix merge issue

* Fix merge issue

---------

Co-authored-by: Fred Snyder <[email protected]>
Co-authored-by: BonitaTerror <[email protected]>
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