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

Avoid repeated calculations of default SwiftUI view name #227

Closed
wants to merge 1 commit into from

Conversation

square-tomb
Copy link

@square-tomb square-tomb commented Dec 13, 2023

Goal

Prior to this change, BugsnagTracedView reevaluates getViewName(content:) each time it is initialized without the viewName parameter.

After this change, the default view name is calculated only once for each specialization of the BugsnagTracedView generic type (and is still calculated lazily due to the lazy behavior of static let).

Testing

CI only.

@clr182 clr182 added the backlog We hope to fix this feature/bug in the future label Jan 4, 2024
@clr182
Copy link

clr182 commented Jan 4, 2024

Hi @square-tomb

Thank you for opening this PR with us. The change you have suggested seems reasonable and as I have added it to our backlog to review when priorities allow. We'll be sure to let you know of any updates.

@kstenerud
Copy link
Contributor

kstenerud commented Jan 17, 2024

Hi @square-tomb

Unfortunately, this won't work because static stored properties are not supported in generic types. This was a language policy decision by the Swift team in order to avoid requiring separate property storage per parametric type. There's a good explanation of the issue here: https://stackoverflow.com/questions/45467329/extension-may-not-contain-stored-property-but-why-is-static-allowed

If you try to run the unit tests, you should see the Xcode error pop up.

@square-tomb
Copy link
Author

Ah, thank you for pointing that out! I should have attempted to compile the entire type before opening this PR 🙈

@mclack mclack added wontfix This is not something we plan to implement and removed backlog We hope to fix this feature/bug in the future labels Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This is not something we plan to implement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants