Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPDATE_KOTLIN_VERSION: 2.1.0-Beta2 #2149

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import com.google.devtools.ksp.configureKtlint
import com.google.devtools.ksp.configureKtlintApplyToIdea
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

val sonatypeUserName: String? by project
val sonatypePassword: String? by project
Expand Down Expand Up @@ -124,5 +125,9 @@ subprojects {

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
compilerOptions.freeCompilerArgs.add("-Xskip-prerelease-check")

// For access to internal classes.
// FIXME: get rid of internal accesses
compilerOptions.languageVersion.set(KotlinVersion.KOTLIN_1_9)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ import com.intellij.openapi.vfs.StandardFileSystems
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiJavaFile
import com.intellij.psi.PsiManager
import com.intellij.psi.impl.file.impl.JavaFileManager
import org.jetbrains.kotlin.analyzer.AnalysisResult
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl
import org.jetbrains.kotlin.config.JvmAnalysisFlags
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.container.ComponentProvider
Expand Down Expand Up @@ -157,6 +159,8 @@ abstract class AbstractKotlinSymbolProcessingExtension(
val psiManager = PsiManager.getInstance(project)
if (initialized) {
psiManager.dropPsiCaches()
psiManager.dropResolveCaches()
invalidateKotlinCliJavaFileManagerCache(project)
} else {
// In case of broken builds.
if (javaShadowBase.exists()) {
Expand Down Expand Up @@ -503,3 +507,13 @@ fun findTargetInfos(languageVersionSettings: LanguageVersionSettings, module: Mo
else -> UnknownPlatformInfoImpl(platform.toString())
}
} ?: emptyList()

// FIXME: remove as soon as possible.
private fun invalidateKotlinCliJavaFileManagerCache(project: Project): Boolean {
val javaFileManager = (JavaFileManager.getInstance(project) as? KotlinCliJavaFileManagerImpl) ?: return false
val privateCacheField = KotlinCliJavaFileManagerImpl::class.java.getDeclaredField("topLevelClassesCache")
if (!privateCacheField.trySetAccessible())
return false
(privateCacheField.get(javaFileManager) as? MutableMap<*, *>)?.clear() ?: return false
return true
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class KotlinFactories {
from = compilerOptions,
into = kspTask.compilerOptions
)
kspTask.produceUnpackedKlib.set(false)
kspTask.produceUnpackagedKlib.set(false)
kspTask.onlyIf {
// KonanTarget is not properly serializable, hence we should check by name
// see https://youtrack.jetbrains.com/issue/KT-61657.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class SourceSetConfigurationsTest {
"""
kotlin {
jvm { }
android(name = "foo") { }
androidTarget(name = "foo") { }
js(IR) { browser() }
androidNativeX86 { }
androidNativeX64(name = "bar") { }
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copied from kotlinc
org.gradle.jvmargs=-Duser.country=US -Dkotlin.daemon.jvm.options=-Xmx4096m -Dfile.encoding=UTF-8

kotlinBaseVersion=2.1.0-Beta1
kotlinBaseVersion=2.1.0-Beta2
agpBaseVersion=7.3.1
intellijVersion=233.13135.103
junitVersion=4.13.1
Expand All @@ -23,5 +23,5 @@ compilerTestEnabled=false
kotlin.jvm.target.validation.mode=warning

# Build or runtime dependencies of this project
buildKotlinVersion=1.9.23
buildKspVersion=1.9.23-1.0.20
buildKotlinVersion=2.0.21
buildKspVersion=2.0.21-1.0.25
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,15 @@ class PlaygroundIT(val useKSP2: Boolean) {
val kotlinCompile = "org.jetbrains.kotlin.gradle.tasks.KotlinCompile"
val buildFile = File(project.root, "workload/build.gradle.kts")
buildFile.appendText("\ntasks.withType<$kotlinCompile> {")
buildFile.appendText("\n kotlinOptions.apiVersion = \"1.5\"")
buildFile.appendText("\n kotlinOptions.languageVersion = \"1.5\"")
buildFile.appendText("\n kotlinOptions.apiVersion = \"1.6\"")
buildFile.appendText("\n kotlinOptions.languageVersion = \"1.6\"")
buildFile.appendText("\n}")

val kotlinVersion = System.getProperty("kotlinVersion").split('-').first()
val gradleRunner = GradleRunner.create().withProjectDir(project.root)
gradleRunner.buildAndCheck("clean", "build") { result ->
Assert.assertTrue(result.output.contains("language version: 1.5"))
Assert.assertTrue(result.output.contains("api version: 1.5"))
Assert.assertTrue(result.output.contains("language version: 1.6"))
Assert.assertTrue(result.output.contains("api version: 1.6"))
if (!useKSP2) {
// In case KSP 1 and KSP 2 uses different compiler versions, ignore this test for KSP 2 for now.
Assert.assertTrue(result.output.contains("compiler version: $kotlinVersion"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ClassVisitor : KSTopDownVisitor<OutputStreamWriter, Unit>() {
data: OutputStreamWriter
) {
super.visitClassDeclaration(classDeclaration, data)
val symbolName = classDeclaration.simpleName.asString().toLowerCase()
val symbolName = classDeclaration.simpleName.asString().lowercase()
data.write(" val $symbolName = true\n")
}
}
Expand Down
Loading