rbs icon indicating copy to clipboard operation
rbs copied to clipboard

Add support for `undef`

Open sampersand opened this issue 1 year ago • 3 comments

Quite a few things in the standard library (and a few of my personal projects) undefine methods from parent classes (for example, Class inherits from Module but undefs refine and module_function). Having syntax for it would be helpful.

sampersand avatar Nov 28 '23 22:11 sampersand

Hmm. The syntax would be something like:

class Class
  undef refine

  undef self.module_function       # Example for singleton method
end

And we can implement it by removing the entry from Definition#methods or adding a special entry.

soutaro avatar Nov 29 '23 05:11 soutaro

The way ruby does it is it actually creates a new method in the class, but gives it the "UNDEF" visibility. We could try something similar

sampersand avatar Feb 06 '24 03:02 sampersand

A concern is that undefs actively break polymorphism, though this would be Ruby’s issue, not RBS’s.

ParadoxV5 avatar Jul 21 '24 21:07 ParadoxV5