-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Warning with delegate and abstract method #8250
Comments
Another case that hints that abstract methods in this language should maybe disappear |
The same will happen for any macro that expands a method. They might need a way to inject the return type in order to comply with the current abstract method check. A way to unlock the delegate macro is to allow passing the returning type. delegate :bla, to: @bla, returning: Int32
delegate bla : Int32, to: @bla
# NOTE: proposal / not working example But it takes some of the fun. The property macro does allow return types already. As I mentioned at #8232 (comment) if the check is reframed as an after check to enforce that the contract of the abstract method is hold then this issue could be resolved without changes to the delegate macro. |
Maybe an after check could work. The problem is that when I tried to do that the compiler would already complain of the type mismatch in the regular type inference phase, or complain about the missing method. In summary, the compiler will complain, it's just that the error message will be slightly different. |
I understand that the compiler will probably complain before a delayed abstract check. If the offending override is used in a way it bothers. The explicit return type helped to catch this earlier. Maybe the relaxation is that if there is an explicit return type it needs to match the abstract def. That way the generated method that will probably work by construction will not need a workaround to annotate a return type. A compiler tool could be in charge of suggesting the explicit return types. (throwing ideas to find the sweet spot of freedom and contracts here) |
is this ok?
The text was updated successfully, but these errors were encountered: