A Kotlin compiler plugin for transforming suspend functions to platform-compatible non-suspend functions, such as the JVM Blocking API and CompletableFuture or JS Promise, etc. 🐱
MIT License
36
stars
3
forks
source link
Support for configuring `includeProperty` in the IncludeAnnotation #54
class Foo {
@JvmBlocking(asProperty = true)
suspend value(): Int = 1
}
the compiled:
class Foo {
@JvmSynthetic
suspend value(): Int = 1
val valueBlocking: Int
@Api4J // Problem: RequiresOptIn doesn't work on getters.
get() = runInBlocking { value() }
}
After
build:
useJvmDefault()
// or
addJvmTransformer(
Transformer(
...,
syntheticFunctionIncludeAnnotations = listOf(
IncludeAnnotation(jvmApi4JAnnotationClassInfo).apply {
includeProperty = true
// 👆 support for including to the property
}
)
)
)
Then the source:
class Foo {
@JvmBlocking(asProperty = true)
suspend value(): Int = 1
}
the compiled:
class Foo {
@JvmSynthetic
suspend value(): Int = 1
@Api4J // Included to this property
val valueBlocking: Int
@Api4J
get() = runInBlocking { value() }
}
Before
build:
Then the source:
the compiled:
After
build:
Then the source:
the compiled: