mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-16 13:59:22 +00:00
improve classcasts
This commit is contained in:
@@ -3,10 +3,13 @@ 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
|
||||
@ClassCastsIncluded(levelsToInclude = 1)
|
||||
sealed interface Test {
|
||||
object A : Test
|
||||
@ClassCastsExcluded
|
||||
object B : Test
|
||||
object B : Test // Will not be included in class casts due to annotation ClassCastsExcluded
|
||||
object C : Test
|
||||
interface D : Test {
|
||||
object DD : D // Will not be included in class casts due to levelsToInclude
|
||||
}
|
||||
}
|
||||
|
@@ -30,3 +30,11 @@ 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)
|
||||
|
||||
public inline fun Test.dOrNull(): Test.D? = this as?
|
||||
dev.inmo.micro_utils.ksp.classcasts.generator.test.Test.D
|
||||
|
||||
public inline fun Test.dOrThrow(): Test.D = this as
|
||||
dev.inmo.micro_utils.ksp.classcasts.generator.test.Test.D
|
||||
|
||||
public inline fun <T> Test.ifD(block: (Test.D) -> T): T? = dOrNull() ?.let(block)
|
||||
|
Reference in New Issue
Block a user