-
Notifications
You must be signed in to change notification settings - Fork 217
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
RFC: new Attribute#ivar
API
#2110
base: master
Are you sure you want to change the base?
Conversation
@@ -304,6 +304,21 @@ def update(name: self.name, type: self.type, ivar_name: self.ivar_name, kind: se | |||
visibility: visibility | |||
) | |||
end | |||
|
|||
def ivar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the semantics are clear: You either get back an InstanceVariable
object, or nil
(meaning this attribute was declared with no backing ivar declaration, e.g. attr_reader foo(): Foo
).
Open question: How should we model the difference between these two?
attr_reader a: Foo # Ivar name is inferred
attr_reader a(@a): Foo # Same ivar name, but explicit
@@ -185,6 +185,8 @@ module RBS | |||
include _HashEqual | |||
|
|||
def update: (?name: Symbol, ?type: Types::t, ?ivar_name: Symbol | false | nil, ?kind: kind, ?annotations: Array[Annotation], ?location: loc?, ?comment: Comment?, ?visibility: visibility?) -> instance | |||
|
|||
def ivar: () -> InstanceVariable? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple return type! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it still make sense for ivar_name
to accept false in the constructor and the attr_reader?
1fff94e
to
e406183
Compare
self.ivar_name # Use the custom instance variable name given by the user | ||
end | ||
|
||
InstanceVariable.new(name: ivar_name, type: type, location: location, comment: comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open question: what should the location
and comment
be? The same as the attribute, or nil
?
My proposal for fixing #2109. Feedback welcome!