-
Notifications
You must be signed in to change notification settings - Fork 15
Reapply "Merge pull request #46 from byroot/use-forward-send" #51
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -405,6 +405,17 @@ def DelegateClass(superclass, &block) | |||||
| protected_instance_methods -= ignores | ||||||
| public_instance_methods = superclass.public_instance_methods | ||||||
| public_instance_methods -= ignores | ||||||
|
|
||||||
| normal, special = public_instance_methods.partition { |m| m.match?(/\A[a-zA-Z]\w*[!\?]?\z/) } | ||||||
|
|
||||||
| source = normal.map do |method| | ||||||
| "def #{method}(...); __getobj__.#{method}(...); end" | ||||||
|
||||||
| "def #{method}(...); __getobj__.#{method}(...); end" | |
| "def #{method}(...); __getobj__.__send__(:#{method}, ...); end" |
Copilot
AI
Dec 17, 2025
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.
The generated method definitions are joined with semicolons on a single line, which will make stack traces harder to read and debug. When an error occurs in a delegated method, the backtrace will show all methods as being on the same line.
Consider joining with newlines instead of semicolons to provide clearer stack traces and better debuggability.
Copilot
AI
Dec 17, 2025
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.
The line number argument __LINE__ in class_eval is incorrect. Since multiple method definitions are joined with semicolons on a single line, all methods will appear to be defined on line 430 in stack traces, making debugging difficult.
Additionally, using __LINE__ here will report the line number of the class_eval call itself, not the line where the method definitions actually start (line 412-414). This will cause confusion when debugging errors in delegated methods.
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.
Why "normal" methods need to start with an alphabet, e.g.,
_is not the case?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.
It's a mistake
_should be there too. But it's not a big deal, just means they don't benefit from the optimization.