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

[feature request] Retrieve property default value for compile time constants #1868

Open
Chuckame opened this issue May 3, 2024 · 3 comments
Labels
feature request Feature request for discussion P3 desirable

Comments

@Chuckame
Copy link

Chuckame commented May 3, 2024

Currently, it's not possible to retrieve the default value as it is expensive to compute (#642).

This feature request is not about extracting all the default values, but just the compile time constants, that would cover the same values as annotations. It would help a lot for static analysis, for schema generation by example.

Example:

data class MyClass(
   val staticString: String = "static string", // would extract 'static string'
   val staticInt: Int = 42, // would extract '42'
   val fieldDependentDefault: String = staticString, // would extract 'static string' as it is the static default of staticString field
   val dynamicDefault: String = UUID.random().toString(), // would extract nothing (or a DYNAMIC placeholder) as it is not constant
)

EDIT: fixed a typo on dynamicDefault example

@neetopia
Copy link
Contributor

This is fair, we will revisit this once KSP2 is stable.

@Chuckame
Copy link
Author

Chuckame commented Jun 2, 2024

Great news! Do you have a planned date for ksp2 to be stable?

@nsk90
Copy link

nsk90 commented Jul 8, 2024

I would also be glad to see this feature in future releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request for discussion P3 desirable
Projects
None yet
Development

No branches or pull requests

4 participants
@neetopia @Chuckame @nsk90 and others