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

Add support for Kotlin inline value classes #182

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

jonduran3000
Copy link
Contributor

There are instances where we are using a type alias in Kotlin when we should be using an inline value class. This pull request adds a Kotlin-specific typeshare decorator for generating these inline value classes. Additionally, updated the redacted_to_string decorator to Redacted so there is a consistent naming convention for the language-specific decorators.

writeln!(w, "@JvmInline")?;
writeln!(w, "value class {}{}(", self.prefix, ty.id.renamed)?;

self.write_element(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this block equivalent to a similar block in the write_struct code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main difference between this and the one in write_struct is that structs are being translated into data classes (or an object if it contains no data) and this is specifically a value class.

@Lucretiel
Copy link
Contributor

Wondering if the redacted string code can be deduplicated; otherwise this looks great to me

@@ -15,7 +15,7 @@ pub struct BestHockeyTeams2 {
Lies: String,
}

#[typeshare(kotlin = "redacted_to_string")]
#[typeshare(kotlin = "Redacted")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the other languages can also have redacted output. It may be better for this to be parsed as #[typeshare(redacted)] allowing each language formatter to choose how the redacted type should be implemented.

@darrell-roberts
Copy link
Member

LGTM

@angelicaliley angelicaliley merged commit 0c1ae05 into 1Password:main Jul 22, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

None yet

4 participants