Skip to content
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

Support attr_accessors for singleton class #123

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tk0miya
Copy link
Contributor

@tk0miya tk0miya commented Oct 19, 2024

To support attr_accessor, reader and writer for singleton class, this converts them to the mere method definitions.

class Foo
  class << self
    attr_accessor :bar
  end
end

The above code will converted into the followings:

class Foo
  %a{pure}
  def self.bar: () -> untyped
  def self.bar=: (untyped) -> untyped
end

@soutaro
Copy link
Owner

soutaro commented Nov 18, 2024

@tk0miya Thank you for opening this PR. I guess we can just use attr_reader self.bar: untyped syntax?

@tk0miya tk0miya force-pushed the support_singleton_attr_accessors branch from 1402ea0 to 1b95167 Compare November 18, 2024 14:55
@tk0miya
Copy link
Contributor Author

tk0miya commented Nov 18, 2024

OMG! I don't know such a strong syntax. Now I fixed!

To support attr_accessor, reader and writer for singleton class, this
converts them to the mere method definitions.

```ruby
class Foo
  class << self
    attr_accessor :bar
  end
end
```

The above code will converted into the followings:

```ruby
class Foo
  attr_accessor self.bar: untyped
end
```
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