Skip to content

Commit 8a8927b

Browse files
committed
build: try release 0.0.6
1 parent 4684b6f commit 8a8927b

28 files changed

+304
-347
lines changed

.idea/.name

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/suspend_transform_annotation_js_0_0_4.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/suspend_transform_annotation_js_0_0_5.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/suspend_transform_annotation_js_0_0_6.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/suspend_transform_annotation_jvm_0_0_4.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/suspend_transform_annotation_jvm_0_0_5.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/suspend_transform_annotation_jvm_0_0_6.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/suspend_transform_runtime_js_0_0_4.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/suspend_transform_runtime_js_0_0_5.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/suspend_transform_runtime_js_0_0_6.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/suspend_transform_runtime_jvm_0_0_4.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/suspend_transform_runtime_jvm_0_0_5.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/artifacts/suspend_transform_runtime_jvm_0_0_6.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ allprojects {
1515
mavenLocal()
1616
mavenCentral()
1717
gradlePluginPortal()
18+
//maven {
19+
// url = URI("")
20+
//}
1821
}
1922
this.tasks.withType<JavaCompile> {
20-
sourceCompatibility = "11"
21-
targetCompatibility = "11"
23+
sourceCompatibility = "1.8"
24+
targetCompatibility = "1.8"
2225
}
2326
this.tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
2427
kotlinOptions.jvmTarget = "1.8"

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies {
2222
api("gradle.plugin.com.bnorm.power:kotlin-power-assert-gradle:0.12.0")
2323
api("io.github.gradle-nexus:publish-plugin:1.1.0")
2424

25-
// api("com.github.jengelman.gradle.plugins:shadow:6.1.0")
25+
api("com.github.jengelman.gradle.plugins:shadow:6.1.0")
2626
}
2727

2828

buildSrc/src/main/kotlin/IProject.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
object IProject {
2-
const val VERSION = "0.0.5"
2+
const val VERSION = "0.0.6"
33
const val GROUP = "love.forte.plugin.suspend-transform"
44
const val DESCRIPTION = "Generate platform-compatible functions for Kotlin suspend functions"
55

buildSrc/src/main/kotlin/MultiplatformTargetsConfigure.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ fun KotlinMultiplatformExtension.configAllNativeTargets(
2525
) {
2626
presets.all {
2727
if (this !is KotlinNativeTargetPreset || !filter(this)) return@all
28-
println(this)
29-
println(this.name)
3028
configureOrCreate(name, this, configureEach)
3129
}
3230
}

buildSrc/src/main/kotlin/suspend-transform.nexus-publish.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ description = "Generate platform-compatible functions for Kotlin suspend functio
1515
val isPublishConfigurable = isPublishConfigurable()
1616

1717
if (!isPublishConfigurable) {
18-
println("[WARN] - sonatype.username or sonatype.password is null, cannot config nexus publishing.")
18+
logger.warn("sonatype.username or sonatype.password is null, cannot config nexus publishing.")
1919
}
2020

2121

2222
if (isPublishConfigurable) {
2323
val (sonatypeUsername, sonatypePassword) = sonatypeUserInfo
2424
nexusPublishing {
25-
println("[NEXUS] - project.group: ${project.group}")
26-
println("[NEXUS] - project.version: ${project.version}")
25+
logger.info("[NEXUS] - project.group: ${project.group}")
26+
logger.info("[NEXUS] - project.version: ${project.version}")
2727
packageGroup by project.group.toString()
2828
repositoryDescription by (project.description ?: "")
2929

@@ -50,7 +50,7 @@ if (isPublishConfigurable) {
5050
}
5151

5252

53-
println("[nexus-publishing-configure] - [$name] configured.")
53+
logger.info("[nexus-publishing-configure] - [{}] configured.", name)
5454
}
5555

5656

compiler/suspend-transform-plugin/build.gradle.kts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ plugins {
99
id("suspend-transform.jvm-maven-publish")
1010
id("com.bennyhuo.kotlin.plugin.embeddable.test") version "1.7.10.0"
1111
}
12-
buildscript {
13-
plugins {
14-
}
15-
}
12+
1613
dependencies {
1714
compileOnly(kotlin("stdlib"))
1815
compileOnly(kotlin("compiler"))
@@ -22,19 +19,30 @@ dependencies {
2219

2320
testImplementation(kotlin("stdlib"))
2421
testImplementation(kotlin("test-junit"))
25-
testImplementation(kotlin("compiler-embeddable"))
22+
// testImplementation(kotlin("compiler-embeddable"))
23+
testImplementation("org.jetbrains.kotlin:kotlin-compiler-embeddable")
2624

2725
testImplementation(project(":runtime:suspend-transform-annotation"))
2826
testImplementation(project(":runtime:suspend-transform-runtime"))
2927

3028
// testImplementation("com.github.tschuchortdev:kotlin-compile-testing:1.4.9")
31-
testImplementation("org.bitbucket.mstrobel:procyon-compilertools:0.6.0")
32-
testImplementation("com.bennyhuo.kotlin:kotlin-compile-testing-extensions:1.7.10.1")
29+
// testImplementation("org.bitbucket.mstrobel:procyon-compilertools:0.6.0")
30+
testImplementation("com.bennyhuo.kotlin:kotlin-compile-testing-extensions:1.7.10.2-SNAPSHOT")
3331

3432
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
3533
// testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.4")
3634
}
3735
val compileKotlin: KotlinCompile by tasks
36+
compileKotlin.kotlinOptions.freeCompilerArgs += listOf("-Xjvm-default=enable", "-opt-in=kotlin.RequiresOptIn")
37+
38+
repositories {
39+
maven {
40+
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
41+
mavenContent {
42+
snapshotsOnly()
43+
}
44+
}
45+
}
3846

3947
buildConfig {
4048
useKotlinOutput {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension
1212
@AutoService(ComponentRegistrar::class)
1313
class SuspendTransformComponentRegistrar : ComponentRegistrar {
1414

15-
internal var defaultConfiguration: SuspendTransformConfiguration? = null
15+
//internal var defaultConfiguration: SuspendTransformConfiguration? = null
1616

1717

1818
override fun registerProjectComponents(
1919
project: MockProject,
2020
configuration: CompilerConfiguration,
2121
) {
2222

23-
val suspendTransformConfiguration = defaultConfiguration ?: configuration.resolveToSuspendTransformConfiguration()
23+
val suspendTransformConfiguration =/* defaultConfiguration ?: */configuration.resolveToSuspendTransformConfiguration()
2424

2525
if (suspendTransformConfiguration.enabled) {
2626
SyntheticResolveExtension.registerExtension(project, SuspendTransformSyntheticResolveExtension(suspendTransformConfiguration))

compiler/suspend-transform-plugin/src/main/kotlin/love/forte/plugin/suspendtrans/ir/SuspendTransformTransformer.kt

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package love.forte.plugin.suspendtrans.ir
22

33
import love.forte.plugin.suspendtrans.*
4-
import love.forte.plugin.suspendtrans.utils.createIrBuilder
5-
import love.forte.plugin.suspendtrans.utils.createSuspendLambdaWithCoroutineScope
6-
import love.forte.plugin.suspendtrans.utils.irAnnotationConstructor
7-
import love.forte.plugin.suspendtrans.utils.paramsAndReceiversAsParamsList
4+
import love.forte.plugin.suspendtrans.utils.*
85
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
96
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
7+
import org.jetbrains.kotlin.builtins.StandardNames.COROUTINES_PACKAGE_FQ_NAME
108
import org.jetbrains.kotlin.descriptors.CallableDescriptor
119
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
1210
import org.jetbrains.kotlin.ir.IrStatement
@@ -15,18 +13,16 @@ import org.jetbrains.kotlin.ir.builders.irBlockBody
1513
import org.jetbrains.kotlin.ir.builders.irCall
1614
import org.jetbrains.kotlin.ir.builders.irGet
1715
import org.jetbrains.kotlin.ir.builders.irReturn
18-
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
19-
import org.jetbrains.kotlin.ir.declarations.IrDeclarationContainer
20-
import org.jetbrains.kotlin.ir.declarations.IrFunction
21-
import org.jetbrains.kotlin.ir.declarations.IrProperty
16+
import org.jetbrains.kotlin.ir.declarations.*
2217
import org.jetbrains.kotlin.ir.expressions.IrBody
2318
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
2419
import org.jetbrains.kotlin.ir.types.typeWith
25-
import org.jetbrains.kotlin.ir.util.isAnnotationWithEqualFqName
26-
import org.jetbrains.kotlin.ir.util.primaryConstructor
20+
import org.jetbrains.kotlin.ir.util.*
2721
import org.jetbrains.kotlin.name.FqName
22+
import org.jetbrains.kotlin.name.Name
2823
import org.jetbrains.kotlin.platform.js.isJs
2924
import org.jetbrains.kotlin.platform.jvm.isJvm
25+
import org.jetbrains.kotlin.serialization.deserialization.KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME
3026

3127
/**
3228
*
@@ -145,7 +141,7 @@ class SuspendTransformTransformer(
145141
if (parent is IrDeclarationContainer) {
146142
val originFunctions = parent.declarations.filterIsInstance<IrFunction>()
147143
.filter { f -> f.descriptor == originFunctionDescriptor }
148-
function.descriptor
144+
149145
if (originFunctions.size != 1) {
150146
// maybe override function
151147
/*
@@ -209,6 +205,27 @@ private fun generateTransformBodyForFunction(
209205
putValueArgument(index, irGet(parameter))
210206
}
211207
})
208+
// argument: 1, if is CoroutineScope, and this is CoroutineScope.
209+
//println("transformTargetFunctionCall.owner: ${transformTargetFunctionCall.owner}")
210+
//println(transformTargetFunctionCall.owner.valueParameters)
211+
val owner = transformTargetFunctionCall.owner
212+
213+
if (owner.valueParameters.size > 1) {
214+
val secondType = owner.valueParameters[1].type
215+
KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME
216+
val coroutineScopeTypeName = COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineScope"))
217+
val coroutineScopeTypeNameUnsafe = coroutineScopeTypeName.toUnsafe()
218+
if (secondType.isClassType(coroutineScopeTypeNameUnsafe)) {
219+
originFunction.dispatchReceiverParameter?.also { dispatchReceiverParameter ->
220+
if (dispatchReceiverParameter.type.isClassType(coroutineScopeTypeNameUnsafe)) {
221+
// put 'this' to second arg
222+
putValueArgument(1, irGet(dispatchReceiverParameter))
223+
}
224+
}
225+
}
226+
227+
}
228+
212229
})
213230
}
214231
}

0 commit comments

Comments
 (0)