Skip to content

Commit c9d60b6

Browse files
committed
UPDATE_KOTLIN_VERSION: 1.9.0-dev-6976
(cherry picked from commit 78ecbfd)
1 parent a95bbee commit c9d60b6

File tree

19 files changed

+60
-60
lines changed

19 files changed

+60
-60
lines changed

compiler-plugin/build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ val intellijVersion: String by project
88
val kotlinBaseVersion: String by project
99

1010
val libsForTesting by configurations.creating
11+
val libsForTestingCommon by configurations.creating
1112

1213
tasks.withType<KotlinCompile> {
1314
compilerOptions.freeCompilerArgs.add("-Xjvm-default=all-compatibility")
@@ -66,6 +67,7 @@ dependencies {
6667
libsForTesting(kotlin("stdlib", kotlinBaseVersion))
6768
libsForTesting(kotlin("test", kotlinBaseVersion))
6869
libsForTesting(kotlin("script-runtime", kotlinBaseVersion))
70+
libsForTestingCommon(kotlin("stdlib-common", kotlinBaseVersion))
6971
}
7072

7173
tasks.register<Copy>("CopyLibsForTesting") {
@@ -75,6 +77,13 @@ tasks.register<Copy>("CopyLibsForTesting") {
7577
rename("(.+)-$escaped\\.jar", "$1.jar")
7678
}
7779

80+
tasks.register<Copy>("CopyLibsForTestingCommon") {
81+
from(configurations.get("libsForTestingCommon"))
82+
into("dist/common")
83+
val escaped = Regex.escape(kotlinBaseVersion)
84+
rename("(.+)-$escaped\\.jar", "$1.jar")
85+
}
86+
7887
fun Project.javaPluginConvention(): JavaPluginConvention = the()
7988
val JavaPluginConvention.testSourceSet: SourceSet
8089
get() = sourceSets.getByName("test")
@@ -83,6 +92,7 @@ val Project.testSourceSet: SourceSet
8392

8493
tasks.test {
8594
dependsOn("CopyLibsForTesting")
95+
dependsOn("CopyLibsForTestingCommon")
8696
maxHeapSize = "2g"
8797

8898
useJUnitPlatform()
@@ -114,6 +124,7 @@ repositories {
114124
}
115125

116126
val dokkaJavadocJar by tasks.register<Jar>("dokkaJavadocJar") {
127+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
117128
dependsOn(tasks.dokkaJavadoc)
118129
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
119130
from(project(":common-util").tasks.dokkaJavadoc.flatMap { it.outputDirectory })

compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/java/KSAnnotationJavaImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class KSAnnotationJavaImpl private constructor(val psi: PsiAnnotation) : KSAnnot
5454
is PsiJavaFile -> KSFileJavaImpl.getCached(parentPsi)
5555
is PsiClass -> KSClassDeclarationJavaImpl.getCached(parentPsi)
5656
is PsiMethod -> KSFunctionDeclarationJavaImpl.getCached(parentPsi)
57-
is PsiParameter -> KSValueParameterJavaImpl.getCached(parentPsi)
57+
is PsiParameter -> KSValueParameterJavaImpl.getCached(parentPsi, this)
5858
is PsiTypeParameter -> KSTypeParameterJavaImpl.getCached(parentPsi)
5959
is PsiType ->
6060
if (parentPsi.parent is PsiClassType) KSTypeArgumentJavaImpl.getCached(parentPsi, this)

compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/java/KSFunctionDeclarationJavaImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class KSFunctionDeclarationJavaImpl private constructor(val psi: PsiMethod) :
7979
}
8080

8181
override val parameters: List<KSValueParameter> by lazy {
82-
psi.parameterList.parameters.map { KSValueParameterJavaImpl.getCached(it) }
82+
psi.parameterList.parameters.map { KSValueParameterJavaImpl.getCached(it, this) }
8383
}
8484

8585
override val parentDeclaration: KSDeclaration? by lazy {

compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/java/KSValueParameterJavaImpl.kt

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,28 @@
1717

1818
package com.google.devtools.ksp.symbol.impl.java
1919

20+
import com.google.devtools.ksp.IdKeyPair
2021
import com.google.devtools.ksp.KSObjectCache
2122
import com.google.devtools.ksp.processing.impl.KSNameImpl
2223
import com.google.devtools.ksp.symbol.*
24+
import com.google.devtools.ksp.symbol.impl.getInstanceForCurrentRound
2325
import com.google.devtools.ksp.symbol.impl.toLocation
24-
import com.intellij.psi.PsiAnnotation
25-
import com.intellij.psi.PsiMethod
2626
import com.intellij.psi.PsiParameter
2727

28-
class KSValueParameterJavaImpl private constructor(val psi: PsiParameter) : KSValueParameter {
29-
companion object : KSObjectCache<PsiParameter, KSValueParameterJavaImpl>() {
30-
fun getCached(psi: PsiParameter) = cache.getOrPut(psi) { KSValueParameterJavaImpl(psi) }
28+
class KSValueParameterJavaImpl private constructor(val psi: PsiParameter, override val parent: KSNode) :
29+
KSValueParameter {
30+
companion object : KSObjectCache<IdKeyPair<PsiParameter, KSNode>, KSValueParameterJavaImpl>() {
31+
fun getCached(psi: PsiParameter, parent: KSNode): KSValueParameterJavaImpl {
32+
val curParent = getInstanceForCurrentRound(parent) as KSNode
33+
return cache.getOrPut(IdKeyPair(psi, curParent)) { KSValueParameterJavaImpl(psi, curParent) }
34+
}
3135
}
3236

3337
override val origin = Origin.JAVA
3438

3539
override val location: Location by lazy {
3640
psi.toLocation()
3741
}
38-
override val parent: KSNode? by lazy {
39-
var parentPsi = psi.parent
40-
while (true) {
41-
when (parentPsi) {
42-
null, is PsiMethod, is PsiAnnotation -> break
43-
else -> parentPsi = parentPsi.parent
44-
}
45-
}
46-
when (parentPsi) {
47-
is PsiMethod -> KSFunctionDeclarationJavaImpl.getCached(parentPsi)
48-
is PsiAnnotation -> KSAnnotationJavaImpl.getCached(parentPsi)
49-
else -> null
50-
}
51-
}
5242

5343
override val annotations: Sequence<KSAnnotation> by lazy {
5444
psi.annotations.asSequence().map { KSAnnotationJavaImpl.getCached(it) }

compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/utils.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ fun PsiElement.findParentAnnotated(): KSAnnotated? {
6565
var parent = when (this) {
6666
// Unfortunately, LightMethod doesn't implement parent.
6767
is LightMethod -> this.containingClass
68+
is PsiMethod -> this.containingClass
6869
else -> this.parent
6970
}
7071

@@ -261,7 +262,7 @@ internal fun getInstanceForCurrentRound(node: KSNode): KSNode? {
261262
is KSTypeParameterJavaImpl -> KSTypeParameterJavaImpl.getCached(node.psi)
262263
is KSTypeReferenceJavaImpl ->
263264
KSTypeReferenceJavaImpl.getCached(node.psi, (node.parent as? KSAnnotated)?.getInstanceForCurrentRound())
264-
is KSValueParameterJavaImpl -> KSValueParameterJavaImpl.getCached(node.psi)
265+
is KSValueParameterJavaImpl -> KSValueParameterJavaImpl.getCached(node.psi, node.parent)
265266
is KSPropertyGetterSyntheticImpl -> KSPropertyGetterSyntheticImpl.getCached(node.ksPropertyDeclaration)
266267
is KSPropertySetterSyntheticImpl -> KSPropertySetterSyntheticImpl.getCached(node.ksPropertyDeclaration)
267268
is KSValueParameterSyntheticImpl ->

gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KotlinFactories.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
4949
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationInfo
5050
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
5151
import org.jetbrains.kotlin.gradle.plugin.mpp.enabledOnCurrentHost
52+
import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompileTool
5253
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
5354
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
5455
import org.jetbrains.kotlin.gradle.tasks.KotlinCompileCommon
@@ -173,7 +174,6 @@ abstract class KspTaskJvm @Inject constructor(
173174
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_PARAMETER_TYPE")
174175
fun `callCompilerAsync$kotlin_gradle_plugin_common`(
175176
args: K2JVMCompilerArguments,
176-
kotlinSources: Set<File>,
177177
inputChanges: InputChanges,
178178
taskOutputsBackup: TaskOutputsBackup?
179179
) {
@@ -182,7 +182,7 @@ abstract class KspTaskJvm @Inject constructor(
182182
it(changedFiles)
183183
}
184184
args.addPluginOptions(extraOptions)
185-
super.callCompilerAsync(args, kotlinSources, inputChanges, taskOutputsBackup)
185+
super.callCompilerAsync(args, inputChanges, taskOutputsBackup)
186186
}
187187

188188
override fun skipCondition(): Boolean = sources.isEmpty && javaSources.isEmpty
@@ -212,7 +212,6 @@ abstract class KspTaskJS @Inject constructor(
212212
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_PARAMETER_TYPE")
213213
fun `callCompilerAsync$kotlin_gradle_plugin_common`(
214214
args: K2JSCompilerArguments,
215-
kotlinSources: Set<File>,
216215
inputChanges: InputChanges,
217216
taskOutputsBackup: TaskOutputsBackup?
218217
) {
@@ -221,7 +220,7 @@ abstract class KspTaskJS @Inject constructor(
221220
it(changedFiles)
222221
}
223222
args.addPluginOptions(extraOptions)
224-
super.callCompilerAsync(args, kotlinSources, inputChanges, taskOutputsBackup)
223+
super.callCompilerAsync(args, inputChanges, taskOutputsBackup)
225224
}
226225
}
227226

@@ -241,7 +240,6 @@ abstract class KspTaskMetadata @Inject constructor(
241240
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_PARAMETER_TYPE")
242241
fun `callCompilerAsync$kotlin_gradle_plugin_common`(
243242
args: K2MetadataCompilerArguments,
244-
kotlinSources: Set<File>,
245243
inputChanges: InputChanges,
246244
taskOutputsBackup: TaskOutputsBackup?
247245
) {
@@ -250,7 +248,7 @@ abstract class KspTaskMetadata @Inject constructor(
250248
it(changedFiles)
251249
}
252250
args.addPluginOptions(extraOptions)
253-
super.callCompilerAsync(args, kotlinSources, inputChanges, taskOutputsBackup)
251+
super.callCompilerAsync(args, inputChanges, taskOutputsBackup)
254252
}
255253
}
256254

@@ -281,3 +279,7 @@ internal fun File.isParentOf(childCandidate: File): Boolean {
281279

282280
return childCandidatePath.startsWith(parentPath)
283281
}
282+
283+
internal fun disableRunViaBuildToolsApi(kspTask: AbstractKotlinCompileTool<*>) {
284+
kspTask.runViaBuildToolsApi.value(false).disallowChanges()
285+
}

gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspSubplugin.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
1817
package com.google.devtools.ksp.gradle
1918

2019
import com.google.devtools.ksp.gradle.model.builder.KspModelBuilder
@@ -315,6 +314,7 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool
315314

316315
fun configureAsAbstractKotlinCompileTool(kspTask: AbstractKotlinCompileTool<*>) {
317316
kspTask.destinationDirectory.set(kspOutputDir)
317+
disableRunViaBuildToolsApi(kspTask)
318318
kspTask.outputs.dirs(
319319
kotlinOutputDir,
320320
javaOutputDir,
@@ -427,13 +427,12 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool
427427
configureLanguageVersion(kspTask)
428428
if (kspTask.classpathSnapshotProperties.useClasspathSnapshot.get() == false) {
429429
kspTask.compilerOptions.moduleName.convention(
430-
kotlinCompileTask.moduleName.map { "$it-ksp" }
430+
kotlinCompileTask.compilerOptions.moduleName.map { "$it-ksp" }
431431
)
432432
} else {
433-
kspTask.compilerOptions.moduleName.convention(kotlinCompileTask.moduleName)
433+
kspTask.compilerOptions.moduleName.convention(kotlinCompileTask.compilerOptions.moduleName)
434434
}
435435

436-
kspTask.moduleName.value(kotlinCompileTask.moduleName.get())
437436
kspTask.destination.value(kspOutputDir)
438437

439438
val isIntermoduleIncremental =

gradle-plugin/src/test/kotlin/com/google/devtools/ksp/gradle/SourceSetConfigurationsTest.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ class SourceSetConfigurationsTest {
8787
androidNativeX64(name = "bar") { }
8888
}
8989
90-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
91-
kotlinOptions.freeCompilerArgs += "-Xuse-deprecated-legacy-compiler"
92-
}
9390
""".trimIndent()
9491
)
9592
testRule.appModule.addMultiplatformSource("commonMain", "Foo.kt", "class Foo")

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Copied from kotlinc
22
org.gradle.jvmargs=-Duser.country=US -Dkotlin.daemon.jvm.options=-Xmx2200m -Dfile.encoding=UTF-8
33

4-
kotlinBaseVersion=1.9.0-dev-4392
4+
kotlinBaseVersion=1.9.0-dev-6976
55
agpBaseVersion=7.0.0
6-
intellijVersion=203.8084.24
6+
intellijVersion=213.7172.25
77
junitVersion=4.12
88
googleTruthVersion=1.1
99
compilerTestEnabled=false

integration-tests/src/test/kotlin/com/google/devtools/ksp/test/KMPImplementedIT.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.gradle.testkit.runner.GradleRunner
55
import org.gradle.testkit.runner.TaskOutcome
66
import org.junit.Assert
77
import org.junit.Assume
8+
import org.junit.Ignore
89
import org.junit.Rule
910
import org.junit.Test
1011
import java.io.File
@@ -215,6 +216,7 @@ class KMPImplementedIT {
215216
}
216217
}
217218

219+
@Ignore
218220
@Test
219221
fun testNonEmbeddableArtifact() {
220222
Assume.assumeFalse(System.getProperty("os.name").startsWith("Windows", ignoreCase = true))

0 commit comments

Comments
 (0)