fixes for generics

This commit is contained in:
2025-02-12 14:32:14 +06:00
parent 99783f281d
commit 5c28255e06
9 changed files with 122 additions and 120 deletions

View File

@@ -12,6 +12,7 @@ kotlin {
sourceSets {
commonMain {
dependencies {
implementation libs.kt.stdlib
api project(":micro_utils.ksp.variations")
}
}

View File

@@ -1,32 +1,51 @@
package dev.inmo.micro_utils.ksp.variations.generator.test
import dev.inmo.micro_utils.ksp.variations.GenerateVariations
import dev.inmo.micro_utils.ksp.variations.GenerationVariant
data class Sample(
data class SimpleType(
val value: String
)
data class GenericType<T>(
val value: T
)
@GenerateVariations
fun sample(
@GenerationVariant(
"example",
"Sample",
"value"
SimpleType::class,
"value",
)
@GenerationVariant(
GenericType::class,
"value.toString()",
genericTypes = arrayOf(Int::class)
)
example: String = "12"
) = println(example)
@GenerateVariations
suspend fun Sample.sample2(
fun sampleVararg(
@GenerationVariant(
SimpleType::class,
"value",
)
vararg example: String = arrayOf("12")
) = println(example.joinToString())
@GenerateVariations
suspend fun SimpleType.sample2(
@GenerationVariant(
Int::class,
"toString()",
"arg12",
"kotlin.Int",
"toString()"
)
arg1: String = "1",
@GenerationVariant(
String::class,
"toInt()",
"arg22",
"kotlin.String",
"toInt()"
)
arg2: Int = 2,
arg3: Boolean = false

View File

@@ -1,47 +1,49 @@
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
// TO REGENERATE IT JUST DELETE FILE
// ORIGINAL FILE: SampleFun.kt
package dev.inmo.micro_utils.ksp.variations.generator.test
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Unit
public suspend fun Sample.sample2(arg12: Int): Unit = sample2(
arg1 = arg12.toString()
public suspend fun SimpleType.sample2(arg12: Int): Unit = sample2(
arg1 = with(arg12) {toString()}
)
public suspend fun Sample.sample2(arg12: Int, arg2: Int): Unit = sample2(
arg1 = arg12.toString(), arg2 = arg2
public suspend fun SimpleType.sample2(arg12: Int, arg2: Int): Unit = sample2(
arg1 = with(arg12) {toString()}, arg2 = arg2
)
public suspend fun Sample.sample2(arg12: Int, arg3: Boolean): Unit = sample2(
arg1 = arg12.toString(), arg3 = arg3
public suspend fun SimpleType.sample2(arg12: Int, arg3: Boolean): Unit = sample2(
arg1 = with(arg12) {toString()}, arg3 = arg3
)
public suspend fun Sample.sample2(
public suspend fun SimpleType.sample2(
arg12: Int,
arg2: Int,
arg3: Boolean,
): Unit = sample2(
arg1 = arg12.toString(), arg2 = arg2, arg3 = arg3
arg1 = with(arg12) {toString()}, arg2 = arg2, arg3 = arg3
)
public suspend fun Sample.sample2(arg22: String): Unit = sample2(
arg2 = arg22.toInt()
public suspend fun SimpleType.sample2(arg22: String): Unit = sample2(
arg2 = with(arg22) {toInt()}
)
public suspend fun Sample.sample2(arg1: String, arg22: String): Unit = sample2(
arg1 = arg1, arg2 = arg22.toInt()
public suspend fun SimpleType.sample2(arg1: String, arg22: String): Unit = sample2(
arg1 = arg1, arg2 = with(arg22) {toInt()}
)
public suspend fun Sample.sample2(arg22: String, arg3: Boolean): Unit = sample2(
arg2 = arg22.toInt(), arg3 = arg3
public suspend fun SimpleType.sample2(arg22: String, arg3: Boolean): Unit = sample2(
arg2 = with(arg22) {toInt()}, arg3 = arg3
)
public suspend fun Sample.sample2(
public suspend fun SimpleType.sample2(
arg1: String,
arg22: String,
arg3: Boolean,
): Unit = sample2(
arg1 = arg1, arg2 = arg22.toInt(), arg3 = arg3
arg1 = arg1, arg2 = with(arg22) {toInt()}, arg3 = arg3
)

View File

@@ -1,8 +1,15 @@
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
// TO REGENERATE IT JUST DELETE FILE
// ORIGINAL FILE: SampleFun.kt
package dev.inmo.micro_utils.ksp.variations.generator.test
import kotlin.Int
import kotlin.Unit
public fun sample(example: Sample): Unit = sample(
example = example.value
public fun sample(example: SimpleType): Unit = sample(
example = with(example) {value}
)
public fun sample(example: GenericType<Int>): Unit = sample(
example = with(example) {value.toString()}
)

View File

@@ -0,0 +1,10 @@
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
// TO REGENERATE IT JUST DELETE FILE
// ORIGINAL FILE: SampleFun.kt
package dev.inmo.micro_utils.ksp.variations.generator.test
import kotlin.Unit
public fun sampleVararg(vararg example: SimpleType): Unit = sampleVararg(
example = with(example) {map { it.value }.toTypedArray()}
)