(delegate) Sigs for delegate + proposal for delegator defs in RBS #765
Open
HoneyryderChuck wants to merge 4 commits intoruby:masterfrom
Open
(delegate) Sigs for delegate + proposal for delegator defs in RBS #765HoneyryderChuck wants to merge 4 commits intoruby:masterfrom
HoneyryderChuck wants to merge 4 commits intoruby:masterfrom
Conversation
96dbb69 to
5e1fa6a
Compare
By defining such RBS classes such as: ```ruby class Tempfile < Delegator[File] ... ``` with this patch, while building the instance definition, the class assigned to the Delegator definition is then merged with the main class definitions, which achieves the purpose of inheriting method definitions from the delegated class. This is a solution based on a stdlib definition however, so it might not be the best way to move forward.
5e1fa6a to
19dd2ba
Compare
HoneyryderChuck
commented
Aug 25, 2021
| end | ||
|
|
||
| module Kernel | ||
| def self?.DelegateClass: [A] (Class superclass) ?{ () -> singleton(Delegator) } -> singleton(Delegator) |
Contributor
Author
There was a problem hiding this comment.
Ideally this should be:
def self?.DelegateClass: [A] (Class superclass) ?{ () -> singleton(Delegator[A]) } -> singleton(Delegator[A])but the parser can't recognize singleton(Delegator[A]).
@soutaro add this along to the other caveats in the description.
Contributor
Author
|
@soutaro given the recent additions in 2.0 around bounded generics, shall we revisit this? I think we still need special syntax for this, i.e. smth like: class Delegator[T]
@delegate_sd_obj: T
# some rbs syntax to say "inherit API from T?
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(tentative) added support for inheriting from delegator classes
By defining such RBS classes such as:
with this patch, while building the instance definition, the class
assigned to the Delegator definition is then merged with the main
class definitions, which achieves the purpose of inheriting method
definitions from the delegated class.
This is a solution based on a stdlib definition however, so it might not
be the best way to move forward.