-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Don't allow weaker return type in overriden method #79765
base: master
Are you sure you want to change the base?
Conversation
8fb3b0c
to
ac66ebd
Compare
We should also remember about overriding native virtual functions. In this case we should make an exception and allow not specifying the return type (which is treated as |
This is already handled by the latest changes.
Yeah, but this is bugfix PR, so more specific type can be implemented later. |
ac66ebd
to
2019e31
Compare
2019e31
to
d2c95e6
Compare
Actually I misunderstood, you are describing the example I specifically showed as undesired. If this needs to be allowed, it should result in a warning at least. |
I see two conflicting problems:
Not entirely sure right now how to deal with this conflict. One potential solution is to treat the overridden method as if it has the same type as the original one if not specified. It may give some type errors even if the user isn't using types, but those would be technically correct. Although it would be tricky to inform the user about the inherited return type. I believe erroring like this would be annoying for someone who prefers to no use static types. If they inherit from an addon which does use types, they will get these errors, when types are supposed to be optional. |
Hence this could be a warning. |
This code
should result in an error, but it didn't.
EDIT:
This breaks methods that return Variant, I'll try to fix it xd
EDIT2:
Fixed and added more tests.
EDIT3:
I added another case for
void
, but it's rather questionable now 😬