Skip to content

Commit b264b80

Browse files
committed
Revert "UPDATE_KOTLIN_VERSION: 1.9.0-dev-6976"
This reverts commit c9d60b6.
1 parent f74ed5f commit b264b80

File tree

19 files changed

+60
-60
lines changed

19 files changed

+60
-60
lines changed

compiler-plugin/build.gradle.kts

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

1010
val libsForTesting by configurations.creating
11-
val libsForTestingCommon by configurations.creating
1211

1312
tasks.withType<KotlinCompile> {
1413
compilerOptions.freeCompilerArgs.add("-Xjvm-default=all-compatibility")
@@ -67,7 +66,6 @@ dependencies {
6766
libsForTesting(kotlin("stdlib", kotlinBaseVersion))
6867
libsForTesting(kotlin("test", kotlinBaseVersion))
6968
libsForTesting(kotlin("script-runtime", kotlinBaseVersion))
70-
libsForTestingCommon(kotlin("stdlib-common", kotlinBaseVersion))
7169
}
7270

7371
tasks.register<Copy>("CopyLibsForTesting") {
@@ -77,13 +75,6 @@ tasks.register<Copy>("CopyLibsForTesting") {
7775
rename("(.+)-$escaped\\.jar", "$1.jar")
7876
}
7977

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-
8778
fun Project.javaPluginConvention(): JavaPluginConvention = the()
8879
val JavaPluginConvention.testSourceSet: SourceSet
8980
get() = sourceSets.getByName("test")
@@ -92,7 +83,6 @@ val Project.testSourceSet: SourceSet
9283

9384
tasks.test {
9485
dependsOn("CopyLibsForTesting")
95-
dependsOn("CopyLibsForTestingCommon")
9686
maxHeapSize = "2g"
9787

9888
useJUnitPlatform()
@@ -124,7 +114,6 @@ repositories {
124114
}
125115

126116
val dokkaJavadocJar by tasks.register<Jar>("dokkaJavadocJar") {
127-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
128117
dependsOn(tasks.dokkaJavadoc)
129118
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
130119
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, this)
57+
is PsiParameter -> KSValueParameterJavaImpl.getCached(parentPsi)
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, this) }
82+
psi.parameterList.parameters.map { KSValueParameterJavaImpl.getCached(it) }
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: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,38 @@
1717

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

20-
import com.google.devtools.ksp.IdKeyPair
2120
import com.google.devtools.ksp.KSObjectCache
2221
import com.google.devtools.ksp.processing.impl.KSNameImpl
2322
import com.google.devtools.ksp.symbol.*
24-
import com.google.devtools.ksp.symbol.impl.getInstanceForCurrentRound
2523
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, 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-
}
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) }
3531
}
3632

3733
override val origin = Origin.JAVA
3834

3935
override val location: Location by lazy {
4036
psi.toLocation()
4137
}
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+
}
4252

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

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ 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
6968
else -> this.parent
7069
}
7170

@@ -262,7 +261,7 @@ internal fun getInstanceForCurrentRound(node: KSNode): KSNode? {
262261
is KSTypeParameterJavaImpl -> KSTypeParameterJavaImpl.getCached(node.psi)
263262
is KSTypeReferenceJavaImpl ->
264263
KSTypeReferenceJavaImpl.getCached(node.psi, (node.parent as? KSAnnotated)?.getInstanceForCurrentRound())
265-
is KSValueParameterJavaImpl -> KSValueParameterJavaImpl.getCached(node.psi, node.parent)
264+
is KSValueParameterJavaImpl -> KSValueParameterJavaImpl.getCached(node.psi)
266265
is KSPropertyGetterSyntheticImpl -> KSPropertyGetterSyntheticImpl.getCached(node.ksPropertyDeclaration)
267266
is KSPropertySetterSyntheticImpl -> KSPropertySetterSyntheticImpl.getCached(node.ksPropertyDeclaration)
268267
is KSValueParameterSyntheticImpl ->

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ 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
5352
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
5453
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
5554
import org.jetbrains.kotlin.gradle.tasks.KotlinCompileCommon
@@ -174,6 +173,7 @@ abstract class KspTaskJvm @Inject constructor(
174173
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_PARAMETER_TYPE")
175174
fun `callCompilerAsync$kotlin_gradle_plugin_common`(
176175
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, inputChanges, taskOutputsBackup)
185+
super.callCompilerAsync(args, kotlinSources, inputChanges, taskOutputsBackup)
186186
}
187187

188188
override fun skipCondition(): Boolean = sources.isEmpty && javaSources.isEmpty
@@ -212,6 +212,7 @@ 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>,
215216
inputChanges: InputChanges,
216217
taskOutputsBackup: TaskOutputsBackup?
217218
) {
@@ -220,7 +221,7 @@ abstract class KspTaskJS @Inject constructor(
220221
it(changedFiles)
221222
}
222223
args.addPluginOptions(extraOptions)
223-
super.callCompilerAsync(args, inputChanges, taskOutputsBackup)
224+
super.callCompilerAsync(args, kotlinSources, inputChanges, taskOutputsBackup)
224225
}
225226
}
226227

@@ -240,6 +241,7 @@ abstract class KspTaskMetadata @Inject constructor(
240241
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "EXPOSED_PARAMETER_TYPE")
241242
fun `callCompilerAsync$kotlin_gradle_plugin_common`(
242243
args: K2MetadataCompilerArguments,
244+
kotlinSources: Set<File>,
243245
inputChanges: InputChanges,
244246
taskOutputsBackup: TaskOutputsBackup?
245247
) {
@@ -248,7 +250,7 @@ abstract class KspTaskMetadata @Inject constructor(
248250
it(changedFiles)
249251
}
250252
args.addPluginOptions(extraOptions)
251-
super.callCompilerAsync(args, inputChanges, taskOutputsBackup)
253+
super.callCompilerAsync(args, kotlinSources, inputChanges, taskOutputsBackup)
252254
}
253255
}
254256

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

280282
return childCandidatePath.startsWith(parentPath)
281283
}
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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
1718
package com.google.devtools.ksp.gradle
1819

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

315316
fun configureAsAbstractKotlinCompileTool(kspTask: AbstractKotlinCompileTool<*>) {
316317
kspTask.destinationDirectory.set(kspOutputDir)
317-
disableRunViaBuildToolsApi(kspTask)
318318
kspTask.outputs.dirs(
319319
kotlinOutputDir,
320320
javaOutputDir,
@@ -427,12 +427,13 @@ 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.compilerOptions.moduleName.map { "$it-ksp" }
430+
kotlinCompileTask.moduleName.map { "$it-ksp" }
431431
)
432432
} else {
433-
kspTask.compilerOptions.moduleName.convention(kotlinCompileTask.compilerOptions.moduleName)
433+
kspTask.compilerOptions.moduleName.convention(kotlinCompileTask.moduleName)
434434
}
435435

436+
kspTask.moduleName.value(kotlinCompileTask.moduleName.get())
436437
kspTask.destination.value(kspOutputDir)
437438

438439
val isIntermoduleIncremental =

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ 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+
}
9093
""".trimIndent()
9194
)
9295
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-6976
4+
kotlinBaseVersion=1.9.0-dev-4392
55
agpBaseVersion=7.0.0
6-
intellijVersion=213.7172.25
6+
intellijVersion=203.8084.24
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: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ 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
98
import org.junit.Rule
109
import org.junit.Test
1110
import java.io.File
@@ -216,7 +215,6 @@ class KMPImplementedIT {
216215
}
217216
}
218217

219-
@Ignore
220218
@Test
221219
fun testNonEmbeddableArtifact() {
222220
Assume.assumeFalse(System.getProperty("os.name").startsWith("Windows", ignoreCase = true))

0 commit comments

Comments
 (0)