In order to implement a "no clobber" checker as in #18618, I would like to have a way to check if a method calls super or not.
So I'm thinking that something along the line of Method#calls_super? could return true/false if the method simply contains the super keyword. I'm not really interested in handling weird/artificial edge cases with eval and binding and whatnot.
classXdefaend;pinstance_method(:a).calls_super?#=> falsedefbsuperend;pinstance_method(:b).calls_super?#=> truedefcsuperiffalseend;pinstance_method(:c).calls_super?#=> truedefdeval'super'end;pinstance_method(:d).calls_super?#=> false (I doubt there's a reasonable way for this to return true)end
With the above it would be possible to warn against a method that has a super_method but doesn't use the super keyword.
Subject changed from Introduce a way to tell if a method invokes the `super` keryword to Introduce a way to tell if a method invokes the `super` keyword
First, I am afraid that no_clobber checks using super would not work well. People would override methods without using super more often that you may expect. Some may copy code from the parent methods, some may just reimplement methods. So the biggest use-case is not valid from my POV.
Second, by the core method naming convention we do not use third-person singular present form (e.g 'include?' instead of 'includes?'). Some (especially native English speaker) may feel unnatural, but we set the rule, and we are not going to change it for the foreseeable future.