// Do not use needsSelf=true in module functions, it is either the module/class or the instance.
// Usage of needsSelf is quite rare for singleton methods (except constructors).
final boolean needsSelf = !anno.isModuleFunction() && !anno.onSingleton() && anno.needsSelf();
final RubyRootNode rootNode = makeGenericMethod(context, methodDetails, needsSelf);
final RubyMethod method = new RubyMethod(rootNode.getSharedMethodInfo(), canonicalName, module, visibility, false,
Truffle.getRuntime().createCallTarget(rootNode), null);
if (anno.isModuleFunction()) {
addMethod(module, method, aliases, Visibility.PRIVATE);
addMethod(module.getSingletonClass(null), method, aliases, Visibility.PUBLIC);