diff --git a/buildSrc/src/main/kotlin/IProject.kt b/buildSrc/src/main/kotlin/IProject.kt index 52559e0..2dd2602 100644 --- a/buildSrc/src/main/kotlin/IProject.kt +++ b/buildSrc/src/main/kotlin/IProject.kt @@ -11,7 +11,7 @@ object IProject : ProjectDetail() { // Remember the libs.versions.toml! val ktVersion = "2.1.0" - val pluginVersion = "0.9.4" + val pluginVersion = "0.10.0" override val version: String = "$ktVersion-$pluginVersion" diff --git a/compiler/suspend-transform-plugin/src/main/kotlin/LocalLoggerHelper.kt b/compiler/suspend-transform-plugin/src/main/kotlin/LocalLoggerHelper.kt new file mode 100644 index 0000000..ae886db --- /dev/null +++ b/compiler/suspend-transform-plugin/src/main/kotlin/LocalLoggerHelper.kt @@ -0,0 +1,15 @@ +//internal object LocalLoggerHelper { +// private val dir = System.getenv("kstcp.logger.dir") +// private val path = Path(dir ?: ".plugin-logger") / Path("${System.currentTimeMillis()}.log") +// init { +// path.parent.createDirectories() +// if (path.notExists()) { +// path.createFile() +// } +// } +// +// fun println(value: Any?) { +// kotlin.io.println(value) +// path.appendText("[${LocalDateTime.now()}] $value\n", Charsets.UTF_8) +// } +//} diff --git a/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/SuspendTransformConfiguration.kt b/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/SuspendTransformConfiguration.kt index b59129c..82d4563 100644 --- a/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/SuspendTransformConfiguration.kt +++ b/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/SuspendTransformConfiguration.kt @@ -159,6 +159,13 @@ open class SuspendTransformConfiguration { open var transformers: MutableMap> = mutableMapOf() + /** + * 在 K2 中,用于使 IR 的合成函数可以定位到 FIR 中原始函数的辅助注解。 + * + * @since *-0.10.0 + */ + open var targetMarker: ClassInfo? = targetMarkerClassInfo + open fun clear() { transformers.clear() } @@ -217,6 +224,8 @@ open class SuspendTransformConfiguration { } companion object { + val targetMarkerClassInfo = ClassInfo("love.forte.plugin.suspendtrans.annotation", "TargetMarker") + //region JVM defaults @JvmStatic val jvmSyntheticClassInfo = ClassInfo("kotlin.jvm", "JvmSynthetic") diff --git a/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/SuspendTransformUserData.kt b/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/SuspendTransformUserData.kt index 7deb27f..d2693f1 100644 --- a/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/SuspendTransformUserData.kt +++ b/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/SuspendTransformUserData.kt @@ -2,17 +2,25 @@ package love.forte.plugin.suspendtrans import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.analysis.checkers.toClassLikeSymbol +import org.jetbrains.kotlin.fir.declarations.ExpectForActualMatchingData import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.expectForActual +import org.jetbrains.kotlin.fir.scopes.impl.toConeType +import org.jetbrains.kotlin.fir.symbols.SymbolInternals import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol +import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.ConeTypeParameterType import org.jetbrains.kotlin.fir.types.classId import org.jetbrains.kotlin.fir.types.coneTypeOrNull import org.jetbrains.kotlin.ir.declarations.IrFunction import org.jetbrains.kotlin.ir.declarations.IrTypeParameter import org.jetbrains.kotlin.ir.declarations.IrValueParameter +import org.jetbrains.kotlin.ir.expressions.IrConst import org.jetbrains.kotlin.ir.types.classFqName -import org.jetbrains.kotlin.ir.util.callableId -import org.jetbrains.kotlin.ir.util.hasEqualFqName +import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.js.descriptorUtils.getKotlinTypeFqName import org.jetbrains.kotlin.name.CallableId import org.jetbrains.kotlin.name.ClassId @@ -134,48 +142,147 @@ data class OriginValueParameter( data class SuspendTransformUserDataFir( val originSymbol: OriginSymbol, + val markerId: String, val asProperty: Boolean, val transformer: Transformer ) fun FirNamedFunctionSymbol.asOriginSymbol( + targetMarker: ClassId?, typeParameters: List, valueParameters: List, - returnType: ClassId? + returnType: ClassId?, + session: FirSession, ): OriginSymbol { return OriginSymbol( + targetMarker, + symbol = this, callableId = this.callableId, typeParameters = typeParameters.map { it.toTypeParameter() }, - valueParameters = valueParameters.map { it.toValueParameter() }, + valueParameters = valueParameters.mapIndexed { index, p -> p.toValueParameter(session, index) }, returnType ) } data class OriginSymbol( + val targetMarker: ClassId?, + val symbol: FirNamedFunctionSymbol, val callableId: CallableId, val typeParameters: List, val valueParameters: List, val returnType: ClassId? ) -data class TypeParameter(val name: Name, val varianceOrdinal: Int, val isReified: Boolean, val bounds: List) +data class TypeParameter( + val name: Name, + val varianceOrdinal: Int, + val isReified: Boolean, + val bounds: List, + val type: ConeTypeParameterType, +) -private fun FirTypeParameter.toTypeParameter(): TypeParameter = - TypeParameter( +private fun FirTypeParameter.toTypeParameter(): TypeParameter { + return TypeParameter( name, variance.ordinal, isReified, - bounds.map { it.coneTypeOrNull?.classId } + bounds.map { it.coneTypeOrNull?.classId }, + toConeType(), ) +} + + +data class ValueParameter( + val fir: FirValueParameter, + val name: Name, + val index: Int, + val coneType: ConeKotlinType?, + val type: ClassId?, + val expectForActual: ExpectForActualMatchingData? +) +@OptIn(SymbolInternals::class) +private fun FirValueParameter.toValueParameter(session: FirSession, index: Int): ValueParameter { +// LocalLoggerHelper.println("returnTypeRef = $returnTypeRef") +// LocalLoggerHelper.println("symbol.resolvedReturnTypeRef = ${symbol.resolvedReturnTypeRef}") +// LocalLoggerHelper.println("symbol.resolvedReturnTypeRef.coneType = ${symbol.resolvedReturnTypeRef.coneType}") +// LocalLoggerHelper.println("symbol.resolvedReturnTypeRef.coneType.isTypealiasExpansion = ${symbol.resolvedReturnTypeRef.coneType.isTypealiasExpansion}") +// LocalLoggerHelper.println( +// "symbol.resolvedReturnTypeRef.coneType.fullyExpandedType(session) = ${ +// symbol.resolvedReturnTypeRef.coneType.fullyExpandedType( +// session +// ) +// }" +// ) +// +// LocalLoggerHelper.println( +// "returnTypeRef.coneType.toClassLikeSymbol(session)?.isActual: ${ +// returnTypeRef.coneType.toClassLikeSymbol( +// session +// )?.isActual +// }" +// ) +// LocalLoggerHelper.println( +// "returnTypeRef.coneType.toClassLikeSymbol(session)?.isExpect: ${ +// returnTypeRef.coneType.toClassLikeSymbol( +// session +// )?.isExpect +// }" +// ) +// +// LocalLoggerHelper.println( +// "returnTypeRef.coneType.toRegularClassSymbol(session): ${ +// returnTypeRef.coneType.toRegularClassSymbol( +// session +// ) +// }" +// ) +// LocalLoggerHelper.println( +// "returnTypeRef.coneType.toClassLikeSymbol(session): ${ +// returnTypeRef.coneType.toClassLikeSymbol( +// session +// ) +// }" +// ) +// +// LocalLoggerHelper.println( +// "returnTypeRef.coneType.toRegularClassSymbol(session)?.fir?.expectForActual: " + +// "${returnTypeRef.coneType.toRegularClassSymbol(session)?.fir?.expectForActual}" +// ) +// +// LocalLoggerHelper.println( +// "returnTypeRef.coneType.toRegularClassSymbol(session)?.fir?.memberExpectForActual: " + +// "${returnTypeRef.coneType.toRegularClassSymbol(session)?.fir?.memberExpectForActual}" +// ) +// +// LocalLoggerHelper.println( +// "returnTypeRef.coneType.toRegularClassSymbol(session)?.fir?.fullyExpandedClass.defaultType: " + +// "${ +// returnTypeRef.coneType.toRegularClassSymbol(session)?.fir?.fullyExpandedClass(session) +// ?.defaultType() +// }" +// ) + + return ValueParameter( + this, + name, + index, + returnTypeRef.coneTypeOrNull, + returnTypeRef.coneTypeOrNull?.classId, + returnTypeRef.toClassLikeSymbol(session)?.expectForActual + ) +} -data class ValueParameter(val name: Name, val type: ClassId?) -private fun FirValueParameter.toValueParameter(): ValueParameter = - ValueParameter(name, returnTypeRef.coneTypeOrNull?.classId) +fun OriginSymbol.checkSame(markerId: String, declaration: IrFunction): Boolean { + if (targetMarker != null) { + val anno = declaration.annotations.firstOrNull { it.symbol.owner.parentAsClass.classId == targetMarker } + if (anno == null) return false + val valueArgument = anno.getValueArgument(Name.identifier("value")) as? IrConst ?: return false + return markerId == valueArgument.value + } -fun OriginSymbol.checkSame(declaration: IrFunction): Boolean { // callableId if (callableId != declaration.callableId) return false // return type @@ -215,6 +322,6 @@ private infix fun IrTypeParameter.isSameAs(typeParameter: TypeParameter): Boolea } private infix fun IrValueParameter.isSameAs(valueParameter: ValueParameter): Boolean { - if (name != valueParameter.name) return false + if (index != valueParameter.index) return false return type.classFqName == valueParameter.type?.asSingleFqName() } 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 6297b30..e408557 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 @@ -22,18 +22,17 @@ import org.jetbrains.kotlin.fir.declarations.utils.isFinal import org.jetbrains.kotlin.fir.declarations.utils.isOverride import org.jetbrains.kotlin.fir.declarations.utils.isSuspend import org.jetbrains.kotlin.fir.declarations.utils.modality +import org.jetbrains.kotlin.fir.expectActualMatchingContextFactory import org.jetbrains.kotlin.fir.expressions.FirAnnotation import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirLiteralExpression import org.jetbrains.kotlin.fir.expressions.builder.* import org.jetbrains.kotlin.fir.extensions.FirDeclarationGenerationExtension import org.jetbrains.kotlin.fir.extensions.FirDeclarationPredicateRegistrar import org.jetbrains.kotlin.fir.extensions.MemberGenerationContext import org.jetbrains.kotlin.fir.extensions.predicate.DeclarationPredicate import org.jetbrains.kotlin.fir.plugin.createConeType -import org.jetbrains.kotlin.fir.resolve.ScopeSession -import org.jetbrains.kotlin.fir.resolve.SessionHolderImpl -import org.jetbrains.kotlin.fir.resolve.getSuperTypes -import org.jetbrains.kotlin.fir.resolve.toRegularClassSymbol +import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculatorForFullBodyResolve import org.jetbrains.kotlin.fir.scopes.impl.FirClassDeclaredMemberScope import org.jetbrains.kotlin.fir.scopes.impl.toConeType @@ -54,6 +53,7 @@ import org.jetbrains.kotlin.platform.isWasm import org.jetbrains.kotlin.platform.jvm.isJvm import org.jetbrains.kotlin.platform.konan.isNative import org.jetbrains.kotlin.types.ConstantValueKind +import java.util.* import java.util.concurrent.ConcurrentHashMap private data class CopiedTypeParameterPair( @@ -69,6 +69,8 @@ class SuspendTransformFirTransformer( session: FirSession, private val suspendTransformConfiguration: SuspendTransformConfiguration ) : FirDeclarationGenerationExtension(session) { + private val targetMarkerValueName = Name.identifier("value") + private val targetMarkerAnnotation = suspendTransformConfiguration.targetMarker?.toClassId() private data class FirCacheKey( val classSymbol: FirClassSymbol<*>, @@ -90,6 +92,7 @@ class SuspendTransformFirTransformer( override fun getCallableNamesForClass(classSymbol: FirClassSymbol<*>, context: MemberGenerationContext): Set { val names = mutableSetOf() + cache.getValue(FirCacheKey(classSymbol, context.declaredScope))?.forEach { (_, map) -> map.values.forEach { names.add(Name.identifier(it.annotationData.functionName)) } } @@ -103,6 +106,183 @@ class SuspendTransformFirTransformer( holder, ReturnTypeCalculatorForFullBodyResolve.Default, ) + private val expectActualContext = session.expectActualMatchingContextFactory.create(session, scope) + + /** + * 根据函数的名称、参数列表的各参数的类型计算一个hash字符串。 + */ + private fun FirSimpleFunction.calculateOriginFuncHash(): String { + val str = buildString { + append(name.asString()) + append(dispatchReceiverType.toString()) + append(receiverParameter?.typeRef?.coneTypeOrNull.toString()) + valueParameters.forEach { vp -> + append(vp.returnTypeRef.coneTypeOrNull.toString()) + } + } + + return Base64.getEncoder().encodeToString(str.toByteArray()) + } + + private fun FirSimpleFunctionBuilder.copyParameters() { + val funSymbol = symbol + val originalTypeParameterCache = mutableListOf() + + val newTypeParameters = typeParameters.map { + buildTypeParameterCopy(it) { + containingDeclarationSymbol = funSymbol // it.containingDeclarationSymbol +// symbol = it.symbol // FirTypeParameterSymbol() + symbol = FirTypeParameterSymbol() + }.also { new -> + originalTypeParameterCache.add(CopiedTypeParameterPair(it, new)) + } + } + typeParameters.clear() + typeParameters.addAll(newTypeParameters) + + val newValueParameters = valueParameters.map { vp -> + buildValueParameterCopy(vp) { + symbol = FirValueParameterSymbol(vp.symbol.name) + + val copiedConeType = vp.returnTypeRef.coneTypeOrNull + ?.copyWithTypeParameters(originalTypeParameterCache) + + if (copiedConeType != null) { + returnTypeRef = returnTypeRef.withReplacedConeType(copiedConeType) + } + } + } + valueParameters.clear() + valueParameters.addAll(newValueParameters) + + receiverParameter?.also { receiverParameter -> + receiverParameter.typeRef.coneTypeOrNull + ?.copyWithTypeParameters(originalTypeParameterCache) + ?.also { foundCopied -> + this.receiverParameter = buildReceiverParameterCopy(receiverParameter) { + typeRef = typeRef.withReplacedConeType(foundCopied) + } + } + } + + val coneTypeOrNull = returnTypeRef.coneTypeOrNull + if (coneTypeOrNull != null) { + returnTypeRef = returnTypeRef.withReplacedConeType( + coneTypeOrNull + .copyWithTypeParameters(originalTypeParameterCache) + ?: coneTypeOrNull, + ) + } + } + +// private fun FirSimpleFunction.copySyntheticFun( +// owner: FirClassSymbol<*>, +// callableId: CallableId +// ): FirSimpleFunction { +// val origin = this +// +// val marker = buildValueParameter { +// source = origin.source +// moduleData = origin.moduleData +// this.origin = origin.origin +// returnTypeRef = buildResolvedTypeRef { +// coneType = StandardTypes.Int +// source = null +// } +// name = Name.identifier("__test_marker") +// symbol = FirValueParameterSymbol(name) +// defaultValue = buildLiteralExpression(null, ConstantValueKind.Int, 1, null, setType = true) +// containingFunctionSymbol = origin.symbol +// backingField = null +// isCrossinline = false +// isNoinline = false +// isVararg = false +// } +// +// val syntheticFun = buildSimpleFunctionCopy(this) { +// this.origin = FirDeclarationOrigin.Synthetic.FakeFunction +// name = callableId.callableName +// symbol = FirNamedFunctionSymbol(callableId) +// status = origin.status.copy( +// modality = Modality.OPEN, +// isOverride = false, +// visibility = Visibilities.Public +// ) +// +// copyParameters() +// +// this.valueParameters.add(0, marker) +// +// val builder = this +// +// body = buildSingleExpressionBlock( +// buildReturnExpression { +// target = FirFunctionTarget(null, false) +// result = buildFunctionCall { +// source = origin.source +// calleeReference = buildResolvedNamedReference { +// source = origin.source +// name = origin.name +// resolvedSymbol = origin.symbol +// } +// // TODO contextReceiverArguments +// +// argumentList = buildResolvedArgumentList( +// null, +// builder.valueParameters.associateByTo(LinkedHashMap()) { valueParameter -> +// buildCallableReferenceAccess { +// source = valueParameter.source +// calleeReference = buildResolvedNamedReference { +// source = valueParameter.source +// name = valueParameter.name +// resolvedSymbol = valueParameter.symbol +// } +// coneTypeOrNull = valueParameter.returnTypeRef.coneTypeOrNull +// } +// }) +// } +// } +// ) +// +// } +// +// syntheticFun.excludeFromJsExport(session) +// syntheticFun.jvmSynthetic(session) +// +// return syntheticFun +// } + + private fun FirSimpleFunction.appendTargetMarker(markerId: String) { + if (targetMarkerAnnotation != null) { + if (annotations.none { + it.fqName(session) == targetMarkerAnnotation.asSingleFqName() + && (it.argumentMapping.mapping[targetMarkerValueName] as? FirLiteralExpression) + ?.value == markerId + }) { + replaceAnnotations( + buildList { + addAll(annotations) + add(buildAnnotation { + argumentMapping = buildAnnotationArgumentMapping { + mapping[Name.identifier("value")] = buildLiteralExpression( + null, + ConstantValueKind.String, + markerId, + null, + true, + null + ) + } + annotationTypeRef = buildResolvedTypeRef { + coneType = targetMarkerAnnotation.createConeType(session) + } + }) + } + ) + } + } + + } @OptIn(SymbolInternals::class) override fun generateFunctions( @@ -114,7 +294,7 @@ class SuspendTransformFirTransformer( ?.get(callableId.callableName) ?: return emptyList() - val funList = mutableListOf() + val funList = arrayListOf() funcMap.forEach { (func, funData) -> @@ -127,10 +307,34 @@ class SuspendTransformFirTransformer( val originFunc = func.fir + val uniqueFunHash = originFunc.calculateOriginFuncHash() + + // TODO 生成一个合成函数用来代替 originFunc, 然后其他生成的桥接函数都使用这个合成的函数而不是源函数。 + +// val syntheticFunCallableName = callableId.callableName.asString() + "-f-${uniqueFunHash}" +// val syntheticFunName = callableId.copy(Name.identifier(syntheticFunCallableName)) +// val syntheticFun = originFunc.copySyntheticFun(owner, callableId) +// funList.add(syntheticFun.symbol) + val (functionAnnotations, _) = copyAnnotations(originFunc, funData) val newFunSymbol = FirNamedFunctionSymbol(callableId) + val key = SuspendTransformPluginKey( + data = SuspendTransformUserDataFir( + markerId = uniqueFunHash, + originSymbol = originFunc.symbol.asOriginSymbol( + targetMarkerAnnotation, + typeParameters = originFunc.typeParameters, + valueParameters = originFunc.valueParameters, + originFunc.returnTypeRef.coneTypeOrNull?.classId, + session, + ), + asProperty = false, + transformer = funData.transformer + ) + ) + val newFun = buildSimpleFunctionCopy(originFunc) { name = callableId.callableName symbol = newFunSymbol @@ -155,49 +359,7 @@ class SuspendTransformFirTransformer( // 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 copy to value parameters, receiver and return type? - val originalTypeParameterCache = mutableListOf() - typeParameters.replaceAll { - buildTypeParameterCopy(it) { - containingDeclarationSymbol = newFunSymbol // it.containingDeclarationSymbol -// symbol = it.symbol // FirTypeParameterSymbol() - symbol = FirTypeParameterSymbol() - }.also { new -> - originalTypeParameterCache.add(CopiedTypeParameterPair(it, new)) - } - } - - valueParameters.replaceAll { vp -> - buildValueParameterCopy(vp) { - symbol = FirValueParameterSymbol(vp.symbol.name) - - val copiedConeType = vp.returnTypeRef.coneTypeOrNull - ?.copyWithTypeParameters(originalTypeParameterCache) - - if (copiedConeType != null) { - returnTypeRef = returnTypeRef.withReplacedConeType(copiedConeType) - } - } - } - - receiverParameter?.also { receiverParameter -> - receiverParameter.typeRef.coneTypeOrNull - ?.copyWithTypeParameters(originalTypeParameterCache) - ?.also { foundCopied -> - this.receiverParameter = buildReceiverParameterCopy(receiverParameter) { - typeRef = typeRef.withReplacedConeType(foundCopied) - } - } - } - - - val coneTypeOrNull = returnTypeRef.coneTypeOrNull - if (coneTypeOrNull != null) { - returnTypeRef = returnTypeRef.withReplacedConeType( - coneTypeOrNull - .copyWithTypeParameters(originalTypeParameterCache) - ?: coneTypeOrNull, - ) - } + copyParameters() annotations.clear() annotations.addAll(functionAnnotations) @@ -207,17 +369,68 @@ class SuspendTransformFirTransformer( returnTypeRef = returnType - origin = SuspendTransformPluginKey( - data = SuspendTransformUserDataFir( - originSymbol = originFunc.symbol.asOriginSymbol( - typeParameters = originFunc.typeParameters, - valueParameters = originFunc.valueParameters, - originFunc.returnTypeRef.coneTypeOrNull?.classId - ), - asProperty = false, - transformer = funData.transformer - ) - ).origin + // TODO 是否可以在FIR中就完成Body的构建? +// buildBlock { +// // build lambda +// val lambda = buildAnonymousFunctionExpression { +// anonymousFunction = buildAnonymousFunction { +// moduleData = originFunc.moduleData +// origin = key.origin +// status = FirResolvedDeclarationStatusImpl.DEFAULT_STATUS_FOR_SUSPEND_FUNCTION_EXPRESSION +// returnTypeRef = originFunc.returnTypeRef +// isLambda = true +// body = buildSingleExpressionBlock( +// buildReturnExpression { +// result = buildFunctionCall { +//// explicitReceiver = this@createConventionCall +// calleeReference = buildResolvedNamedReference { +// source = originFunc.source +// name = originFunc.name +// resolvedSymbol = originFunc.symbol +// } +// +// argumentList = buildResolvedArgumentList(null, +// this@buildSimpleFunctionCopy.valueParameters.associateByTo(LinkedHashMap()) { valueParameter -> +// buildCallableReferenceAccess { +// source = valueParameter.source +// calleeReference = buildResolvedNamedReference { +// source = valueParameter.source +// name = valueParameter.name +// resolvedSymbol = valueParameter.symbol +// } +// coneTypeOrNull = valueParameter.returnTypeRef.coneTypeOrNull +// } +// } +// ) +// } +// } +// ) +// symbol = FirAnonymousFunctionSymbol() +// } +// } +// lambda +// +// +// /* +// fun xxxBlock() = transformFun({ orignFun }, ) +// */ +// statements.add( +// buildReturnExpression { +// +// +// } +// ) +// +// buildFunctionCall { +// this +// } +// } + + origin = key.origin + } + + if (targetMarkerAnnotation != null) { + originFunc.appendTargetMarker(uniqueFunHash) } funList.add(newFun.symbol) @@ -247,6 +460,8 @@ class SuspendTransformFirTransformer( // generate val original = func.fir + val uniqueFunHash = original.calculateOriginFuncHash() + val (functionAnnotations, propertyAnnotations) = copyAnnotations(original, funData) @@ -279,10 +494,13 @@ class SuspendTransformFirTransformer( val pSymbol = FirPropertySymbol(callableId) val pKey = SuspendTransformPluginKey( data = SuspendTransformUserDataFir( + markerId = uniqueFunHash, originSymbol = original.symbol.asOriginSymbol( + targetMarkerAnnotation, typeParameters = original.typeParameters, valueParameters = original.valueParameters, - original.returnTypeRef.coneTypeOrNull?.classId + original.returnTypeRef.coneTypeOrNull?.classId, + session ), asProperty = true, transformer = funData.transformer @@ -365,6 +583,10 @@ class SuspendTransformFirTransformer( } propList.add(p1.symbol) + + if (targetMarkerAnnotation != null) { + original.appendTargetMarker(uniqueFunHash) + } } } @@ -598,7 +820,7 @@ class SuspendTransformFirTransformer( if (copyFunction) { val notCompileAnnotationsCopied = original.annotations.filterNot { val annotationClassId = it.toAnnotationClassId(session) ?: return@filterNot true - excludes.any { ex -> annotationClassId == ex } + annotationClassId == targetMarkerAnnotation || excludes.any { ex -> annotationClassId == ex } } /* diff --git a/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/ir/SuspendTransformTransformer.kt b/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/ir/SuspendTransformTransformer.kt index ddb5398..5f9888f 100644 --- a/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/ir/SuspendTransformTransformer.kt +++ b/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/ir/SuspendTransformTransformer.kt @@ -92,7 +92,7 @@ class SuspendTransformTransformer( pluginKey, declaration, { f -> - pluginKey.data.originSymbol.checkSame(f) + pluginKey.data.originSymbol.checkSame(pluginKey.data.markerId, f) }, callableFunction )?.also { generatedOriginFunction -> @@ -255,12 +255,14 @@ class SuspendTransformTransformer( originFunction.reportLocation() ?: function.reportLocation() ) - function.body = generateTransformBodyForFunctionLambda( - pluginContext, - function, - originFunction, - transformTargetFunctionCall - ) + if (function.body == null) { + function.body = generateTransformBodyForFunctionLambda( + pluginContext, + function, + originFunction, + transformTargetFunctionCall + ) + } return originFunction } diff --git a/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/utils/FirUtils.kt b/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/utils/FirUtils.kt new file mode 100644 index 0000000..8db1b49 --- /dev/null +++ b/compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/utils/FirUtils.kt @@ -0,0 +1,71 @@ +package love.forte.plugin.suspendtrans.utils + +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.expressions.FirEmptyArgumentList +import org.jetbrains.kotlin.fir.expressions.builder.buildAnnotationCall +import org.jetbrains.kotlin.fir.moduleData +import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference +import org.jetbrains.kotlin.fir.resolve.defaultType +import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider +import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.platform.isJs +import org.jetbrains.kotlin.platform.jvm.isJvm +import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull + +private val jsExportIgnore = ClassId.fromString("kotlin/js/JsExport.Ignore") +private val jvmSynthetic = ClassId.fromString("kotlin/jvm/JvmSynthetic") + +fun FirDeclaration.excludeFromJsExport(session: FirSession) { + if (!session.moduleData.platform.isJs()) { + return + } + val jsExportIgnore = session.symbolProvider.getClassLikeSymbolByClassId(jsExportIgnore) + val jsExportIgnoreAnnotation = jsExportIgnore as? FirRegularClassSymbol ?: return + val jsExportIgnoreConstructor = + jsExportIgnoreAnnotation.declarationSymbols.firstIsInstanceOrNull() ?: return + + val jsExportIgnoreAnnotationCall = buildAnnotationCall { + argumentList = FirEmptyArgumentList + annotationTypeRef = buildResolvedTypeRef { + coneType = jsExportIgnoreAnnotation.defaultType() + } + calleeReference = buildResolvedNamedReference { + name = jsExportIgnoreAnnotation.name + resolvedSymbol = jsExportIgnoreConstructor + } + + containingDeclarationSymbol = this@excludeFromJsExport.symbol + } + + replaceAnnotations(annotations + jsExportIgnoreAnnotationCall) +} + +fun FirDeclaration.jvmSynthetic(session: FirSession) { + if (!session.moduleData.platform.isJvm()) { + return + } + + val jvmSynthetic = session.symbolProvider.getClassLikeSymbolByClassId(jvmSynthetic) + val jvmExportIgnoreAnnotation = jvmSynthetic as? FirRegularClassSymbol ?: return + val jvmExportIgnoreConstructor = + jvmExportIgnoreAnnotation.declarationSymbols.firstIsInstanceOrNull() ?: return + + val jvmSyntheticAnnotationCall = buildAnnotationCall { + argumentList = FirEmptyArgumentList + annotationTypeRef = buildResolvedTypeRef { + coneType = jvmExportIgnoreAnnotation.defaultType() + } + calleeReference = buildResolvedNamedReference { + name = jvmExportIgnoreAnnotation.name + resolvedSymbol = jvmExportIgnoreConstructor + } + + containingDeclarationSymbol = this@jvmSynthetic.symbol + } + + replaceAnnotations(annotations + jvmSyntheticAnnotationCall) +} diff --git a/compiler/suspend-transform-plugin/src/test-gen/love/forte/plugin/suspendtrans/runners/CodeGenTestRunnerGenerated.java b/compiler/suspend-transform-plugin/src/test-gen/love/forte/plugin/suspendtrans/runners/CodeGenTestRunnerGenerated.java index 91136d7..d1eb602 100644 --- a/compiler/suspend-transform-plugin/src/test-gen/love/forte/plugin/suspendtrans/runners/CodeGenTestRunnerGenerated.java +++ b/compiler/suspend-transform-plugin/src/test-gen/love/forte/plugin/suspendtrans/runners/CodeGenTestRunnerGenerated.java @@ -61,4 +61,10 @@ public void testImplOverriden() { public void testImplOverridenGeneric() { runTest("src/testData/codegen/implOverridenGeneric.kt"); } + + @Test + @TestMetadata("alias.kt") + public void testAlias() { + runTest("src/testData/codegen/alias.kt"); + } } diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/alias.asm.txt b/compiler/suspend-transform-plugin/src/testData/codegen/alias.asm.txt new file mode 100644 index 0000000..951b4c3 --- /dev/null +++ b/compiler/suspend-transform-plugin/src/testData/codegen/alias.asm.txt @@ -0,0 +1,49 @@ +public final class MainKt : java/lang/Object { + +} + +final class MyClass$errorReproductionAsync$1 : kotlin/coroutines/jvm/internal/SuspendLambda, kotlin/jvm/functions/Function1 { + final long $amount + + int label + + final MyClass this$0 + + void (MyClass $receiver, long $amount, kotlin.coroutines.Continuation p2) + + public final kotlin.coroutines.Continuation create(kotlin.coroutines.Continuation $completion) + + public final java.lang.Object invoke(kotlin.coroutines.Continuation p1) + + public java.lang.Object invoke(java.lang.Object p1) + + public final java.lang.Object invokeSuspend(java.lang.Object $result) +} + +final class MyClass$errorReproductionBlocking$1 : kotlin/coroutines/jvm/internal/SuspendLambda, kotlin/jvm/functions/Function1 { + final long $amount + + int label + + final MyClass this$0 + + void (MyClass $receiver, long $amount, kotlin.coroutines.Continuation p2) + + public final kotlin.coroutines.Continuation create(kotlin.coroutines.Continuation $completion) + + public final java.lang.Object invoke(kotlin.coroutines.Continuation p1) + + public java.lang.Object invoke(java.lang.Object p1) + + public final java.lang.Object invokeSuspend(java.lang.Object $result) +} + +public final class MyClass : java/lang/Object { + public void () + + public final java.lang.Object errorReproduction(long amount, kotlin.coroutines.Continuation p1) + + public final java.util.concurrent.CompletableFuture errorReproductionAsync(long amount) + + public final void errorReproductionBlocking(long amount) +} diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/alias.fir.ir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/alias.fir.ir.txt new file mode 100644 index 0000000..dd3bc1b --- /dev/null +++ b/compiler/suspend-transform-plugin/src/testData/codegen/alias.fir.ir.txt @@ -0,0 +1,64 @@ +FILE fqName: fileName:/Main.kt + CLASS CLASS name:MyClass modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyClass + CONSTRUCTOR visibility:public <> () returnType:.MyClass [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MyClass 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 + FUN GENERATED[love.forte.plugin.suspendtrans.fir.SuspendTransformPluginKey] name:errorReproductionAsync visibility:public modality:FINAL <> ($this:.MyClass, amount:kotlin.Long) returnType:java.util.concurrent.CompletableFuture + annotations: + Api4J + $this: VALUE_PARAMETER name: type:.MyClass + VALUE_PARAMETER name:amount index:0 type:kotlin.Long + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun errorReproductionAsync (amount: kotlin.Long): java.util.concurrent.CompletableFuture declared in .MyClass' + 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 .MyClass.errorReproductionAsync' + CALL 'public final fun errorReproduction (amount: kotlin.Long): kotlin.Unit declared in .MyClass' type=kotlin.Unit origin=null + $this: GET_VAR ': .MyClass declared in .MyClass.errorReproductionAsync' type=.MyClass origin=null + amount: GET_VAR 'amount: kotlin.Long declared in .MyClass.errorReproductionAsync' type=kotlin.Long origin=null + FUN GENERATED[love.forte.plugin.suspendtrans.fir.SuspendTransformPluginKey] name:errorReproductionBlocking visibility:public modality:FINAL <> ($this:.MyClass, amount:kotlin.Long) returnType:kotlin.Unit + annotations: + Api4J + $this: VALUE_PARAMETER name: type:.MyClass + VALUE_PARAMETER name:amount index:0 type:kotlin.Long + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun errorReproductionBlocking (amount: kotlin.Long): kotlin.Unit declared in .MyClass' + 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 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend] + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .MyClass.errorReproductionBlocking' + CALL 'public final fun errorReproduction (amount: kotlin.Long): kotlin.Unit declared in .MyClass' type=kotlin.Unit origin=null + $this: GET_VAR ': .MyClass declared in .MyClass.errorReproductionBlocking' type=.MyClass origin=null + amount: GET_VAR 'amount: kotlin.Long declared in .MyClass.errorReproductionBlocking' type=kotlin.Long origin=null + FUN name:errorReproduction visibility:public modality:FINAL <> ($this:.MyClass, amount:kotlin.Long) returnType:kotlin.Unit [suspend] + annotations: + JvmBlocking(baseName = , suffix = , asProperty = ) + JvmAsync(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZXJyb3JSZXByb2R1Y3Rpb25NeUNsYXNzbnVsbHtNb25leVZhbHVlPX0ga290bGluL0xvbmc=") + JvmSynthetic + $this: VALUE_PARAMETER name: type:.MyClass + VALUE_PARAMETER name:amount index:0 type:kotlin.Long + BLOCK_BODY + CALL 'public final fun println (message: kotlin.Long): kotlin.Unit declared in kotlin.io' type=kotlin.Unit origin=null + message: GET_VAR 'amount: kotlin.Long declared in .MyClass.errorReproduction' type=kotlin.Long origin=null + TYPEALIAS name:MoneyValue visibility:public expandedType:kotlin.Long diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/alias.fir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/alias.fir.txt new file mode 100644 index 0000000..dee753c --- /dev/null +++ b/compiler/suspend-transform-plugin/src/testData/codegen/alias.fir.txt @@ -0,0 +1,16 @@ +FILE: Main.kt + public final typealias MoneyValue = R|kotlin/Long| + public final class MyClass : R|kotlin/Any| { + public constructor(): R|MyClass| { + super() + } + + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZXJyb3JSZXByb2R1Y3Rpb25NeUNsYXNzbnVsbHtNb25leVZhbHVlPX0ga290bGluL0xvbmc=)) public final suspend fun errorReproduction(amount: R|{MoneyValue=} kotlin/Long|): R|kotlin/Unit| { + R|kotlin/io/println|(R|/amount|) + } + + @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public final fun errorReproductionAsync(amount: R|{MoneyValue=} kotlin/Long|): R|java/util/concurrent/CompletableFuture| + + @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public final fun errorReproductionBlocking(amount: R|{MoneyValue=} kotlin/Long|): R|kotlin/Unit| + + } diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/alias.kt b/compiler/suspend-transform-plugin/src/testData/codegen/alias.kt new file mode 100644 index 0000000..ed0adc2 --- /dev/null +++ b/compiler/suspend-transform-plugin/src/testData/codegen/alias.kt @@ -0,0 +1,16 @@ +// FIR_DUMP +// DUMP_IR +// SOURCE +// FILE: Main.kt [MainKt#main] + +import kotlinx.coroutines.runBlocking +import love.forte.plugin.suspendtrans.annotation.JvmAsync +import love.forte.plugin.suspendtrans.annotation.JvmBlocking + +typealias MoneyValue = Long + +class MyClass { + @JvmBlocking + @JvmAsync + suspend fun errorReproduction(amount: MoneyValue) { println(amount) } +} diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/asProperty.fir.ir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/asProperty.fir.ir.txt index 8236bb4..94fc8b0 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/asProperty.fir.ir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/asProperty.fir.ir.txt @@ -22,6 +22,7 @@ FILE fqName: fileName:/Main.kt annotations: JvmBlocking(baseName = , suffix = "", asProperty = true) JvmAsync(baseName = , suffix = , asProperty = true) + TargetMarker(value = "cHJvcFByb3BGb29udWxs") JvmSynthetic $this: VALUE_PARAMETER name: type:.PropFoo BLOCK_BODY @@ -86,6 +87,7 @@ FILE fqName: fileName:/Main.kt annotations: JvmBlocking(baseName = , suffix = "", asProperty = true) JvmAsync(baseName = , suffix = , asProperty = true) + TargetMarker(value = "cHJvcFByb3BJbXBsbnVsbA==") JvmSynthetic overridden: public abstract fun prop (): kotlin.String declared in .IProp @@ -156,6 +158,7 @@ FILE fqName: fileName:/Main.kt annotations: JvmBlocking(baseName = , suffix = "", asProperty = true) JvmAsync(baseName = , suffix = , asProperty = true) + TargetMarker(value = "cHJvcElQcm9wbnVsbA==") JvmSynthetic $this: VALUE_PARAMETER name: type:.IProp PROPERTY GENERATED[love.forte.plugin.suspendtrans.fir.SuspendTransformPluginKey] name:prop visibility:public modality:OPEN [val] diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/asProperty.fir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/asProperty.fir.txt index 9aa9126..8e4a88a 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/asProperty.fir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/asProperty.fir.txt @@ -4,7 +4,7 @@ FILE: Main.kt super() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|(asProperty = Boolean(true), suffix = String()) @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|(asProperty = Boolean(true)) public final suspend fun prop(): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|(asProperty = Boolean(true), suffix = String()) @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|(asProperty = Boolean(true)) @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(cHJvcFByb3BGb29udWxs)) public final suspend fun prop(): R|kotlin/String| { ^prop String() } @@ -16,7 +16,7 @@ FILE: Main.kt } public abstract interface IProp : R|kotlin/Any| { - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|(asProperty = Boolean(true), suffix = String()) @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|(asProperty = Boolean(true)) public abstract suspend fun prop(): R|kotlin/String| + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|(asProperty = Boolean(true), suffix = String()) @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|(asProperty = Boolean(true)) @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(cHJvcElQcm9wbnVsbA==)) public abstract suspend fun prop(): R|kotlin/String| @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public open val prop: R|kotlin/String| @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public get(): R|kotlin/String| @@ -30,7 +30,7 @@ FILE: Main.kt super() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|(asProperty = Boolean(true), suffix = String()) @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|(asProperty = Boolean(true)) public open override suspend fun prop(): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|(asProperty = Boolean(true), suffix = String()) @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|(asProperty = Boolean(true)) @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(cHJvcFByb3BJbXBsbnVsbA==)) public open override suspend fun prop(): R|kotlin/String| { ^prop String() } diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/basic.fir.ir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/basic.fir.ir.txt index 530ed83..e81cdb2 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/basic.fir.ir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/basic.fir.ir.txt @@ -51,6 +51,7 @@ FILE fqName: fileName:/Main.kt FUN name:bar visibility:public modality:FINAL <> ($this:.BasicBar) returnType:kotlin.String [suspend] annotations: JvmAsync(baseName = , suffix = , asProperty = ) + TargetMarker(value = "YmFyQmFzaWNCYXJudWxs") JvmSynthetic $this: VALUE_PARAMETER name: type:.BasicBar BLOCK_BODY @@ -59,6 +60,7 @@ FILE fqName: fileName:/Main.kt FUN name:bar2 visibility:public modality:FINAL <> ($this:.BasicBar, i:kotlin.Int) returnType:kotlin.String [suspend] annotations: JvmAsync(baseName = , suffix = , asProperty = ) + TargetMarker(value = "YmFyMkJhc2ljQmFybnVsbGtvdGxpbi9JbnQ=") JvmSynthetic $this: VALUE_PARAMETER name: type:.BasicBar VALUE_PARAMETER name:i index:0 type:kotlin.Int @@ -101,6 +103,7 @@ FILE fqName: fileName:/Main.kt FUN name:foo visibility:public modality:FINAL <> ($this:.BasicFoo) returnType:kotlin.String [suspend] annotations: JvmAsync(baseName = , suffix = , asProperty = ) + TargetMarker(value = "Zm9vQmFzaWNGb29udWxs") JvmSynthetic $this: VALUE_PARAMETER name: type:.BasicFoo BLOCK_BODY @@ -177,11 +180,13 @@ FILE fqName: fileName:/Main.kt FUN name:bar visibility:public modality:ABSTRACT <> ($this:.InterfaceBar) returnType:kotlin.String [suspend] annotations: JvmAsync(baseName = , suffix = , asProperty = ) + TargetMarker(value = "YmFySW50ZXJmYWNlQmFybnVsbA==") JvmSynthetic $this: VALUE_PARAMETER name: type:.InterfaceBar FUN name:bar2 visibility:public modality:ABSTRACT <> ($this:.InterfaceBar, i:kotlin.Int) returnType:kotlin.String [suspend] annotations: JvmAsync(baseName = , suffix = , asProperty = ) + TargetMarker(value = "YmFyMkludGVyZmFjZUJhcm51bGxrb3RsaW4vSW50") JvmSynthetic $this: VALUE_PARAMETER name: type:.InterfaceBar VALUE_PARAMETER name:i index:0 type:kotlin.Int diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/basic.fir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/basic.fir.txt index 61ce273..ca0b8f6 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/basic.fir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/basic.fir.txt @@ -4,7 +4,7 @@ FILE: Main.kt super() } - @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() public final suspend fun foo(): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(Zm9vQmFzaWNGb29udWxs)) public final suspend fun foo(): R|kotlin/String| { ^foo String(foo) } @@ -16,11 +16,11 @@ FILE: Main.kt super() } - @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() public final suspend fun bar(): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(YmFyQmFzaWNCYXJudWxs)) public final suspend fun bar(): R|kotlin/String| { ^bar String(bar) } - @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() public final suspend fun bar2(i: R|kotlin/Int|): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(YmFyMkJhc2ljQmFybnVsbGtvdGxpbi9JbnQ=)) public final suspend fun bar2(i: R|kotlin/Int|): R|kotlin/String| { ^bar2 String(bar2) } @@ -30,9 +30,9 @@ FILE: Main.kt } public abstract interface InterfaceBar : R|kotlin/Any| { - @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() public abstract suspend fun bar(): R|kotlin/String| + @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(YmFySW50ZXJmYWNlQmFybnVsbA==)) public abstract suspend fun bar(): R|kotlin/String| - @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() public abstract suspend fun bar2(i: R|kotlin/Int|): R|kotlin/String| + @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(YmFyMkludGVyZmFjZUJhcm51bGxrb3RsaW4vSW50)) public abstract suspend fun bar2(i: R|kotlin/Int|): R|kotlin/String| public abstract fun asyncBase(i: R|kotlin/Int|): R|ResultValue| diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/implOverriden.fir.ir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/implOverriden.fir.ir.txt index ef44f46..2dae78c 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/implOverriden.fir.ir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/implOverriden.fir.ir.txt @@ -67,6 +67,7 @@ FILE fqName: fileName:/Main.kt FUN name:data visibility:public modality:OPEN <> ($this:.FooInterface1Impl) returnType:kotlin.String [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YUZvb0ludGVyZmFjZTFJbXBsbnVsbA==") JvmSynthetic overridden: public abstract fun data (): kotlin.String declared in .FooInterface1 @@ -77,6 +78,7 @@ FILE fqName: fileName:/Main.kt FUN name:data2 visibility:public modality:OPEN <> ($this:.FooInterface1Impl, value:kotlin.Int) returnType:kotlin.String [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTJGb29JbnRlcmZhY2UxSW1wbG51bGxrb3RsaW4vSW50") JvmSynthetic overridden: public abstract fun data2 (value: kotlin.Int): kotlin.String declared in .FooInterface1 @@ -88,6 +90,7 @@ FILE fqName: fileName:/Main.kt FUN name:data3 visibility:public modality:OPEN <> ($this:.FooInterface1Impl, $receiver:kotlin.Int) returnType:kotlin.String [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTNGb29JbnRlcmZhY2UxSW1wbGtvdGxpbi9JbnQ=") JvmSynthetic overridden: public abstract fun data3 (): kotlin.String declared in .FooInterface1 @@ -170,6 +173,7 @@ FILE fqName: fileName:/Main.kt FUN name:data visibility:public modality:OPEN <> ($this:.FooInterface2Impl) returnType:kotlin.String [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YUZvb0ludGVyZmFjZTJJbXBsbnVsbA==") JvmSynthetic overridden: public abstract fun data (): kotlin.String declared in .FooInterface2 @@ -180,6 +184,7 @@ FILE fqName: fileName:/Main.kt FUN name:data2 visibility:public modality:OPEN <> ($this:.FooInterface2Impl, value:kotlin.Int) returnType:kotlin.String [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTJGb29JbnRlcmZhY2UySW1wbG51bGxrb3RsaW4vSW50") JvmSynthetic overridden: public abstract fun data2 (value: kotlin.Int): kotlin.String declared in .FooInterface2 @@ -191,6 +196,7 @@ FILE fqName: fileName:/Main.kt FUN name:data3 visibility:public modality:OPEN <> ($this:.FooInterface2Impl, $receiver:kotlin.Int) returnType:kotlin.String [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTNGb29JbnRlcmZhY2UySW1wbGtvdGxpbi9JbnQ=") JvmSynthetic overridden: public abstract fun data3 (): kotlin.String declared in .FooInterface2 @@ -221,6 +227,7 @@ FILE fqName: fileName:/Main.kt FUN name:data visibility:public modality:OPEN <> ($this:.FooInterface3Impl) returnType:kotlin.String [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = true) + TargetMarker(value = "ZGF0YUZvb0ludGVyZmFjZTNJbXBsbnVsbA==") JvmSynthetic overridden: public abstract fun data (): kotlin.String declared in .FooInterface3 @@ -306,6 +313,7 @@ FILE fqName: fileName:/Main.kt FUN name:data visibility:public modality:OPEN <> ($this:.FooInterface4Impl) returnType:kotlin.String [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YUZvb0ludGVyZmFjZTRJbXBsbnVsbA==") JvmSynthetic overridden: public abstract fun data (): kotlin.String declared in .FooInterface4 @@ -316,6 +324,7 @@ FILE fqName: fileName:/Main.kt FUN name:data2 visibility:public modality:OPEN <> ($this:.FooInterface4Impl, value:kotlin.Int) returnType:kotlin.String [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTJGb29JbnRlcmZhY2U0SW1wbG51bGxrb3RsaW4vSW50") JvmSynthetic overridden: public abstract fun data2 (value: kotlin.Int): kotlin.String declared in .FooInterface4 @@ -459,11 +468,13 @@ FILE fqName: fileName:/Main.kt FUN name:data visibility:public modality:ABSTRACT <> ($this:.FooInterface4) returnType:kotlin.String [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YUZvb0ludGVyZmFjZTRudWxs") JvmSynthetic $this: VALUE_PARAMETER name: type:.FooInterface4 FUN name:data2 visibility:public modality:ABSTRACT <> ($this:.FooInterface4, value:kotlin.Int) returnType:kotlin.String [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTJGb29JbnRlcmZhY2U0bnVsbGtvdGxpbi9JbnQ=") JvmSynthetic $this: VALUE_PARAMETER name: type:.FooInterface4 VALUE_PARAMETER name:value index:0 type:kotlin.Int diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/implOverriden.fir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/implOverriden.fir.txt index 7958223..95b1784 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/implOverriden.fir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/implOverriden.fir.txt @@ -12,15 +12,15 @@ FILE: Main.kt super() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data(): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YUZvb0ludGVyZmFjZTFJbXBsbnVsbA==)) public open override suspend fun data(): R|kotlin/String| { ^data String() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data2(value: R|kotlin/Int|): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTJGb29JbnRlcmZhY2UxSW1wbG51bGxrb3RsaW4vSW50)) public open override suspend fun data2(value: R|kotlin/Int|): R|kotlin/String| { ^data2 String() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun R|kotlin/Int|.data3(): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTNGb29JbnRlcmZhY2UxSW1wbGtvdGxpbi9JbnQ=)) public open override suspend fun R|kotlin/Int|.data3(): R|kotlin/String| { ^data3 String() } @@ -56,15 +56,15 @@ FILE: Main.kt super() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data(): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YUZvb0ludGVyZmFjZTJJbXBsbnVsbA==)) public open override suspend fun data(): R|kotlin/String| { ^data String() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data2(value: R|kotlin/Int|): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTJGb29JbnRlcmZhY2UySW1wbG51bGxrb3RsaW4vSW50)) public open override suspend fun data2(value: R|kotlin/Int|): R|kotlin/String| { ^data2 String() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun R|kotlin/Int|.data3(): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTNGb29JbnRlcmZhY2UySW1wbGtvdGxpbi9JbnQ=)) public open override suspend fun R|kotlin/Int|.data3(): R|kotlin/String| { ^data3 String() } @@ -89,7 +89,7 @@ FILE: Main.kt super() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|(asProperty = Boolean(true)) public open override suspend fun data(): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|(asProperty = Boolean(true)) @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YUZvb0ludGVyZmFjZTNJbXBsbnVsbA==)) public open override suspend fun data(): R|kotlin/String| { ^data String() } @@ -98,9 +98,9 @@ FILE: Main.kt } public abstract interface FooInterface4 : R|kotlin/Any| { - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public abstract suspend fun data(): R|kotlin/String| + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YUZvb0ludGVyZmFjZTRudWxs)) public abstract suspend fun data(): R|kotlin/String| - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public abstract suspend fun data2(value: R|kotlin/Int|): R|kotlin/String| + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTJGb29JbnRlcmZhY2U0bnVsbGtvdGxpbi9JbnQ=)) public abstract suspend fun data2(value: R|kotlin/Int|): R|kotlin/String| @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public open fun data2Blocking(value: R|kotlin/Int|): R|kotlin/String| @@ -112,11 +112,11 @@ FILE: Main.kt super() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data(): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YUZvb0ludGVyZmFjZTRJbXBsbnVsbA==)) public open override suspend fun data(): R|kotlin/String| { ^data String() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data2(value: R|kotlin/Int|): R|kotlin/String| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTJGb29JbnRlcmZhY2U0SW1wbG51bGxrb3RsaW4vSW50)) public open override suspend fun data2(value: R|kotlin/Int|): R|kotlin/String| { ^data2 String() } diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/implOverridenGeneric.fir.ir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/implOverridenGeneric.fir.ir.txt index 76ed5eb..7b2e294 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/implOverridenGeneric.fir.ir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/implOverridenGeneric.fir.ir.txt @@ -70,6 +70,7 @@ FILE fqName: fileName:/Main.kt FUN name:data visibility:public modality:OPEN <> ($this:.FooInterface1Impl.FooInterface1Impl>) returnType:T of .FooInterface1Impl [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YUZvb0ludGVyZmFjZTFJbXBsPFQ+bnVsbA==") JvmSynthetic overridden: public abstract fun data (): T of .FooInterface1 declared in .FooInterface1 @@ -80,6 +81,7 @@ FILE fqName: fileName:/Main.kt FUN name:data2 visibility:public modality:OPEN ($this:.FooInterface1Impl.FooInterface1Impl>, value:A of .FooInterface1Impl.data2) returnType:T of .FooInterface1Impl [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTJGb29JbnRlcmZhY2UxSW1wbDxUPm51bGxB") JvmSynthetic overridden: public abstract fun data2 (value: A of .FooInterface1.data2): T of .FooInterface1 declared in .FooInterface1 @@ -92,6 +94,7 @@ FILE fqName: fileName:/Main.kt FUN name:data3 visibility:public modality:OPEN <> ($this:.FooInterface1Impl.FooInterface1Impl>, $receiver:kotlin.Int) returnType:T of .FooInterface1Impl [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTNGb29JbnRlcmZhY2UxSW1wbDxUPmtvdGxpbi9JbnQ=") JvmSynthetic overridden: public abstract fun data3 (): T of .FooInterface1 declared in .FooInterface1 @@ -169,6 +172,7 @@ FILE fqName: fileName:/Main.kt FUN name:data visibility:public modality:OPEN <> ($this:.FooInterface2Impl.FooInterface2Impl>) returnType:T of .FooInterface2Impl [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YUZvb0ludGVyZmFjZTJJbXBsPFQ+bnVsbA==") JvmSynthetic overridden: public abstract fun data (): T of .FooInterface2 declared in .FooInterface2 @@ -179,6 +183,7 @@ FILE fqName: fileName:/Main.kt FUN name:data2 visibility:public modality:OPEN <> ($this:.FooInterface2Impl.FooInterface2Impl>, value:T of .FooInterface2Impl) returnType:T of .FooInterface2Impl [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTJGb29JbnRlcmZhY2UySW1wbDxUPm51bGxU") JvmSynthetic overridden: public abstract fun data2 (value: T of .FooInterface2): T of .FooInterface2 declared in .FooInterface2 @@ -190,6 +195,7 @@ FILE fqName: fileName:/Main.kt FUN name:data3 visibility:public modality:OPEN <> ($this:.FooInterface2Impl.FooInterface2Impl>, $receiver:kotlin.Int) returnType:T of .FooInterface2Impl [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTNGb29JbnRlcmZhY2UySW1wbDxUPmtvdGxpbi9JbnQ=") JvmSynthetic overridden: public abstract fun data3 (): T of .FooInterface2 declared in .FooInterface2 @@ -275,6 +281,7 @@ FILE fqName: fileName:/Main.kt FUN name:data visibility:public modality:OPEN <> ($this:.FooInterface3Impl.FooInterface3Impl>) returnType:T of .FooInterface3Impl [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YUZvb0ludGVyZmFjZTNJbXBsPFQ+bnVsbA==") JvmSynthetic overridden: public abstract fun data (): T of .FooInterface3 declared in .FooInterface3 @@ -285,6 +292,7 @@ FILE fqName: fileName:/Main.kt FUN name:data2 visibility:public modality:OPEN ($this:.FooInterface3Impl.FooInterface3Impl>, value:A of .FooInterface3Impl.data2) returnType:T of .FooInterface3Impl [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTJGb29JbnRlcmZhY2UzSW1wbDxUPm51bGxB") JvmSynthetic overridden: public abstract fun data2 (value: A of .FooInterface3.data2): T of .FooInterface3 declared in .FooInterface3 @@ -297,6 +305,7 @@ FILE fqName: fileName:/Main.kt FUN name:data3 visibility:public modality:OPEN <> ($this:.FooInterface3Impl.FooInterface3Impl>, $receiver:kotlin.Int) returnType:T of .FooInterface3Impl [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTNGb29JbnRlcmZhY2UzSW1wbDxUPmtvdGxpbi9JbnQ=") JvmSynthetic overridden: public abstract fun data3 (): T of .FooInterface3 declared in .FooInterface3 @@ -380,6 +389,7 @@ FILE fqName: fileName:/Main.kt FUN name:data visibility:public modality:OPEN <> ($this:.FooInterface4Impl.FooInterface4Impl>) returnType:T of .FooInterface4Impl [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YUZvb0ludGVyZmFjZTRJbXBsPFQ+bnVsbA==") JvmSynthetic overridden: public abstract fun data (): T of .FooInterface4 declared in .FooInterface4 @@ -390,6 +400,7 @@ FILE fqName: fileName:/Main.kt FUN name:data2 visibility:public modality:OPEN <> ($this:.FooInterface4Impl.FooInterface4Impl>, value:T of .FooInterface4Impl) returnType:T of .FooInterface4Impl [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTJGb29JbnRlcmZhY2U0SW1wbDxUPm51bGxU") JvmSynthetic overridden: public abstract fun data2 (value: T of .FooInterface4): T of .FooInterface4 declared in .FooInterface4 @@ -401,6 +412,7 @@ FILE fqName: fileName:/Main.kt FUN name:data3 visibility:public modality:OPEN <> ($this:.FooInterface4Impl.FooInterface4Impl>, $receiver:kotlin.Int) returnType:T of .FooInterface4Impl [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTNGb29JbnRlcmZhY2U0SW1wbDxUPmtvdGxpbi9JbnQ=") JvmSynthetic overridden: public abstract fun data3 (): T of .FooInterface4 declared in .FooInterface4 @@ -555,11 +567,13 @@ FILE fqName: fileName:/Main.kt FUN name:data visibility:public modality:ABSTRACT <> ($this:.FooInterface3.FooInterface3>) returnType:T of .FooInterface3 [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YUZvb0ludGVyZmFjZTM8VD5udWxs") JvmSynthetic $this: VALUE_PARAMETER name: type:.FooInterface3.FooInterface3> FUN name:data2 visibility:public modality:ABSTRACT ($this:.FooInterface3.FooInterface3>, value:A of .FooInterface3.data2) returnType:T of .FooInterface3 [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTJGb29JbnRlcmZhY2UzPFQ+bnVsbEE=") JvmSynthetic TYPE_PARAMETER name:A index:0 variance: superTypes:[kotlin.Any?] reified:false $this: VALUE_PARAMETER name: type:.FooInterface3.FooInterface3> @@ -567,6 +581,7 @@ FILE fqName: fileName:/Main.kt FUN name:data3 visibility:public modality:ABSTRACT <> ($this:.FooInterface3.FooInterface3>, $receiver:kotlin.Int) returnType:T of .FooInterface3 [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTNGb29JbnRlcmZhY2UzPFQ+a290bGluL0ludA==") JvmSynthetic $this: VALUE_PARAMETER name: type:.FooInterface3.FooInterface3> $receiver: VALUE_PARAMETER name: type:kotlin.Int @@ -635,17 +650,20 @@ FILE fqName: fileName:/Main.kt FUN name:data visibility:public modality:ABSTRACT <> ($this:.FooInterface4.FooInterface4>) returnType:T of .FooInterface4 [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YUZvb0ludGVyZmFjZTQ8VD5udWxs") JvmSynthetic $this: VALUE_PARAMETER name: type:.FooInterface4.FooInterface4> FUN name:data2 visibility:public modality:ABSTRACT <> ($this:.FooInterface4.FooInterface4>, value:T of .FooInterface4) returnType:T of .FooInterface4 [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTJGb29JbnRlcmZhY2U0PFQ+bnVsbFQ=") JvmSynthetic $this: VALUE_PARAMETER name: type:.FooInterface4.FooInterface4> VALUE_PARAMETER name:value index:0 type:T of .FooInterface4 FUN name:data3 visibility:public modality:ABSTRACT <> ($this:.FooInterface4.FooInterface4>, $receiver:kotlin.Int) returnType:T of .FooInterface4 [suspend] annotations: JvmBlocking(baseName = , suffix = , asProperty = ) + TargetMarker(value = "ZGF0YTNGb29JbnRlcmZhY2U0PFQ+a290bGluL0ludA==") JvmSynthetic $this: VALUE_PARAMETER name: type:.FooInterface4.FooInterface4> $receiver: VALUE_PARAMETER name: type:kotlin.Int diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/implOverridenGeneric.fir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/implOverridenGeneric.fir.txt index 79c33a7..50347f6 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/implOverridenGeneric.fir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/implOverridenGeneric.fir.txt @@ -16,15 +16,15 @@ FILE: Main.kt super() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data(): R|T| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YUZvb0ludGVyZmFjZTFJbXBsPFQ+bnVsbA==)) public open override suspend fun data(): R|T| { ^data R|kotlin/TODO|() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data2(value: R|A|): R|T| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTJGb29JbnRlcmZhY2UxSW1wbDxUPm51bGxB)) public open override suspend fun data2(value: R|A|): R|T| { ^data2 R|kotlin/TODO|() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun R|kotlin/Int|.data3(): R|T| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTNGb29JbnRlcmZhY2UxSW1wbDxUPmtvdGxpbi9JbnQ=)) public open override suspend fun R|kotlin/Int|.data3(): R|T| { ^data3 R|kotlin/TODO|() } @@ -48,15 +48,15 @@ FILE: Main.kt super() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data(): R|T| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YUZvb0ludGVyZmFjZTJJbXBsPFQ+bnVsbA==)) public open override suspend fun data(): R|T| { ^data R|kotlin/TODO|() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data2(value: R|T|): R|T| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTJGb29JbnRlcmZhY2UySW1wbDxUPm51bGxU)) public open override suspend fun data2(value: R|T|): R|T| { ^data2 R|kotlin/TODO|() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun R|kotlin/Int|.data3(): R|T| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTNGb29JbnRlcmZhY2UySW1wbDxUPmtvdGxpbi9JbnQ=)) public open override suspend fun R|kotlin/Int|.data3(): R|T| { ^data3 R|kotlin/TODO|() } @@ -68,11 +68,11 @@ FILE: Main.kt } public abstract interface FooInterface3 : R|kotlin/Any| { - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public abstract suspend fun data(): R|T| + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YUZvb0ludGVyZmFjZTM8VD5udWxs)) public abstract suspend fun data(): R|T| - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public abstract suspend fun data2(value: R|A|): R|T| + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTJGb29JbnRlcmZhY2UzPFQ+bnVsbEE=)) public abstract suspend fun data2(value: R|A|): R|T| - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public abstract suspend fun R|kotlin/Int|.data3(): R|T| + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTNGb29JbnRlcmZhY2UzPFQ+a290bGluL0ludA==)) public abstract suspend fun R|kotlin/Int|.data3(): R|T| @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public open fun data2Blocking(value: R|A|): R|T| @@ -86,15 +86,15 @@ FILE: Main.kt super() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data(): R|T| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YUZvb0ludGVyZmFjZTNJbXBsPFQ+bnVsbA==)) public open override suspend fun data(): R|T| { ^data R|kotlin/TODO|() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data2(value: R|A|): R|T| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTJGb29JbnRlcmZhY2UzSW1wbDxUPm51bGxB)) public open override suspend fun data2(value: R|A|): R|T| { ^data2 R|kotlin/TODO|() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun R|kotlin/Int|.data3(): R|T| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTNGb29JbnRlcmZhY2UzSW1wbDxUPmtvdGxpbi9JbnQ=)) public open override suspend fun R|kotlin/Int|.data3(): R|T| { ^data3 R|kotlin/TODO|() } @@ -106,11 +106,11 @@ FILE: Main.kt } public abstract interface FooInterface4 : R|kotlin/Any| { - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public abstract suspend fun data(): R|T| + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YUZvb0ludGVyZmFjZTQ8VD5udWxs)) public abstract suspend fun data(): R|T| - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public abstract suspend fun data2(value: R|T|): R|T| + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTJGb29JbnRlcmZhY2U0PFQ+bnVsbFQ=)) public abstract suspend fun data2(value: R|T|): R|T| - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public abstract suspend fun R|kotlin/Int|.data3(): R|T| + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTNGb29JbnRlcmZhY2U0PFQ+a290bGluL0ludA==)) public abstract suspend fun R|kotlin/Int|.data3(): R|T| @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public open fun data2Blocking(value: R|T|): R|T| @@ -124,15 +124,15 @@ FILE: Main.kt super() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data(): R|T| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YUZvb0ludGVyZmFjZTRJbXBsPFQ+bnVsbA==)) public open override suspend fun data(): R|T| { ^data R|kotlin/TODO|() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun data2(value: R|T|): R|T| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTJGb29JbnRlcmZhY2U0SW1wbDxUPm51bGxU)) public open override suspend fun data2(value: R|T|): R|T| { ^data2 R|kotlin/TODO|() } - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() public open override suspend fun R|kotlin/Int|.data3(): R|T| { + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(ZGF0YTNGb29JbnRlcmZhY2U0SW1wbDxUPmtvdGxpbi9JbnQ=)) public open override suspend fun R|kotlin/Int|.data3(): R|T| { ^data3 R|kotlin/TODO|() } diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/opt.fir.ir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/opt.fir.ir.txt index e8001eb..9156a3a 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/opt.fir.ir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/opt.fir.ir.txt @@ -106,6 +106,7 @@ FILE fqName: fileName:/Main.kt Values(target = CLASS_REFERENCE 'CLASS CLASS name:OptInTest modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<.OptInTest>) JvmBlocking(baseName = , suffix = , asProperty = ) JvmAsync(baseName = , suffix = , asProperty = ) + TargetMarker(value = "cnVuT3B0SW5UZXN0bnVsbA==") JvmSynthetic $this: VALUE_PARAMETER name: type:.OptInTest BLOCK_BODY diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/opt.fir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/opt.fir.txt index 3df34a3..5a12831 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/opt.fir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/opt.fir.txt @@ -23,7 +23,7 @@ FILE: Main.kt ^run0 Int(1) } - @R|kotlin/OptIn|(markerClass = vararg((Q|OneOptAnno|))) @R|Values|(target = (Q|OptInTest|)) @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() public final suspend fun run(): R|kotlin/Int| { + @R|kotlin/OptIn|(markerClass = vararg((Q|OneOptAnno|))) @R|Values|(target = (Q|OptInTest|)) @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(cnVuT3B0SW5UZXN0bnVsbA==)) public final suspend fun run(): R|kotlin/Int| { ^run this@R|/OptInTest|.R|/OptInTest.run0|() } diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/override.fir.ir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/override.fir.ir.txt index 3cd26d2..dcd2dec 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/override.fir.ir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/override.fir.ir.txt @@ -166,6 +166,7 @@ FILE fqName: fileName:/Main.kt annotations: JvmBlocking(baseName = , suffix = , asProperty = ) JvmAsync(baseName = , suffix = , asProperty = ) + TargetMarker(value = "cnVuRm9vbnVsbA==") JvmSynthetic $this: VALUE_PARAMETER name: type:.Foo FUN name:run visibility:public modality:ABSTRACT <> ($this:.Foo, n:kotlin.Int) returnType:.Bar [suspend] @@ -231,6 +232,7 @@ FILE fqName: fileName:/Main.kt n: GET_VAR 'n: kotlin.Int declared in .IFoo.runBlocking' type=kotlin.Int origin=null FUN name:run visibility:public modality:ABSTRACT <> ($this:.IFoo, n:kotlin.Int) returnType:.Bar [suspend] annotations: + TargetMarker(value = "cnVuSUZvb251bGxrb3RsaW4vSW50") JvmSynthetic $this: VALUE_PARAMETER name: type:.IFoo VALUE_PARAMETER name:n index:0 type:kotlin.Int diff --git a/compiler/suspend-transform-plugin/src/testData/codegen/override.fir.txt b/compiler/suspend-transform-plugin/src/testData/codegen/override.fir.txt index 97193a0..16a577c 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/override.fir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/override.fir.txt @@ -1,6 +1,6 @@ FILE: Main.kt @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() public abstract interface IFoo : R|kotlin/Any| { - public abstract suspend fun run(n: R|kotlin/Int|): R|Bar| + @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(cnVuSUZvb251bGxrb3RsaW4vSW50)) public abstract suspend fun run(n: R|kotlin/Int|): R|Bar| @R|love/forte/plugin/suspendtrans/annotation/Api4J|() public open fun runAsync(n: R|kotlin/Int|): R|java/util/concurrent/CompletableFuture| @@ -8,7 +8,7 @@ FILE: Main.kt } public abstract interface Foo : R|IFoo| { - @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() public abstract suspend fun run(): R|Bar| + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(cnVuRm9vbnVsbA==)) public abstract suspend fun run(): R|Bar| public open suspend fun run(name: R|kotlin/String|): R|Tar| { ^run R|/Tar.Tar|() 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 4b096d5..b9e8fdf 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 @@ -204,6 +204,7 @@ FILE fqName: fileName:/Main.kt annotations: JvmBlocking(baseName = , suffix = , asProperty = ) JvmAsync(baseName = , suffix = , asProperty = ) + TargetMarker(value = "cnVuRm9vPFQ+bnVsbEFwaTxSPg==") JvmSynthetic TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any] reified:false $this: VALUE_PARAMETER name: type:.Foo.Foo> @@ -212,5 +213,6 @@ FILE fqName: fileName:/Main.kt annotations: JvmBlocking(baseName = , suffix = , asProperty = ) JvmAsync(baseName = , suffix = , asProperty = ) + TargetMarker(value = "dmFsdWVGb288VD5udWxs") JvmSynthetic $this: VALUE_PARAMETER name: type:.Foo.Foo> 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 f85c6f5..cc5bfb9 100644 --- a/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.fir.txt +++ b/compiler/suspend-transform-plugin/src/testData/codegen/typeAttr.fir.txt @@ -18,9 +18,9 @@ FILE: Main.kt } 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|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(dmFsdWVGb288VD5udWxs)) 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(api: R|Api|): R|R| + @R|love/forte/plugin/suspendtrans/annotation/JvmBlocking|() @R|love/forte/plugin/suspendtrans/annotation/JvmAsync|() @R|love/forte/plugin/suspendtrans/annotation/TargetMarker|(value = String(cnVuRm9vPFQ+bnVsbEFwaTxSPg==)) 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| diff --git a/runtime/suspend-transform-annotation/src/commonMain/kotlin/love/forte/plugin/suspendtrans/annotation/TargetMarker.kt b/runtime/suspend-transform-annotation/src/commonMain/kotlin/love/forte/plugin/suspendtrans/annotation/TargetMarker.kt new file mode 100644 index 0000000..37648d5 --- /dev/null +++ b/runtime/suspend-transform-annotation/src/commonMain/kotlin/love/forte/plugin/suspendtrans/annotation/TargetMarker.kt @@ -0,0 +1,11 @@ +package love.forte.plugin.suspendtrans.annotation + +/** + * @since *-0.10.0 + */ +@Retention(AnnotationRetention.SOURCE) +@Deprecated("Only used by auto-generate", level = DeprecationLevel.HIDDEN) +@Repeatable +public annotation class TargetMarker( + val value: String +) diff --git a/settings.gradle.kts b/settings.gradle.kts index c622630..45d4533 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -30,3 +30,4 @@ include(":plugins:suspend-transform-plugin-gradle") //Samples // include(":tests:test-jvm") // include(":tests:test-js") +include(":tests:test-kmp") diff --git a/tests/test-kmp/build.gradle.kts b/tests/test-kmp/build.gradle.kts new file mode 100644 index 0000000..41a784d --- /dev/null +++ b/tests/test-kmp/build.gradle.kts @@ -0,0 +1,76 @@ +import love.forte.plugin.suspendtrans.ClassInfo +import love.forte.plugin.suspendtrans.SuspendTransformConfiguration.Companion.jvmAsyncTransformer +import love.forte.plugin.suspendtrans.SuspendTransformConfiguration.Companion.jvmBlockingTransformer +import love.forte.plugin.suspendtrans.TargetPlatform +import love.forte.plugin.suspendtrans.gradle.SuspendTransformGradleExtension + +plugins { + kotlin("multiplatform") +} + + +buildscript { + this@buildscript.repositories { + mavenLocal() + mavenCentral() + } + dependencies { + classpath("love.forte.plugin.suspend-transform:suspend-transform-plugin-gradle:2.1.0-0.10.0") + } +} + +kotlin { + compilerOptions { + freeCompilerArgs.add("-Xjvm-default=all") + freeCompilerArgs.add("-Xexpect-actual-classes") + } +} + +repositories { + mavenLocal() +} + +apply(plugin = "love.forte.plugin.suspend-transform") + +kotlin { + jvm() + js { + nodejs() + } + + sourceSets { + commonMain.dependencies { + implementation(kotlin("reflect")) + implementation(project(":runtime:suspend-transform-annotation")) + implementation(project(":runtime:suspend-transform-runtime")) + implementation(libs.kotlinx.coroutines.core) + } + } +} + +extensions.getByType().apply { + includeRuntime = false + includeAnnotation = false +// useJvmDefault() + transformers[TargetPlatform.JVM] = mutableListOf( + // Add `kotlin.OptIn` to copyAnnotationExcludes + jvmBlockingTransformer.copy( + copyAnnotationExcludes = buildList { + addAll(jvmBlockingTransformer.copyAnnotationExcludes) + add(ClassInfo("kotlin", "OptIn")) + } + ), + + // Add `kotlin.OptIn` to copyAnnotationExcludes + jvmAsyncTransformer.copy( + copyAnnotationExcludes = buildList { + addAll(jvmAsyncTransformer.copyAnnotationExcludes) + add(ClassInfo("kotlin", "OptIn")) + } + ) + ) +} + +tasks.withType { + useJUnitPlatform() +} diff --git a/tests/test-kmp/src/commonMain/kotlin/example/MyClass.kt b/tests/test-kmp/src/commonMain/kotlin/example/MyClass.kt new file mode 100644 index 0000000..1c20a34 --- /dev/null +++ b/tests/test-kmp/src/commonMain/kotlin/example/MyClass.kt @@ -0,0 +1,10 @@ +package example + +import love.forte.plugin.suspendtrans.annotation.JvmBlocking + +expect class MoneyValue + +class MyClass { + @JvmBlocking + suspend fun errorReproduction(amount: MoneyValue) = println(amount) +} diff --git a/tests/test-kmp/src/jsMain/kotlin/example/MyClass.js.kt b/tests/test-kmp/src/jsMain/kotlin/example/MyClass.js.kt new file mode 100644 index 0000000..13f4705 --- /dev/null +++ b/tests/test-kmp/src/jsMain/kotlin/example/MyClass.js.kt @@ -0,0 +1,3 @@ +package example + +actual class MoneyValue diff --git a/tests/test-kmp/src/jvmMain/kotlin/example/MyClass.jvm.kt b/tests/test-kmp/src/jvmMain/kotlin/example/MyClass.jvm.kt new file mode 100644 index 0000000..fe2ccc3 --- /dev/null +++ b/tests/test-kmp/src/jvmMain/kotlin/example/MyClass.jvm.kt @@ -0,0 +1,5 @@ +package example + +import java.math.BigDecimal + +actual typealias MoneyValue = BigDecimal