mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-16 13:59:22 +00:00
add ClassCasts generator
This commit is contained in:
27
ksp/classcasts/generator/test/build.gradle
Normal file
27
ksp/classcasts/generator/test/build.gradle
Normal file
@@ -0,0 +1,27 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "com.android.library"
|
||||
id "com.google.devtools.ksp"
|
||||
}
|
||||
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api project(":micro_utils.ksp.classcasts")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
add("kspCommonMainMetadata", project(":micro_utils.ksp.classcasts.generator"))
|
||||
}
|
||||
|
||||
ksp {
|
||||
}
|
12
ksp/classcasts/generator/test/src/commonMain/kotlin/Test.kt
Normal file
12
ksp/classcasts/generator/test/src/commonMain/kotlin/Test.kt
Normal file
@@ -0,0 +1,12 @@
|
||||
package dev.inmo.micro_utils.ksp.classcasts.generator.test
|
||||
|
||||
import dev.inmo.micro_utils.ksp.classcasts.ClassCastsExcluded
|
||||
import dev.inmo.micro_utils.ksp.classcasts.ClassCastsIncluded
|
||||
|
||||
@ClassCastsIncluded
|
||||
sealed interface Test {
|
||||
object A : Test
|
||||
@ClassCastsExcluded
|
||||
object B : Test
|
||||
object C : Test
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
|
||||
// TO REGENERATE IT JUST DELETE FILE
|
||||
// ORIGINAL FILE: Test.kt
|
||||
@file:Suppress(
|
||||
"unused",
|
||||
"RemoveRedundantQualifierName",
|
||||
"RedundantVisibilityModifier",
|
||||
"NOTHING_TO_INLINE",
|
||||
"UNCHECKED_CAST",
|
||||
"OPT_IN_USAGE",
|
||||
)
|
||||
|
||||
package dev.inmo.micro_utils.ksp.classcasts.generator.test
|
||||
|
||||
import dev.inmo.micro_utils.ksp.classcasts.generator.test.Test
|
||||
import kotlin.Suppress
|
||||
|
||||
public inline fun Test.aOrNull(): Test.A? = this as?
|
||||
dev.inmo.micro_utils.ksp.classcasts.generator.test.Test.A
|
||||
|
||||
public inline fun Test.aOrThrow(): Test.A = this as
|
||||
dev.inmo.micro_utils.ksp.classcasts.generator.test.Test.A
|
||||
|
||||
public inline fun <T> Test.ifA(block: (Test.A) -> T): T? = aOrNull() ?.let(block)
|
||||
|
||||
public inline fun Test.cOrNull(): Test.C? = this as?
|
||||
dev.inmo.micro_utils.ksp.classcasts.generator.test.Test.C
|
||||
|
||||
public inline fun Test.cOrThrow(): Test.C = this as
|
||||
dev.inmo.micro_utils.ksp.classcasts.generator.test.Test.C
|
||||
|
||||
public inline fun <T> Test.ifC(block: (Test.C) -> T): T? = cOrNull() ?.let(block)
|
Reference in New Issue
Block a user