-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
AutoBuilder will not build Kotlin data class with Duration #1579
Comments
We've encountered this internally. Googlers can see it at b/276527697. Here's what I wrote there. In the discussion, we have This is a tricky one. Presumably the main purpose of the builder is for Java clients, since Kotlin clients can just do data class Options(val duration: Duration) {
@AutoBuilder(callMethod = "make")
interface Builder {
fun setDuration(duration: java.time.Duration): Builder
fun build(): Options
}
companion object {
@JvmStatic fun make(duration: java.time.Duration) = Options(duration.toKotlinDuration())
}
} I also agree that we could have a better error message here. The message is technically true: there really is no visible constructor. But the underlying problem is with the inline parameter, and perhaps we could detect that and mention it in the error message. |
I like that workaround! It's an extra method, but mostly copy+paste. As for the error message: Yeah, that would have saved me some time... 😅 |
[AutoBuilderNoVisible] No visible constructor for REDACTED
Caused by: error: [AutoBuilderNoVisible] No visible constructor for REDACTED
|
I have a Kotlin data class with a nested
@AutoBuilder
.If I change one of my Kotlin data class constructor arguments from a
Long
to a KotlinDuration
, I get the follow error:Perhaps because
Duration
is aninline class
?The text was updated successfully, but these errors were encountered: