-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- No longer generated incorrect contracts on delegates and reifications - Also add deprecations to reified versions Remove some Suppression of INVISIBLE_REFERENCE
- Loading branch information
1 parent
225d359
commit 42f4fc6
Showing
29 changed files
with
357 additions
and
190 deletions.
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
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
...d/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/AnnotatableReified.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,7 @@ | ||
package dev.kord.codegen.kotlinpoet | ||
|
||
import com.squareup.kotlinpoet.Annotatable | ||
import com.squareup.kotlinpoet.asClassName | ||
|
||
public inline fun <T : Annotatable.Builder<T>, reified A> Annotatable.Builder<T>.addAnnotation(): T | ||
= addAnnotation(A::class.asClassName()) |
7 changes: 7 additions & 0 deletions
7
...ild/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ClassNameReified.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,7 @@ | ||
package dev.kord.codegen.kotlinpoet | ||
|
||
import com.squareup.kotlinpoet.ClassName | ||
import com.squareup.kotlinpoet.asClassName | ||
import kotlin.Int | ||
|
||
public inline fun <reified O> ClassName.compareTo(): Int = compareTo(O::class.asClassName()) |
21 changes: 21 additions & 0 deletions
21
...uild/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FileSpecReified.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,21 @@ | ||
package dev.kord.codegen.kotlinpoet | ||
|
||
import com.squareup.kotlinpoet.FileSpec | ||
import com.squareup.kotlinpoet.asClassName | ||
import kotlin.String | ||
import kotlin.collections.Iterable | ||
|
||
public inline fun <reified C> FileSpec.Builder.addImport(vararg names: String): FileSpec.Builder = | ||
addImport(C::class.asClassName(), names = names) | ||
|
||
public inline fun <reified C> FileSpec.Builder.addImport(names: Iterable<String>): FileSpec.Builder | ||
= addImport(C::class.asClassName(), names) | ||
|
||
public inline fun <reified C> FileSpec.Builder.addAliasedImport(`as`: String): FileSpec.Builder = | ||
addAliasedImport(C::class.asClassName(), `as`) | ||
|
||
public inline fun <reified C> FileSpec.Builder.addAliasedImport(memberName: String, `as`: String): | ||
FileSpec.Builder = addAliasedImport(C::class.asClassName(), memberName, `as`) | ||
|
||
public inline fun <reified A> FileSpec.Builder.addAnnotation(): FileSpec.Builder = | ||
addAnnotation(A::class.asClassName()) |
15 changes: 15 additions & 0 deletions
15
...build/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/FunSpecReified.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,15 @@ | ||
package dev.kord.codegen.kotlinpoet | ||
|
||
import com.squareup.kotlinpoet.CodeBlock | ||
import com.squareup.kotlinpoet.FunSpec | ||
import com.squareup.kotlinpoet.asClassName | ||
import com.squareup.kotlinpoet.typeNameOf | ||
|
||
public inline fun <reified R> FunSpec.Builder.`receiver`(kdoc: CodeBlock = emptyCodeBlock()): | ||
FunSpec.Builder = `receiver`(typeNameOf<R>(), kdoc) | ||
|
||
public inline fun <reified R> FunSpec.Builder.returns(kdoc: CodeBlock = emptyCodeBlock()): | ||
FunSpec.Builder = returns(typeNameOf<R>(), kdoc) | ||
|
||
public inline fun <reified A> FunSpec.Builder.addAnnotation(): FunSpec.Builder = | ||
addAnnotation(A::class.asClassName()) |
26 changes: 26 additions & 0 deletions
26
...enerated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/LambdaTypeNameReified.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,26 @@ | ||
package dev.kord.codegen.kotlinpoet | ||
|
||
import com.squareup.kotlinpoet.ExperimentalKotlinPoetApi | ||
import com.squareup.kotlinpoet.LambdaTypeName | ||
import com.squareup.kotlinpoet.ParameterSpec | ||
import com.squareup.kotlinpoet.TypeName | ||
import com.squareup.kotlinpoet.typeNameOf | ||
import kotlin.collections.List | ||
|
||
@ExperimentalKotlinPoetApi | ||
public inline fun <reified R, reified R_> | ||
LambdaTypeName.Companion.`get`(parameters: List<ParameterSpec> = emptyList(), | ||
contextReceivers: List<TypeName> = emptyList()): LambdaTypeName = `get`(typeNameOf<R>(), | ||
parameters, typeNameOf<R_>(), contextReceivers) | ||
|
||
public inline fun <reified R, reified R_> | ||
LambdaTypeName.Companion.`get`(parameters: List<ParameterSpec> = emptyList()): LambdaTypeName = | ||
`get`(typeNameOf<R>(), parameters, typeNameOf<R_>()) | ||
|
||
public inline fun <reified R, reified R_> LambdaTypeName.Companion.`get`(vararg parameters: TypeName | ||
= emptyArray()): LambdaTypeName = `get`(typeNameOf<R>(), parameters = parameters, | ||
typeNameOf<R_>()) | ||
|
||
public inline fun <reified R, reified R_> LambdaTypeName.Companion.`get`(vararg | ||
parameters: ParameterSpec = emptyArray()): LambdaTypeName = `get`(typeNameOf<R>(), | ||
parameters = parameters, typeNameOf<R_>()) |
15 changes: 15 additions & 0 deletions
15
...generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ParameterSpecReified.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,15 @@ | ||
package dev.kord.codegen.kotlinpoet | ||
|
||
import com.squareup.kotlinpoet.ParameterSpec | ||
import com.squareup.kotlinpoet.asClassName | ||
import com.squareup.kotlinpoet.typeNameOf | ||
import kotlin.String | ||
|
||
public inline fun <reified T> ParameterSpec.toBuilder(name: String = this.name): | ||
ParameterSpec.Builder = toBuilder(name, typeNameOf<T>()) | ||
|
||
public inline fun <reified A> ParameterSpec.Builder.addAnnotation(): ParameterSpec.Builder = | ||
addAnnotation(A::class.asClassName()) | ||
|
||
public inline fun <reified T> ParameterSpec.Companion.unnamed(): ParameterSpec = | ||
unnamed(typeNameOf<T>()) |
7 changes: 7 additions & 0 deletions
7
...d/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/ParameterizedTypeNameReified.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,7 @@ | ||
package dev.kord.codegen.kotlinpoet | ||
|
||
import com.squareup.kotlinpoet.ParameterizedTypeName | ||
import com.squareup.kotlinpoet.typeNameOf | ||
|
||
public inline fun <reified T> ParameterizedTypeName.plusParameter(): ParameterizedTypeName = | ||
plusParameter(typeNameOf<T>()) |
15 changes: 15 additions & 0 deletions
15
.../generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/PropertySpecReified.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,15 @@ | ||
package dev.kord.codegen.kotlinpoet | ||
|
||
import com.squareup.kotlinpoet.PropertySpec | ||
import com.squareup.kotlinpoet.asClassName | ||
import com.squareup.kotlinpoet.typeNameOf | ||
import kotlin.String | ||
|
||
public inline fun <reified T> PropertySpec.toBuilder(name: String = this.name): PropertySpec.Builder | ||
= toBuilder(name, typeNameOf<T>()) | ||
|
||
public inline fun <reified R> PropertySpec.Builder.`receiver`(): PropertySpec.Builder = | ||
`receiver`(typeNameOf<R>()) | ||
|
||
public inline fun <reified A> PropertySpec.Builder.addAnnotation(): PropertySpec.Builder = | ||
addAnnotation(A::class.asClassName()) |
12 changes: 12 additions & 0 deletions
12
...generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeAliasSpecReified.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,12 @@ | ||
package dev.kord.codegen.kotlinpoet | ||
|
||
import com.squareup.kotlinpoet.TypeAliasSpec | ||
import com.squareup.kotlinpoet.asClassName | ||
import com.squareup.kotlinpoet.typeNameOf | ||
import kotlin.String | ||
|
||
public inline fun <reified T> TypeAliasSpec.toBuilder(name: String = this.name): | ||
TypeAliasSpec.Builder = toBuilder(name, typeNameOf<T>()) | ||
|
||
public inline fun <reified A> TypeAliasSpec.Builder.addAnnotation(): TypeAliasSpec.Builder = | ||
addAnnotation(A::class.asClassName()) |
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
51 changes: 51 additions & 0 deletions
51
...uild/generated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/TypeSpecReified.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,51 @@ | ||
package dev.kord.codegen.kotlinpoet | ||
|
||
import com.squareup.kotlinpoet.CodeBlock | ||
import com.squareup.kotlinpoet.TypeSpec | ||
import com.squareup.kotlinpoet.asClassName | ||
import com.squareup.kotlinpoet.typeNameOf | ||
import kotlin.Deprecated | ||
import kotlin.DeprecationLevel | ||
import kotlin.ReplaceWith | ||
import kotlin.String | ||
import kotlin.Suppress | ||
|
||
public inline fun <reified S> TypeSpec.Builder.superclass(): TypeSpec.Builder = | ||
superclass(typeNameOf<S>()) | ||
|
||
public inline fun <reified S> TypeSpec.Builder.addSuperinterface(`delegate`: CodeBlock = | ||
emptyCodeBlock()): TypeSpec.Builder = addSuperinterface(typeNameOf<S>(), `delegate`) | ||
|
||
public inline fun <reified S> TypeSpec.Builder.addSuperinterface(constructorParameter: String): | ||
TypeSpec.Builder = addSuperinterface(typeNameOf<S>(), constructorParameter) | ||
|
||
public inline fun <reified A> TypeSpec.Builder.addAnnotation(): TypeSpec.Builder = | ||
addAnnotation(A::class.asClassName()) | ||
|
||
public inline fun <reified C> TypeSpec.Companion.classBuilder(): TypeSpec.Builder = | ||
classBuilder(C::class.asClassName()) | ||
|
||
@Deprecated( | ||
message = "Use classBuilder() instead. This function will be removed in KotlinPoet 2.0.", | ||
replaceWith = ReplaceWith(imports = arrayOf(), expression = | ||
"TypeSpec.classBuilder(className).addModifiers(KModifier.EXPECT)"), | ||
level = DeprecationLevel.WARNING, | ||
) | ||
@Suppress(names = arrayOf("DEPRECATION")) | ||
public inline fun <reified C> TypeSpec.Companion.expectClassBuilder(): TypeSpec.Builder = | ||
expectClassBuilder(C::class.asClassName()) | ||
|
||
public inline fun <reified C> TypeSpec.Companion.objectBuilder(): TypeSpec.Builder = | ||
objectBuilder(C::class.asClassName()) | ||
|
||
public inline fun <reified C> TypeSpec.Companion.interfaceBuilder(): TypeSpec.Builder = | ||
interfaceBuilder(C::class.asClassName()) | ||
|
||
public inline fun <reified C> TypeSpec.Companion.funInterfaceBuilder(): TypeSpec.Builder = | ||
funInterfaceBuilder(C::class.asClassName()) | ||
|
||
public inline fun <reified C> TypeSpec.Companion.enumBuilder(): TypeSpec.Builder = | ||
enumBuilder(C::class.asClassName()) | ||
|
||
public inline fun <reified C> TypeSpec.Companion.annotationBuilder(): TypeSpec.Builder = | ||
annotationBuilder(C::class.asClassName()) |
10 changes: 10 additions & 0 deletions
10
...erated/ksp/generationSource/kotlin/dev/kord/codegen/kotlinpoet/WildcardTypeNameReified.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,10 @@ | ||
package dev.kord.codegen.kotlinpoet | ||
|
||
import com.squareup.kotlinpoet.WildcardTypeName | ||
import com.squareup.kotlinpoet.typeNameOf | ||
|
||
public inline fun <reified O> WildcardTypeName.Companion.producerOf(): WildcardTypeName = | ||
producerOf(typeNameOf<O>()) | ||
|
||
public inline fun <reified I> WildcardTypeName.Companion.consumerOf(): WildcardTypeName = | ||
consumerOf(typeNameOf<I>()) |
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
Oops, something went wrong.