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

NavArgsDelegate fails KSP due to false positive when property code comments include parentheses #567

Closed
ryanholden8 opened this issue Jan 23, 2024 · 3 comments
Labels
feedback needed Extra attention is needed

Comments

@ryanholden8
Copy link

ryanholden8 commented Jan 23, 2024

This code works:

data class MyNavArgs(
    /** This is an awesome property. */
    val myProperty: Boolean = false
)

@WmsDestination(navArgsDelegate = MyNavArgs::class)
@Composable
fun MyScreen(navigator: DestinationsNavigator, navArgs: MyNavArgs) {}

This code results in IllegalDestinationsSetup: Navigation arguments using function calls with parameters as their default value... -

throw IllegalDestinationsSetup("Navigation arguments using function calls with parameters as their default value " +


data class MyNavArgs(
    /** This is an awesome (usually) property. */
    val myProperty: Boolean = false
)

@WmsDestination(navArgsDelegate = MyNavArgs::class)
@Composable
fun MyScreen(navigator: DestinationsNavigator, navArgs: MyNavArgs) {}

Took me a quite to figure out because the error message did not seem related to the default property at all.

Thanks for the awesome library! I removed the parentheses for now but wanted to provide an FYI for any that run across this issue.

@raamcosta
Copy link
Owner

Thanks!

Yes in this manual parsing of the default value there are limitless possibilities and there will always be some case it doesn’t support well.
Of course I will fix it everytime something unexpected is found, such as this one. I’m also adding new cases to unit tests so that there’s no regression as I fix more and more of these.

@raamcosta
Copy link
Owner

@ryanholden8 Can you tell me which version are you using? I cannot reproduce it with the exact nav args class you used in the example. I was able to reproduce it if I put the comment in the line after the parameter though.

I just want to make sure that it is the same issue you have.

@raamcosta
Copy link
Owner

raamcosta commented Jan 26, 2024

Please try 1.9.63 (or 1.10.0 for compose 1.6) and let me know if it fixes it for you!

@raamcosta raamcosta added the feedback needed Extra attention is needed label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback needed Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants