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

feat: allow empty data classes in kotlin schema #582

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

worstell
Copy link
Contributor

Empty data classes can be defined in Kotlin as typealias <ClassName> = Unit

@worstell worstell force-pushed the worstell/20231109-allow-empty-data-classes-kotlin branch from 6a502ce to faef61e Compare November 10, 2023 01:07
Empty data classes can be defined in Kotlin as `typealias <ClassName> = Unit`
@worstell worstell force-pushed the worstell/20231109-allow-empty-data-classes-kotlin branch from faef61e to c7974aa Compare November 10, 2023 01:08

// `typealias <name> = Unit` can be used in Kotlin to declare an empty FTL data type.
// This is a workaround to support empty objects in the FTL schema despite being unsupported by Kotlin data classes.
private fun KotlinType.isEmptyClassTypeAlias(): Boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Magic!

@worstell worstell merged commit 5f74abb into main Nov 10, 2023
9 checks passed
@worstell worstell deleted the worstell/20231109-allow-empty-data-classes-kotlin branch November 10, 2023 01:21
alecthomas added a commit that referenced this pull request Nov 10, 2023
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.

2 participants