From 64686c11a989179fb652f062d1f9d748d37fd122 Mon Sep 17 00:00:00 2001 From: ForteScarlet Date: Wed, 13 Nov 2024 23:53:02 +0800 Subject: [PATCH] =?UTF-8?q?Type=20Parameter!!!!=F0=9F=98=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildSrc/src/main/kotlin/IProject.kt | 2 +- .../fir/SuspendTransformFirTransformer.kt | 98 ++++++++++++++++++- .../src/testData/codegen/typeAttr.asm.txt | 28 ++++-- .../src/testData/codegen/typeAttr.fir.ir.txt | 72 +++++++++----- .../src/testData/codegen/typeAttr.fir.txt | 16 ++- .../src/testData/codegen/typeAttr.kt | 8 +- gradle/libs.versions.toml | 2 +- settings.gradle.kts | 2 +- 8 files changed, 185 insertions(+), 43 deletions(-) diff --git a/buildSrc/src/main/kotlin/IProject.kt b/buildSrc/src/main/kotlin/IProject.kt index 5d2c625..d365c9e 100644 --- a/buildSrc/src/main/kotlin/IProject.kt +++ b/buildSrc/src/main/kotlin/IProject.kt @@ -10,7 +10,7 @@ object IProject : ProjectDetail() { const val HOMEPAGE = "https://github.com/ForteScarlet/kotlin-suspend-transform-compiler-plugin" // Remember the libs.versions.toml! - val ktVersion = "2.0.20" + val ktVersion = "2.0.21" val pluginVersion = "0.9.4" override val version: String = "$ktVersion-$pluginVersion" diff --git a/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/fir/SuspendTransformFirTransformer.kt b/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/fir/SuspendTransformFirTransformer.kt index 36fb14e..17591c3 100644 --- a/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/fir/SuspendTransformFirTransformer.kt +++ b/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/fir/SuspendTransformFirTransformer.kt @@ -11,7 +11,6 @@ import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.context.MutableCheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.getContainingClassSymbol import org.jetbrains.kotlin.fir.analysis.checkers.processOverriddenFunctions -import org.jetbrains.kotlin.fir.builder.buildFunctionTypeParameter import org.jetbrains.kotlin.fir.caches.FirCache import org.jetbrains.kotlin.fir.caches.firCachesFactory import org.jetbrains.kotlin.fir.caches.getValue @@ -36,6 +35,7 @@ import org.jetbrains.kotlin.fir.resolve.SessionHolderImpl import org.jetbrains.kotlin.fir.resolve.getSuperTypes import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculatorForFullBodyResolve import org.jetbrains.kotlin.fir.scopes.impl.FirClassDeclaredMemberScope +import org.jetbrains.kotlin.fir.scopes.impl.toConeType import org.jetbrains.kotlin.fir.scopes.processAllFunctions import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.symbols.SymbolInternals @@ -43,7 +43,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef -import org.jetbrains.kotlin.ir.builders.declarations.buildTypeParameter import org.jetbrains.kotlin.name.CallableId import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName @@ -150,14 +149,104 @@ class SuspendTransformFirTransformer( // In the generated IR, data and dataBlocking will share an `A`, generating the error. // The error: Duplicate IR node // [IR VALIDATION] JvmIrValidationBeforeLoweringPhase: Duplicate IR node: TYPE_PARAMETER name:A index:0 variance: superTypes:[kotlin.Any?] reified:false of FUN GENERATED[...] - // TODO onebot type parameters? + // TODO copy to value parameters, receiver and return type? + val originalTypeParameterCache = mutableMapOf() typeParameters.replaceAll { buildTypeParameterCopy(it) { containingDeclarationSymbol = newFunSymbol // it.containingDeclarationSymbol - symbol = it.symbol // FirTypeParameterSymbol() +// symbol = it.symbol // FirTypeParameterSymbol() + symbol = FirTypeParameterSymbol() + }.also { new -> + originalTypeParameterCache[it] = new + } } + // TODO + valueParameters.replaceAll { vp -> + buildValueParameterCopy(vp) { + symbol = FirValueParameterSymbol(vp.symbol.name) + + val cachedTypeParameter = originalTypeParameterCache.entries.find { (k, v) -> + k.toConeType() == vp.returnTypeRef.coneTypeOrNull + } + val newReturnTypeRef = if (cachedTypeParameter != null) { + returnTypeRef.withReplacedConeType(cachedTypeParameter.value.toConeType()) + } else { + println("returnTypeRef: $returnTypeRef") + returnTypeRef.coneType.typeArguments.forEach { + println("returnTypeRef.coneType.typeArguments: $it") + } + + returnTypeRef + } + + returnTypeRef = newReturnTypeRef + } + } + +// valueParameters.replaceAll { vp -> +// buildValueParameterCopy(vp) { +// //println("find: ${originalTypeParameterCache[vp.returnTypeRef]}") +// val cachedTypeParameter = originalTypeParameterCache.entries.find { (k, v) -> +// k.toConeType() == vp.returnTypeRef.coneTypeOrNull +// } +// println("cache conetype: $cachedTypeParameter") +// +// println("returnTypeRef1: $returnTypeRef") +// +// val stack = ArrayDeque() +// +// fun resolveTypeCopy() { +// +// } +// +// val type = returnTypeRef.coneTypeOrNull +// if (type != null && type.typeArguments.isNotEmpty()) { +// for (subArguments in type.typeArguments) { +// +// } +// } +// +// returnTypeRef.accept(object : FirVisitorVoid() { +// override fun visitElement(element: FirElement) { +// println("visitElement($element)") +// element.acceptChildren(this) +// } +// +// override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) { +// println("visitResolvedTypeRef(${resolvedTypeRef})") +// resolvedTypeRef.type.typeArguments.forEach { +// it.type?.typeArguments +// } +// super.visitResolvedTypeRef(resolvedTypeRef) +// } +// +// override fun visitValueParameter(valueParameter: FirValueParameter) { +// println("visitValueParameter($valueParameter)") +// super.visitValueParameter(valueParameter) +// } +// +// override fun visitTypeParameter(typeParameter: FirTypeParameter) { +// println("visitTypeParameter($typeParameter)") +// super.visitTypeParameter(typeParameter) +// } +// +// override fun visitTypeParameterRef(typeParameterRef: FirTypeParameterRef) { +// println("visitTypeParameterRef($typeParameterRef)") +// super.visitTypeParameterRef(typeParameterRef) +// } +// }) +// +// if (cachedTypeParameter != null) { +// returnTypeRef = returnTypeRef.withReplacedConeType(cachedTypeParameter.value.toConeType()) +// } +// +// println("returnTypeRef2: $returnTypeRef") +// symbol = FirValueParameterSymbol(vp.symbol.name) +// } +// } + // valueParameters.replaceAll { vp -> // buildValueParameterCopy(vp) { // containingFunctionSymbol = newFunSymbol @@ -185,7 +274,6 @@ class SuspendTransformFirTransformer( ).origin } - funList.add(newFun.symbol) } } diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.asm.txt b/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.asm.txt index 8711a96..465ee38 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.asm.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.asm.txt @@ -1,11 +1,15 @@ +public final class Api : java/lang/Object { + public void () +} + public class Bar : java/lang/Object { public void () } public final class Foo$DefaultImpls : java/lang/Object { - public static java.util.concurrent.CompletableFuture runAsync(Foo $this) + public static java.util.concurrent.CompletableFuture runAsync(Foo $this, Api api) - public static java.lang.Object runBlocking(Foo $this) + public static java.lang.Object runBlocking(Foo $this, Api api) public static java.util.concurrent.CompletableFuture valueAsync(Foo $this) @@ -13,11 +17,13 @@ public final class Foo$DefaultImpls : java/lang/Object { } final class Foo$runAsync$1 : kotlin/coroutines/jvm/internal/SuspendLambda, kotlin/jvm/functions/Function1 { + final Api $api + int label final Foo this$0 - void (Foo $receiver, kotlin.coroutines.Continuation $completion) + void (Foo $receiver, Api $api, kotlin.coroutines.Continuation $completion) public final kotlin.coroutines.Continuation create(kotlin.coroutines.Continuation $completion) @@ -29,11 +35,13 @@ final class Foo$runAsync$1 : kotlin/coroutines/jvm/internal/SuspendLambda, kotli } final class Foo$runBlocking$1 : kotlin/coroutines/jvm/internal/SuspendLambda, kotlin/jvm/functions/Function1 { + final Api $api + int label final Foo this$0 - void (Foo $receiver, kotlin.coroutines.Continuation $completion) + void (Foo $receiver, Api $api, kotlin.coroutines.Continuation $completion) public final kotlin.coroutines.Continuation create(kotlin.coroutines.Continuation $completion) @@ -77,11 +85,11 @@ final class Foo$valueBlocking$1 : kotlin/coroutines/jvm/internal/SuspendLambda, } public abstract interface Foo : java/lang/Object { - public abstract java.lang.Object run(kotlin.coroutines.Continuation p0) + public abstract java.lang.Object run(Api p0, kotlin.coroutines.Continuation p1) - public abstract java.util.concurrent.CompletableFuture runAsync() + public abstract java.util.concurrent.CompletableFuture runAsync(Api p0) - public abstract java.lang.Object runBlocking() + public abstract java.lang.Object runBlocking(Api p0) public abstract java.lang.Object value(kotlin.coroutines.Continuation p0) @@ -93,9 +101,11 @@ public abstract interface Foo : java/lang/Object { public final class FooImpl : java/lang/Object, Foo { public void () - public java.util.concurrent.CompletableFuture runAsync() + public java.lang.Object run(Api api, kotlin.coroutines.Continuation $completion) + + public java.util.concurrent.CompletableFuture runAsync(Api api) - public java.lang.Object runBlocking() + public java.lang.Object runBlocking(Api api) public java.lang.Object value(kotlin.coroutines.Continuation $completion) diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.fir.ir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.fir.ir.txt index 9677503..7ea9238 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.fir.ir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.fir.ir.txt @@ -1,4 +1,24 @@ FILE fqName: fileName:/Main.kt + CLASS CLASS name:Api modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Api.Api> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any] reified:false + CONSTRUCTOR visibility:public <> () returnType:.Api.Api> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Api modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:Bar modality:OPEN visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Bar CONSTRUCTOR visibility:public <> () returnType:.Bar [primary] @@ -33,28 +53,22 @@ FILE fqName: fileName:/Main.kt overridden: public open fun hashCode (): kotlin.Int declared in .Foo $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:run visibility:public modality:ABSTRACT ($this:.Foo<.Tar>) returnType:R of .Foo.runBlocking [suspend,fake_override] - annotations: - JvmBlocking(baseName = , suffix = , asProperty = ) - JvmAsync(baseName = , suffix = , asProperty = ) - overridden: - public abstract fun run (): R of .Foo.runBlocking declared in .Foo - TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any] reified:false - $this: VALUE_PARAMETER name: type:.Foo<.Tar> - FUN FAKE_OVERRIDE name:runAsync visibility:public modality:OPEN ($this:.Foo<.Tar>) returnType:java.util.concurrent.CompletableFuture [fake_override] + FUN FAKE_OVERRIDE name:runAsync visibility:public modality:OPEN ($this:.Foo<.Tar>, api:.Api.Foo.run>) returnType:java.util.concurrent.CompletableFuture [fake_override] annotations: Api4J overridden: - public open fun runAsync (): java.util.concurrent.CompletableFuture declared in .Foo + public open fun runAsync (api: .Api.Foo.run>): java.util.concurrent.CompletableFuture declared in .Foo TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any] reified:false $this: VALUE_PARAMETER name: type:.Foo<.Tar> - FUN FAKE_OVERRIDE name:runBlocking visibility:public modality:OPEN ($this:.Foo<.Tar>) returnType:R of .FooImpl.runBlocking [fake_override] + VALUE_PARAMETER name:api index:0 type:.Api.Foo.run> + FUN FAKE_OVERRIDE name:runBlocking visibility:public modality:OPEN ($this:.Foo<.Tar>, api:.Api.Foo.run>) returnType:R of .Foo.run [fake_override] annotations: Api4J overridden: - public open fun runBlocking (): R of .Foo.runBlocking declared in .Foo + public open fun runBlocking (api: .Api.Foo.run>): R of .Foo.run declared in .Foo TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any] reified:false $this: VALUE_PARAMETER name: type:.Foo<.Tar> + VALUE_PARAMETER name:api index:0 type:.Api.Foo.run> FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: public open fun toString (): kotlin.String declared in .Foo @@ -71,6 +85,15 @@ FILE fqName: fileName:/Main.kt overridden: public open fun valueBlocking (): T of .Foo declared in .Foo $this: VALUE_PARAMETER name: type:.Foo<.Tar> + FUN name:run visibility:public modality:OPEN ($this:.FooImpl, api:.Api.FooImpl.run>) returnType:R of .FooImpl.run [suspend] + overridden: + public abstract fun run (api: .Api.Foo.run>): R of .Foo.run declared in .Foo + TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any] reified:false + $this: VALUE_PARAMETER name: type:.FooImpl + VALUE_PARAMETER name:api index:0 type:.Api.FooImpl.run> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun run (api: .Api.FooImpl.run>): R of .FooImpl.run declared in .FooImpl' + CALL 'public final fun TODO (): kotlin.Nothing declared in kotlin' type=kotlin.Nothing origin=null FUN name:value visibility:public modality:OPEN <> ($this:.FooImpl) returnType:.Tar [suspend] overridden: public abstract fun value (): T of .Foo declared in .Foo @@ -113,38 +136,42 @@ FILE fqName: fileName:/Main.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any - FUN GENERATED[love.forte.plugin.suspendtrans.fir.SuspendTransformPluginKey] name:runAsync visibility:public modality:OPEN ($this:.Foo.Foo>) returnType:java.util.concurrent.CompletableFuture + FUN GENERATED[love.forte.plugin.suspendtrans.fir.SuspendTransformPluginKey] name:runAsync visibility:public modality:OPEN ($this:.Foo.Foo>, api:.Api.Foo.run>) returnType:java.util.concurrent.CompletableFuture annotations: Api4J TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any] reified:false $this: VALUE_PARAMETER name: type:.Foo.Foo> + VALUE_PARAMETER name:api index:0 type:.Api.Foo.run> BLOCK_BODY - RETURN type=kotlin.Nothing from='public open fun runAsync (): java.util.concurrent.CompletableFuture declared in .Foo' + RETURN type=kotlin.Nothing from='public open fun runAsync (api: .Api.Foo.run>): java.util.concurrent.CompletableFuture declared in .Foo' CALL 'public final fun $runInAsync$ (block: kotlin.coroutines.SuspendFunction0, scope: kotlinx.coroutines.CoroutineScope?): java.util.concurrent.CompletableFuture declared in love.forte.plugin.suspendtrans.runtime' type=java.util.concurrent.CompletableFuture origin=null : block: FUN_EXPR type=kotlin.coroutines.SuspendFunction0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:java.util.concurrent.CompletableFuture [suspend] BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): java.util.concurrent.CompletableFuture declared in .Foo.runAsync' - CALL 'public abstract fun run (): R of .Foo.runBlocking declared in .Foo' type=R of .Foo.runBlocking origin=null + CALL 'public abstract fun run (api: .Api.Foo.run>): R of .Foo.run declared in .Foo' type=R of .Foo.run origin=null : $this: GET_VAR ': .Foo.Foo> declared in .Foo.runAsync' type=.Foo.Foo> origin=null - FUN GENERATED[love.forte.plugin.suspendtrans.fir.SuspendTransformPluginKey] name:runBlocking visibility:public modality:OPEN ($this:.Foo.Foo>) returnType:R of .Foo.runBlocking + api: GET_VAR 'api: .Api.Foo.run> declared in .Foo.runAsync' type=.Api.Foo.run> origin=null + FUN GENERATED[love.forte.plugin.suspendtrans.fir.SuspendTransformPluginKey] name:runBlocking visibility:public modality:OPEN ($this:.Foo.Foo>, api:.Api.Foo.run>) returnType:R of .Foo.run annotations: Api4J TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any] reified:false $this: VALUE_PARAMETER name: type:.Foo.Foo> + VALUE_PARAMETER name:api index:0 type:.Api.Foo.run> BLOCK_BODY - RETURN type=kotlin.Nothing from='public open fun runBlocking (): R of .Foo.runBlocking declared in .Foo' + RETURN type=kotlin.Nothing from='public open fun runBlocking (api: .Api.Foo.run>): R of .Foo.run declared in .Foo' CALL 'public final fun $runInBlocking$ (block: kotlin.coroutines.SuspendFunction0): 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 : - block: FUN_EXPR type=kotlin.coroutines.SuspendFunction0.Foo.runBlocking> origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:R of .Foo.runBlocking [suspend] + block: FUN_EXPR type=kotlin.coroutines.SuspendFunction0.Foo.run> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:R of .Foo.run [suspend] BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): R of .Foo.runBlocking declared in .Foo.runBlocking' - CALL 'public abstract fun run (): R of .Foo.runBlocking declared in .Foo' type=R of .Foo.runBlocking origin=null + RETURN type=kotlin.Nothing from='local final fun (): R of .Foo.run declared in .Foo.runBlocking' + CALL 'public abstract fun run (api: .Api.Foo.run>): R of .Foo.run declared in .Foo' type=R of .Foo.run origin=null : $this: GET_VAR ': .Foo.Foo> declared in .Foo.runBlocking' type=.Foo.Foo> origin=null + api: GET_VAR 'api: .Api.Foo.run> declared in .Foo.runBlocking' type=.Api.Foo.run> origin=null FUN GENERATED[love.forte.plugin.suspendtrans.fir.SuspendTransformPluginKey] name:valueAsync visibility:public modality:OPEN <> ($this:.Foo.Foo>) returnType:java.util.concurrent.CompletableFuture annotations: Api4J @@ -173,13 +200,14 @@ FILE fqName: fileName:/Main.kt RETURN type=kotlin.Nothing from='local final fun (): T of .Foo declared in .Foo.valueBlocking' CALL 'public abstract fun value (): T of .Foo declared in .Foo' type=T of .Foo origin=null $this: GET_VAR ': .Foo.Foo> declared in .Foo.valueBlocking' type=.Foo.Foo> origin=null - FUN name:run visibility:public modality:ABSTRACT ($this:.Foo.Foo>) returnType:R of .Foo.runBlocking [suspend] + FUN name:run visibility:public modality:ABSTRACT ($this:.Foo.Foo>, api:.Api.Foo.run>) returnType:R of .Foo.run [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) JvmAsync(baseName = , suffix = , asProperty = ) JvmSynthetic TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any] reified:false $this: VALUE_PARAMETER name: type:.Foo.Foo> + VALUE_PARAMETER name:api index:0 type:.Api.Foo.run> FUN name:value visibility:public modality:ABSTRACT <> ($this:.Foo.Foo>) returnType:T of .Foo [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.fir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.fir.txt index c9ad3d8..f85c6f5 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.fir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.fir.txt @@ -10,19 +10,25 @@ FILE: Main.kt super() } + } + public final class Api : R|kotlin/Any| { + public constructor(): R|Api| { + super() + } + } public abstract interface Foo : R|kotlin/Any| { @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() public abstract suspend fun value(): R|T| - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() public abstract suspend fun run(): R|R| + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() public abstract suspend fun run(api: R|Api|): R|R| @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public open fun valueAsync(): R|java/util/concurrent/CompletableFuture| @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public open fun valueBlocking(): R|T| - @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public open fun runAsync(): R|java/util/concurrent/CompletableFuture| + @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public open fun runAsync(api: R|Api|): R|java/util/concurrent/CompletableFuture| - @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public open fun runBlocking(): R|R| + @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public open fun runBlocking(api: R|Api|): R|R| } public final class FooImpl : R|Foo| { @@ -34,4 +40,8 @@ FILE: Main.kt ^value R|/Tar.Tar|() } + public open override suspend fun run(api: R|Api|): R|R| { + ^run R|kotlin/TODO|() + } + } diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.kt b/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.kt index 2a75a22..164eb39 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.kt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.kt @@ -8,6 +8,8 @@ import love.forte.plugin.suspendtrans.annotation.JvmBlocking open class Bar class Tar : Bar() +class Api + interface Foo { @JvmBlocking @JvmAsync @@ -15,12 +17,16 @@ interface Foo { @JvmBlocking @JvmAsync - suspend fun run(): R + suspend fun run(api: Api): R } class FooImpl : Foo { override suspend fun value(): Tar { return Tar() } + + override suspend fun run(api: Api): R { + return TODO() + } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c75553d..5a32ef8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ kotlinx-coroutines = "1.8.0" kotlinx-serialization = "1.7.1" google-auto-service = "1.0.1" # Remember the `IProject.ktVersion`! -kotlin = "2.0.20" +kotlin = "2.0.21" [libraries] diff --git a/settings.gradle.kts b/settings.gradle.kts index 3815ef9..a9ad244 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -28,5 +28,5 @@ include(":runtime:suspend-transform-runtime") include(":plugins:suspend-transform-plugin-gradle") //Samples -include(":tests:test-jvm") +//include(":tests:test-jvm") //include(":tests:test-js")