-
Notifications
You must be signed in to change notification settings - Fork 294
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
Migrate OriginatingElementsHolder and Taggable from JVM to common #2040
Open
ForteScarlet
wants to merge
4
commits into
square:main
Choose a base branch
from
ForteScarlet:migrate_OriginatingElementsHolder
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+334
−72
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c3d69db
Migrate OriginatingElementsHolder from JVM to common
ForteScarlet 1cf0fa5
Migrate Taggable from JVM to common
ForteScarlet 2e79139
Optimise comments and typography.
ForteScarlet 47baf7b
Rename JvmTypeAliasKotlinPoetApi to JvmOnlyKotlinPoetApi
ForteScarlet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/Taggable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (C) 2019 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.squareup.kotlinpoet | ||
|
||
import com.squareup.kotlinpoet.jvm.alias.JvmClass | ||
import com.squareup.kotlinpoet.jvm.alias.JvmDefaultWithCompatibility | ||
import com.squareup.kotlinpoet.jvm.alias.kotlin | ||
import kotlin.jvm.JvmInline | ||
import kotlin.reflect.KClass | ||
|
||
/** A type that can be tagged with extra metadata of the user's choice. */ | ||
@JvmDefaultWithCompatibility | ||
public interface Taggable { | ||
|
||
/** Returns all tags. */ | ||
public val tags: Map<KClass<*>, Any> get() = emptyMap() | ||
|
||
/** Returns the tag attached with [type] as a key, or null if no tag is attached with that key. */ | ||
public fun <T : Any> tag(type: JvmClass<T>): T? = tag(type.kotlin) | ||
|
||
/** Returns the tag attached with [type] as a key, or null if no tag is attached with that key. */ | ||
public fun <T : Any> tag(type: KClass<T>): T? { | ||
@Suppress("UNCHECKED_CAST") | ||
return tags[type] as T? | ||
} | ||
|
||
/** The builder analogue to [Taggable] types. */ | ||
@JvmDefaultWithCompatibility | ||
public interface Builder<out T : Builder<T>> { | ||
|
||
/** Mutable map of the current tags this builder contains. */ | ||
public val tags: MutableMap<KClass<*>, Any> | ||
|
||
/** | ||
* Attaches [tag] to the request using [type] as a key. Tags can be read from a | ||
* request using [Taggable.tag]. Use `null` to remove any existing tag assigned for | ||
* [type]. | ||
* | ||
* Use this API to attach originating elements, debugging, or other application data to a spec | ||
* so that you may read it in other APIs or callbacks. | ||
*/ | ||
public fun tag(type: JvmClass<*>, tag: Any?): T = tag(type.kotlin, tag) | ||
|
||
/** | ||
* Attaches [tag] to the request using [type] as a key. Tags can be read from a | ||
* request using [Taggable.tag]. Use `null` to remove any existing tag assigned for | ||
* [type]. | ||
* | ||
* Use this API to attach originating elements, debugging, or other application data to a spec | ||
* so that you may read it in other APIs or callbacks. | ||
*/ | ||
@Suppress("UNCHECKED_CAST") | ||
public fun tag(type: KClass<*>, tag: Any?): T = apply { | ||
if (tag == null) { | ||
this.tags.remove(type) | ||
} else { | ||
this.tags[type] = tag | ||
} | ||
} as T | ||
} | ||
} | ||
|
||
/** Returns the tag attached with [T] as a key, or null if no tag is attached with that key. */ | ||
public inline fun <reified T : Any> Taggable.tag(): T? = tag(T::class) | ||
|
||
internal fun Taggable.Builder<*>.buildTagMap(): TagMap = TagMap(tags) | ||
|
||
@JvmInline | ||
internal value class TagMap private constructor(override val tags: Map<KClass<*>, Any>) : Taggable { | ||
companion object { | ||
operator fun invoke(tags: Map<KClass<*>, Any>): TagMap = TagMap(tags.toImmutableMap()) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmClass.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (C) 2024 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.squareup.kotlinpoet.jvm.alias | ||
|
||
import kotlin.reflect.KClass | ||
|
||
/** | ||
* An expected typealias for `java.lang.Class`. | ||
*/ | ||
public expect class JvmClass<T : Any> | ||
|
||
internal expect val <T : Any> JvmClass<T>.kotlin: KClass<T> |
23 changes: 23 additions & 0 deletions
23
...et/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmDefaultWithCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (C) 2024 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.squareup.kotlinpoet.jvm.alias | ||
|
||
/** | ||
* A typealias annotation for `kotlin.jvm.JvmDefaultWithCompatibility`. | ||
*/ | ||
@OptIn(ExperimentalMultiplatform::class) | ||
@OptionalExpectation | ||
public expect annotation class JvmDefaultWithCompatibility() |
36 changes: 36 additions & 0 deletions
36
kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmElement.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (C) 2024 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.squareup.kotlinpoet.jvm.alias | ||
|
||
/** | ||
* An expected typealias for `javax.lang.model.element.Element`. | ||
*/ | ||
public expect interface JvmElement | ||
|
||
/** | ||
* An expected typealias for `javax.lang.model.element.TypeElement`. | ||
*/ | ||
public expect interface JvmTypeElement : JvmElement | ||
|
||
/** | ||
* An expected typealias for `javax.lang.model.element.ExecutableElement`. | ||
*/ | ||
public expect interface JvmExecutableElement : JvmElement | ||
|
||
/** | ||
* An expected typealias for `javax.lang.model.element.VariableElement`. | ||
*/ | ||
public expect interface JvmVariableElement : JvmElement |
29 changes: 29 additions & 0 deletions
29
kotlinpoet/src/commonMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmOnlyKotlinPoetApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (C) 2024 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.squareup.kotlinpoet.jvm.alias | ||
|
||
/** | ||
* An expected type for JVM to `typealias` only. | ||
*/ | ||
@MustBeDocumented | ||
@Retention(AnnotationRetention.BINARY) | ||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS) | ||
@RequiresOptIn( | ||
level = RequiresOptIn.Level.ERROR, | ||
message = "An expected type for JVM to `typealias` only." + | ||
" Don't implement or use it in non-JVM platforms.", | ||
) | ||
public annotation class JvmOnlyKotlinPoetApi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmClass.jvm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2024 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.squareup.kotlinpoet.jvm.alias | ||
|
||
import kotlin.jvm.kotlin as jvmKotlin | ||
import kotlin.reflect.KClass | ||
|
||
public actual typealias JvmClass<T> = Class<T> | ||
|
||
internal actual val <T : Any> JvmClass<T>.kotlin: KClass<T> | ||
get() = jvmKotlin |
18 changes: 18 additions & 0 deletions
18
...t/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmDefaultWithCompatibility.jvm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (C) 2024 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.squareup.kotlinpoet.jvm.alias | ||
|
||
public actual typealias JvmDefaultWithCompatibility = kotlin.jvm.JvmDefaultWithCompatibility |
29 changes: 29 additions & 0 deletions
29
kotlinpoet/src/jvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmElement.jvm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (C) 2024 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.squareup.kotlinpoet.jvm.alias | ||
|
||
import javax.lang.model.element.Element | ||
import javax.lang.model.element.ExecutableElement | ||
import javax.lang.model.element.TypeElement | ||
import javax.lang.model.element.VariableElement | ||
|
||
public actual typealias JvmElement = Element | ||
|
||
public actual typealias JvmTypeElement = TypeElement | ||
|
||
public actual typealias JvmExecutableElement = ExecutableElement | ||
|
||
public actual typealias JvmVariableElement = VariableElement |
25 changes: 25 additions & 0 deletions
25
kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmClass.nonJvm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (C) 2024 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.squareup.kotlinpoet.jvm.alias | ||
|
||
import kotlin.reflect.KClass | ||
|
||
@JvmOnlyKotlinPoetApi | ||
public actual class JvmClass<T : Any> private constructor() | ||
|
||
@JvmOnlyKotlinPoetApi | ||
internal actual val <T : Any> JvmClass<T>.kotlin: KClass<T> | ||
get() = throw UnsupportedOperationException() |
28 changes: 28 additions & 0 deletions
28
kotlinpoet/src/nonJvmMain/kotlin/com/squareup/kotlinpoet/jvm/alias/JvmElement.nonJvm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (C) 2024 Square, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.squareup.kotlinpoet.jvm.alias | ||
|
||
@JvmOnlyKotlinPoetApi | ||
public actual interface JvmElement | ||
|
||
@JvmOnlyKotlinPoetApi | ||
public actual interface JvmTypeElement : JvmElement | ||
|
||
@JvmOnlyKotlinPoetApi | ||
public actual interface JvmExecutableElement : JvmElement | ||
|
||
@JvmOnlyKotlinPoetApi | ||
public actual interface JvmVariableElement : JvmElement |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is an JVM-only API. I don't see a reason to move it.
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.
It is implemented by many other types, e.g.
FunSpec
,TypeSpec
,PropertySpec
. I think even though it's JVM-only, it still needs to be in the commonThere 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.
The expect/actual mechanism allows actuals on the JVM to implement interfaces not exposed by the expect.
Here's an example in Okio:
We should not expose JVM-only APIs in common. The need to create a ton of dummy typealiases to JVM types is a good indicator for an API that should not be in common.
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.
In the case of
FunSpec
, for example, if you want to use the expect/actual mechanism to makeFunSpec
in the JVM implementOriginatingElementsHolder
in a way that other platforms don't, thenFunSpec
itself must be expect/actual (unless the extra in the interface is not abstract).This can create a lot of duplicate logic or generate a lot of extra work. That's what I use typealias for: to reduce the amount of work due to compatibility.
If we don't accept any JVM-only typealias exposed in common, then almost all major types will become expect/actual, even though their logic doesn't really differ.
This is the same problem you mentioned in #304 (comment), and I'm trying to get around it with typealias.
Exposing JVM-only types in common I think is a compromise for compatibility and maybe acceptable? 🤔 If it's unacceptable, that's fine too, except that later migrations to those major types will become more difficult.
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.
Would that require expect/actuals of
FunSpec
and co?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.
If an interface is expect/actual and there is an extra abstract method in the JVM, then
FunSpec
must also be expect/actual. Otherwise, in common it can't know about that extra part of the JVM and thus can't implement it.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.
The primary reason this work hasn't been done is because of this problem. I don't love the idea of exposing a large, JVM-based API surface that is effectively useless to other platforms.
I would rather we either wait for the language to evolve, or explore alternative ways of simplifying the duplication which comes from doing it properly today. For example, we could pull out sealed abstract base classes which contain the common code of each type, and then
expect
/actual
a mostly-empty subtype which then would allow retaining platform-specific API surfaces.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.
This is indeed tricky. Even more painful is the fact that KT-20427 has made little visible progress to date. 😭
(Come on, Jetbrains! ✊)
But it seems that most of the forced ‘compatibility’ is related to
DelicateKotlinPoetApi
orjavax.lang.model
. Do they have an obvious role in the Kotlin API? Or do they need to be kept? If they are not planned to be retained in the future (3.0, for example), then some of the current interim measures might be acceptable? Personal opinion.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.
K2 blocked all significant language features for nearly three years. They're only starting to catch up to addressing things, but I still wouldn't hold my breath for that feature for a while.
Delicate APIs are still stable APIs–we can't break them. The usage of Java mirrors and elements are tied to annotation processors which generate Kotlin. While kapt is set to be deprecated, we need to retain those APIs for existing tools.
We could attempt to pursue a 3.x by developing a multiplatform variant of KotlinPoet in common from scratch in the
app.cash.kotlinpoet
package. We would develop this over time, allowing people to try it out in the 2.x releases since it would sit as a sibling. Then, when we're happy, we would delete thecom.squareup.kotlinpoet
API in its entirety, change the Maven groupId, and release 3.0. This would ensure that 2.x users never see a breakage, while allowing 3.x to be iterated on and tested.It would allow fixing design mistakes both in regard to how the JVM-specific APIs are integrated, but also the pervasive use of builders instead of something more appropriate to Kotlin such as fully mutable types that get captured into immutable specs, with helpers for things like moving the mutable types into the receiver position of a function.
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.
Sounds like a good programme!🤩 Please feel free to let me know if there is anything I can do to help!