Skip to content
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

Setting a class final prevents using functions or compute properties #25

Open
mbarnach opened this issue Oct 20, 2021 · 1 comment
Open

Comments

@mbarnach
Copy link

When a class is set final, the compute properties or the functions are not working anymore.
This can be tested with any samples of the README.
If the behaviour is expected, maybe adding this to the README could help troubleshooting the issue.

@nerdsupremacist
Copy link
Owner

This behavior is known but undocumented. the reason behind it is that we read the symbols on the vtable to get a list of methods and their signatures. Vtables are there to dispatch method calls to the right implementation of the actual class. If a class is final, Swift will optimize to us static method dispatching and won't create the table at all. Methods in extensions are also omitted for the same reason, since you can't override them. I believe a method will also be omitted if the method is final.

This definitely needs to be documented, thanks for raising this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants