-
Notifications
You must be signed in to change notification settings - Fork 4
Description
there seems to be an issue with custom transformers where it won't detect the transformer function if the custom annotation is used in common code
if used in js code then it does detect it
build.gradle
suspendTransformPlugin {
transformers {
includeAnnotation = false
includeRuntime = false
addJs {
markAnnotation {
classInfo {
packageName = "com.annotations"
className = "JsPromiseResult"
}
defaultSuffix = "Async"
defaultAsProperty = false
}
transformFunctionInfo {
packageName = "com.annotations"
functionName = "toAsync"
}
transformReturnType {
packageName = "kotlin.js"
className = "Promise"
}
transformReturnTypeGeneric = true
copyAnnotationsToSyntheticFunction = false
}
}
}
JsPromiseResult common
package com.annotations
@OptIn(ExperimentalMultiplatform::class)
@OptionalExpectation
expect annotation class JsPromiseResult()
JsPromiseResult js
package com.annotations
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.promise
import kotlin.js.Promise
actual annotation class JsPromiseResult(
val baseName: String = "",
val suffix: String = "Async",
val asProperty: Boolean = false,
)
private val coroutineScope = CoroutineScope(CoroutineName("JsPromiseResult"))
fun <T> toAsync(block: suspend () -> Result<T>): Promise<T> {
return coroutineScope.promise { block().getOrThrow() }
}
Foo common
package com.foo
import kotlinx.coroutines.delay
import kotlin.js.JsExport
@JsExport
class Foo {
@JsPromiseResult
@JsExport.Ignore
suspend fun test(): Result<String> {
delay(500)
return Result.success("")
}
}
This produces the error:
Caused by: java.lang.IllegalStateException: Cannot find transformer function symbol for transformer: Transformer(copyAnnotationExcludes=[], markAnnotation=MarkAnnotation(asPropertyProperty='asProperty', classInfo=ClassInfo(className='JsPromiseResult', packageName='com.annotations', local=false, nullable=false), baseNameProperty='baseName', suffixProperty='suffix', defaultSuffix='Async', defaultAsProperty=false), transformFunctionInfo=FunctionInfo(functionName='toAsync', packageName='com.annotations'), transformReturnType=ClassInfo(className='Promise', packageName='kotlin.js', local=false, nullable=false), transformReturnTypeGeneric=true, originFunctionIncludeAnnotations=[], syntheticFunctionIncludeAnnotations=[], copyAnnotationsToSyntheticFunction=false, copyAnnotationsToSyntheticProperty=false)