-
Notifications
You must be signed in to change notification settings - Fork 125
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
WIP: Add support for intercepting methods #656
base: master
Are you sure you want to change the base?
Conversation
Interesting PR. I haven't looked at the code yet, but there is a limitation that you may or may not have considered already. Since this has to be implemented by rewriting the call site, it can only cover usages in the source files of the consuming project/module. Calls from external code will not be intercepted, particularly concerning for API code, callbacks, and the like. I don't think this is a showstopper, but it should be clearly documented, maybe it is already? Couple other random thoughts.
|
Thank you for the valid remarks. Intercepted methods behave similarly to regular extensions, sharing the same behavior and limitations. There are only a few differences in how intercepted methods are handled:
In response to your questions:
|
This PR introduces the concept of intercepting (existing) methods, allowing you to modify their logic or introduce custom behavior before or after the original method executes.
The method's signature remains unchanged, meaning the return type, parameters, and any declared exceptions must be
preserved.
To intercept a method, simply annotate the (extension) method with
@Intercept
.Consider the following example: