Skip to content

Commit 6586751

Browse files
committed
fix: IllegalArgumentException: Failed requirement when attempting to copy an annotation with an argument of type KClass
1 parent 964217d commit 6586751

File tree

15 files changed

+376
-49
lines changed

15 files changed

+376
-49
lines changed

buildSrc/src/main/kotlin/IProject.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object IProject : ProjectDetail() {
1111

1212
// Remember the libs.versions.toml!
1313
val ktVersion = "2.0.20-Beta1"
14-
val pluginVersion = "0.9.1"
14+
val pluginVersion = "0.9.2"
1515

1616
override val version: String = "$ktVersion-$pluginVersion"
1717

@@ -46,6 +46,6 @@ object IProject : ProjectDetail() {
4646
fun Project.setupWith(ktVersion: String) {
4747
group = IProject.GROUP
4848
description = IProject.DESCRIPTION
49-
val mergedVersion = ktVersion + "-" + IProject.pluginVersion.toString()
49+
val mergedVersion = ktVersion + "-" + IProject.pluginVersion
5050
version = if (IS_SNAPSHOT) "$mergedVersion-SNAPSHOT" else mergedVersion
5151
}

compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/fir/SuspendTransformFirTransformer.kt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,29 @@ class SuspendTransformFirTransformer(
415415
excludes.any { ex -> annotationClassId == ex }
416416
}
417417

418-
addAll(notCompileAnnotationsCopied)
418+
/*
419+
* Create a new annotation based the annotation from the original function.
420+
* It will be crashed with `IllegalArgumentException: Failed requirement`
421+
* when using the `notCompileAnnotationsCopied` directly
422+
* if there have some arguments with type `KClass`,
423+
* e.g. `annotation class OneAnnotation(val target: KClass<*>)` or `kotlin.OptIn`.
424+
*
425+
* See https://github.com/ForteScarlet/kotlin-suspend-transform-compiler-plugin/issues/56
426+
*/
427+
val copied = notCompileAnnotationsCopied.map { a ->
428+
buildAnnotation {
429+
annotationTypeRef = buildResolvedTypeRef {
430+
type = a.resolvedType
431+
}
432+
this.typeArguments.addAll(a.typeArguments)
433+
this.argumentMapping = buildAnnotationArgumentMapping {
434+
this.source = a.source
435+
this.mapping.putAll(a.argumentMapping.mapping)
436+
}
437+
}
438+
}
439+
440+
addAll(copied)
419441
}
420442

421443
// try add @Generated(by = ...)

compiler/suspend-transform-plugin/src/test-gen/love/forte/plugin/suspendtrans/runners/CodeGenTestRunnerGenerated.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,10 @@ public void testOverride() {
4343
public void testTypeAttr() {
4444
runTest("src/testData/codegen/typeAttr.kt");
4545
}
46+
47+
@Test
48+
@TestMetadata("opt.kt")
49+
public void testOpt() {
50+
runTest("src/testData/codegen/opt.kt");
51+
}
4652
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
public abstract interface OneOptAnno : java/lang/Object, java/lang/annotation/Annotation {
2+
3+
}
4+
5+
final class OptInTest$runAsync$1 : kotlin/coroutines/jvm/internal/SuspendLambda, kotlin/jvm/functions/Function1 {
6+
int label
7+
8+
final OptInTest this$0
9+
10+
void <init>(OptInTest $receiver, kotlin.coroutines.Continuation $completion)
11+
12+
public final kotlin.coroutines.Continuation create(kotlin.coroutines.Continuation $completion)
13+
14+
public final java.lang.Object invoke(kotlin.coroutines.Continuation p1)
15+
16+
public java.lang.Object invoke(java.lang.Object p1)
17+
18+
public final java.lang.Object invokeSuspend(java.lang.Object $result)
19+
}
20+
21+
final class OptInTest$runBlocking$1 : kotlin/coroutines/jvm/internal/SuspendLambda, kotlin/jvm/functions/Function1 {
22+
int label
23+
24+
final OptInTest this$0
25+
26+
void <init>(OptInTest $receiver, kotlin.coroutines.Continuation $completion)
27+
28+
public final kotlin.coroutines.Continuation create(kotlin.coroutines.Continuation $completion)
29+
30+
public final java.lang.Object invoke(kotlin.coroutines.Continuation p1)
31+
32+
public java.lang.Object invoke(java.lang.Object p1)
33+
34+
public final java.lang.Object invokeSuspend(java.lang.Object $result)
35+
}
36+
37+
public final class OptInTest : java/lang/Object {
38+
public void <init>()
39+
40+
public final static java.lang.Object access$run0(OptInTest $this, kotlin.coroutines.Continuation $completion)
41+
42+
public final java.lang.Object run(kotlin.coroutines.Continuation $completion)
43+
44+
private final java.lang.Object run0(kotlin.coroutines.Continuation $completion)
45+
46+
public final java.util.concurrent.CompletableFuture runAsync()
47+
48+
public final int runBlocking()
49+
}
50+
51+
public abstract interface Values : java/lang/Object, java/lang/annotation/Annotation {
52+
public abstract java.lang.Class target()
53+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
FILE fqName:<root> fileName:/Main.kt
2+
CLASS ANNOTATION_CLASS name:OneOptAnno modality:OPEN visibility:public superTypes:[kotlin.Annotation]
3+
annotations:
4+
RequiresOptIn(message = <null>, level = GET_ENUM 'ENUM_ENTRY IR_EXTERNAL_DECLARATION_STUB name:ERROR' type=kotlin.RequiresOptIn.Level)
5+
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.OneOptAnno
6+
CONSTRUCTOR visibility:public <> () returnType:<root>.OneOptAnno [primary]
7+
BLOCK_BODY
8+
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
9+
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:OneOptAnno modality:OPEN visibility:public superTypes:[kotlin.Annotation]'
10+
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
11+
overridden:
12+
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Annotation
13+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
14+
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
15+
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
16+
overridden:
17+
public open fun hashCode (): kotlin.Int declared in kotlin.Annotation
18+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
19+
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
20+
overridden:
21+
public open fun toString (): kotlin.String declared in kotlin.Annotation
22+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
23+
CLASS ANNOTATION_CLASS name:Values modality:OPEN visibility:public superTypes:[kotlin.Annotation]
24+
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Values
25+
PROPERTY name:target visibility:public modality:FINAL [val]
26+
FIELD PROPERTY_BACKING_FIELD name:target type:kotlin.reflect.KClass<*> visibility:private [final]
27+
EXPRESSION_BODY
28+
GET_VAR 'target: kotlin.reflect.KClass<*> declared in <root>.Values.<init>' type=kotlin.reflect.KClass<*> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
29+
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-target> visibility:public modality:FINAL <> ($this:<root>.Values) returnType:kotlin.reflect.KClass<*>
30+
correspondingProperty: PROPERTY name:target visibility:public modality:FINAL [val]
31+
$this: VALUE_PARAMETER name:<this> type:<root>.Values
32+
BLOCK_BODY
33+
RETURN type=kotlin.Nothing from='public final fun <get-target> (): kotlin.reflect.KClass<*> declared in <root>.Values'
34+
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:target type:kotlin.reflect.KClass<*> visibility:private [final]' type=kotlin.reflect.KClass<*> origin=null
35+
receiver: GET_VAR '<this>: <root>.Values declared in <root>.Values.<get-target>' type=<root>.Values origin=null
36+
CONSTRUCTOR visibility:public <> (target:kotlin.reflect.KClass<*>) returnType:<root>.Values [primary]
37+
VALUE_PARAMETER name:target index:0 type:kotlin.reflect.KClass<*>
38+
BLOCK_BODY
39+
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
40+
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:Values modality:OPEN visibility:public superTypes:[kotlin.Annotation]'
41+
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
42+
overridden:
43+
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Annotation
44+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
45+
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
46+
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
47+
overridden:
48+
public open fun hashCode (): kotlin.Int declared in kotlin.Annotation
49+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
50+
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
51+
overridden:
52+
public open fun toString (): kotlin.String declared in kotlin.Annotation
53+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
54+
CLASS CLASS name:OptInTest modality:FINAL visibility:public superTypes:[kotlin.Any]
55+
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.OptInTest
56+
CONSTRUCTOR visibility:public <> () returnType:<root>.OptInTest [primary]
57+
BLOCK_BODY
58+
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
59+
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:OptInTest modality:FINAL visibility:public superTypes:[kotlin.Any]'
60+
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
61+
overridden:
62+
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
63+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
64+
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
65+
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
66+
overridden:
67+
public open fun hashCode (): kotlin.Int declared in kotlin.Any
68+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
69+
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
70+
overridden:
71+
public open fun toString (): kotlin.String declared in kotlin.Any
72+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
73+
FUN GENERATED[love.forte.plugin.suspendtrans.fir.SuspendTransformPluginKey] name:runAsync visibility:public modality:FINAL <> ($this:<root>.OptInTest) returnType:java.util.concurrent.CompletableFuture
74+
annotations:
75+
OptIn(markerClass = [CLASS_REFERENCE 'CLASS ANNOTATION_CLASS name:OneOptAnno modality:OPEN visibility:public superTypes:[kotlin.Annotation]' type=kotlin.reflect.KClass<<root>.OneOptAnno>])
76+
Values(target = CLASS_REFERENCE 'CLASS CLASS name:OptInTest modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<<root>.OptInTest>)
77+
JvmBlocking(baseName = <null>, suffix = <null>, asProperty = <null>)
78+
Api4J
79+
$this: VALUE_PARAMETER name:<this> type:<root>.OptInTest
80+
BLOCK_BODY
81+
RETURN type=kotlin.Nothing from='public final fun runAsync (): java.util.concurrent.CompletableFuture declared in <root>.OptInTest'
82+
CALL 'public final fun $runInAsync$ <T> (block: kotlin.coroutines.SuspendFunction0<T of love.forte.plugin.suspendtrans.runtime.$runInAsync$>, scope: kotlinx.coroutines.CoroutineScope?): java.util.concurrent.CompletableFuture declared in love.forte.plugin.suspendtrans.runtime' type=java.util.concurrent.CompletableFuture origin=null
83+
<T>: <none>
84+
block: FUN_EXPR type=kotlin.coroutines.SuspendFunction0<java.util.concurrent.CompletableFuture> origin=LAMBDA
85+
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<no name provided> visibility:local modality:FINAL <> () returnType:java.util.concurrent.CompletableFuture [suspend]
86+
BLOCK_BODY
87+
RETURN type=kotlin.Nothing from='local final fun <no name provided> (): java.util.concurrent.CompletableFuture declared in <root>.OptInTest.runAsync'
88+
CALL 'public final fun run (): kotlin.Int declared in <root>.OptInTest' type=kotlin.Int origin=null
89+
$this: GET_VAR '<this>: <root>.OptInTest declared in <root>.OptInTest.runAsync' type=<root>.OptInTest origin=null
90+
FUN GENERATED[love.forte.plugin.suspendtrans.fir.SuspendTransformPluginKey] name:runBlocking visibility:public modality:FINAL <> ($this:<root>.OptInTest) returnType:kotlin.Int
91+
annotations:
92+
OptIn(markerClass = [CLASS_REFERENCE 'CLASS ANNOTATION_CLASS name:OneOptAnno modality:OPEN visibility:public superTypes:[kotlin.Annotation]' type=kotlin.reflect.KClass<<root>.OneOptAnno>])
93+
Values(target = CLASS_REFERENCE 'CLASS CLASS name:OptInTest modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<<root>.OptInTest>)
94+
JvmAsync(baseName = <null>, suffix = <null>, asProperty = <null>)
95+
Api4J
96+
$this: VALUE_PARAMETER name:<this> type:<root>.OptInTest
97+
BLOCK_BODY
98+
RETURN type=kotlin.Nothing from='public final fun runBlocking (): kotlin.Int declared in <root>.OptInTest'
99+
CALL 'public final fun $runInBlocking$ <T> (block: kotlin.coroutines.SuspendFunction0<T of love.forte.plugin.suspendtrans.runtime.$runInBlocking$>): T of love.forte.plugin.suspendtrans.runtime.$runInBlocking$ declared in love.forte.plugin.suspendtrans.runtime' type=T of love.forte.plugin.suspendtrans.runtime.$runInBlocking$ origin=null
100+
<T>: <none>
101+
block: FUN_EXPR type=kotlin.coroutines.SuspendFunction0<kotlin.Int> origin=LAMBDA
102+
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<no name provided> visibility:local modality:FINAL <> () returnType:kotlin.Int [suspend]
103+
BLOCK_BODY
104+
RETURN type=kotlin.Nothing from='local final fun <no name provided> (): kotlin.Int declared in <root>.OptInTest.runBlocking'
105+
CALL 'public final fun run (): kotlin.Int declared in <root>.OptInTest' type=kotlin.Int origin=null
106+
$this: GET_VAR '<this>: <root>.OptInTest declared in <root>.OptInTest.runBlocking' type=<root>.OptInTest origin=null
107+
FUN name:run visibility:public modality:FINAL <> ($this:<root>.OptInTest) returnType:kotlin.Int [suspend]
108+
annotations:
109+
OptIn(markerClass = [CLASS_REFERENCE 'CLASS ANNOTATION_CLASS name:OneOptAnno modality:OPEN visibility:public superTypes:[kotlin.Annotation]' type=kotlin.reflect.KClass<<root>.OneOptAnno>])
110+
Values(target = CLASS_REFERENCE 'CLASS CLASS name:OptInTest modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<<root>.OptInTest>)
111+
JvmBlocking(baseName = <null>, suffix = <null>, asProperty = <null>)
112+
JvmAsync(baseName = <null>, suffix = <null>, asProperty = <null>)
113+
JvmSynthetic
114+
$this: VALUE_PARAMETER name:<this> type:<root>.OptInTest
115+
BLOCK_BODY
116+
RETURN type=kotlin.Nothing from='public final fun run (): kotlin.Int declared in <root>.OptInTest'
117+
CALL 'private final fun run0 (): kotlin.Int declared in <root>.OptInTest' type=kotlin.Int origin=null
118+
$this: GET_VAR '<this>: <root>.OptInTest declared in <root>.OptInTest.run' type=<root>.OptInTest origin=null
119+
FUN name:run0 visibility:private modality:FINAL <> ($this:<root>.OptInTest) returnType:kotlin.Int [suspend]
120+
annotations:
121+
OneOptAnno
122+
$this: VALUE_PARAMETER name:<this> type:<root>.OptInTest
123+
BLOCK_BODY
124+
RETURN type=kotlin.Nothing from='private final fun run0 (): kotlin.Int declared in <root>.OptInTest'
125+
CONST Int type=kotlin.Int value=1
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FILE: Main.kt
2+
@R|kotlin/RequiresOptIn|(level = Q|kotlin/RequiresOptIn.Level|.R|kotlin/RequiresOptIn.Level.ERROR|) public final annotation class OneOptAnno : R|kotlin/Annotation| {
3+
public constructor(): R|OneOptAnno| {
4+
super<R|kotlin/Any|>()
5+
}
6+
7+
}
8+
public final annotation class Values : R|kotlin/Annotation| {
9+
public constructor(target: R|kotlin/reflect/KClass<*>|): R|Values| {
10+
super<R|kotlin/Any|>()
11+
}
12+
13+
public final val target: R|kotlin/reflect/KClass<*>| = R|<local>/target|
14+
public get(): R|kotlin/reflect/KClass<*>|
15+
16+
}
17+
public final class OptInTest : R|kotlin/Any| {
18+
public constructor(): R|OptInTest| {
19+
super<R|kotlin/Any|>()
20+
}
21+
22+
@R|OneOptAnno|() private final suspend fun run0(): R|kotlin/Int| {
23+
^run0 Int(1)
24+
}
25+
26+
@R|kotlin/OptIn|(markerClass = vararg(<getClass>(Q|OneOptAnno|))) @R|Values|(target = <getClass>(Q|OptInTest|)) @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() public final suspend fun run(): R|kotlin/Int| {
27+
^run this@R|/OptInTest|.R|/OptInTest.run0|()
28+
}
29+
30+
@R|kotlin/OptIn|(markerClass = vararg(<getClass>(Q|OneOptAnno|))) @R|Values|(target = <getClass>(Q|OptInTest|)) @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public final fun runAsync(): R|java/util/concurrent/CompletableFuture<out kotlin/Int>|
31+
32+
@R|kotlin/OptIn|(markerClass = vararg(<getClass>(Q|OneOptAnno|))) @R|Values|(target = <getClass>(Q|OptInTest|)) @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public final fun runBlocking(): R|kotlin/Int|
33+
34+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// FIR_DUMP
2+
// DUMP_IR
3+
// SOURCE
4+
// FILE: Main.kt [MainKt#main]
5+
6+
import kotlinx.coroutines.suspendCancellableCoroutine
7+
import love.forte.plugin.suspendtrans.annotation.JvmAsync
8+
import love.forte.plugin.suspendtrans.annotation.JvmBlocking
9+
import kotlin.annotation.AnnotationRetention.SOURCE
10+
import kotlin.coroutines.resume
11+
import kotlin.reflect.KClass
12+
13+
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
14+
annotation class OneOptAnno
15+
16+
annotation class Values(val target: KClass<*>)
17+
18+
class OptInTest {
19+
@OneOptAnno
20+
private suspend fun run0() = 1
21+
22+
@OptIn(OneOptAnno::class)
23+
@Values(OptInTest::class)
24+
@JvmBlocking
25+
@JvmAsync
26+
suspend fun run(): Int = run0()
27+
}

samples/sample-js/build.gradle.kts

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,55 +25,40 @@ repositories {
2525

2626
apply(plugin = "love.forte.plugin.suspend-transform")
2727

28-
//tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
29-
// kotlinOptions {
30-
// useK2
31-
// languageVersion = "2.0"
32-
// }
33-
//}
34-
35-
36-
28+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
3729
kotlin {
30+
compilerOptions {
31+
freeCompilerArgs.addAll(
32+
"-Xexpect-actual-classes"
33+
)
34+
}
35+
3836
js(IR) {
3937
nodejs()
4038
useEsModules()
4139
generateTypeScriptDefinitions()
4240
binaries.executable()
4341

44-
@OptIn(ExperimentalKotlinGradlePluginApi::class)
4542
compilerOptions {
4643
target = "es2015"
4744
useEsClasses = true
4845
freeCompilerArgs.addAll(
4946
// https://kotlinlang.org/docs/whatsnew20.html#per-file-compilation-for-kotlin-js-projects
50-
"-Xir-per-file"
47+
"-Xir-per-file",
5148
)
5249
}
53-
54-
// compilations.all {
55-
// kotlinOptions {
56-
// useEsClasses = true
57-
// }
58-
// }
5950
}
6051

6152
sourceSets {
6253
named("jsMain") {
6354
dependencies {
6455
implementation(kotlin("stdlib"))
65-
// val pluginVersion = "0.4.0"
66-
// api("love.forte.plugin.suspend-transform:suspend-transform-runtime:$pluginVersion")
67-
// api("love.forte.plugin.suspend-transform:suspend-transform-annotation:$pluginVersion")
68-
// implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
6956
api(libs.kotlinx.coroutines.core)
7057
}
7158
}
7259
}
7360
}
7461

75-
76-
7762
extensions.getByType<SuspendTransformGradleExtension>().apply {
7863
transformers[TargetPlatform.JS] = mutableListOf(
7964
SuspendTransformConfiguration.jsPromiseTransformer.copy(
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@file:OptIn(ExperimentalJsExport::class)
2+
3+
import love.forte.plugin.suspendtrans.annotation.JsPromise
4+
5+
6+
/**
7+
*
8+
* @author ForteScarlet
9+
*/
10+
@JsExport
11+
abstract class Key {
12+
13+
@JsPromise
14+
@JsExport.Ignore
15+
abstract suspend fun run(): Any
16+
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import love.forte.plugin.suspendtrans.annotation.JsPromise
2+
3+
/**
4+
*
5+
* @author ForteScarlet
6+
*/
7+
expect class KeyImpl : Key {
8+
@JsPromise
9+
override suspend fun run(): ByteArray
10+
}

0 commit comments

Comments
 (0)