Skip to content

Add imports for default values #1407

Closed Answered by Egorand
St4B asked this question in Q&A
Nov 4, 2022 · 1 comments · 6 replies
Discussion options

You must be logged in to vote

Imports are automatically added for types (as described in %T for Types). In your case, "ZonedDateTime" and "ZoneId" are simply parts of an expression, KotlinPoet has no way of knowing that those are actually types. Use the %T modifier to resolve this:

defaultValue("%T.of(1989,1,23,0,0,0,0, %T.of(\"UTC\"))", ZonedDateTime::class, ZoneId::class)

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@Egorand
Comment options

@St4B
Comment options

@JakeWharton
Comment options

@St4B
Comment options

@Egorand
Comment options

Answer selected by St4B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1406 on November 04, 2022 09:03.