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
Support direct annotation instantiation in code gen on Kotlin 1.6 #1390
Conversation
The failure is interesting. Basically, the
|
It's a bug on their side with |
886506a
to
a7eb500
Compare
a7eb500
to
e1fca34
Compare
e1fca34
to
c7335ec
Compare
Still broken in 1.6.0-M1, pushed to 1.6.0-RC now -_- |
Small update after talking with @swankjesse
Will wait for #1393 to merge in and Kotlin 1.6-RC (which should have this implemented) |
b5a6ae2
to
54c0f73
Compare
Got an interesting problem here. In short, we reuse AnnotationSpec instances for qualifiers. Since we’re directly instantiating them now, we can just reuse them and join their members as the constructor args. However, internally in kotlinpoet it uses collection literal So there’s three options I can think of: I think we should go with option A. Doesn’t read as nicely but it’s definitely in the spirit of portability like other changes have been (explicit public modifiers, imports from kotlin.*, etc). lmk what you think |
I agree, |
This allows these annotation specs' members to be more portable regardless of whether it's used as an annotation or constructor called. See square/moshi#1390 (comment) for more details
This allows these annotation specs' members to be more portable regardless of whether it's used as an annotation or constructor called. See square/moshi#1390 (comment) for more details
@@ -125,8 +130,8 @@ subprojects { | |||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { | |||
tasks.withType<KotlinCompile>().configureEach { | |||
kotlinOptions { | |||
@Suppress("SuspiciousCollectionReassignment") | |||
freeCompilerArgs += listOf("-progressive") | |||
// @Suppress("SuspiciousCollectionReassignment") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete if not needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, will remove before merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually going to leave it but with a comment explaining it's just temporary while we support dual kotlin versions
After talking with @Egorand, plan is option A. It's already merged in KotlinPoet and I'll update this after that release is out |
woo! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Resolves #1382. This also implements it gated on the target type's language version, which allows this to seamlessly work in a backward-compatible way.
Generated adapter now looks like this