fix #72 comments are allowed in class constructor; some configuration bigs fixed

This commit is contained in:
Sergey Chernov 2025-12-04 16:09:27 +01:00
parent b8f27c7a18
commit 5cfc15cf17
4 changed files with 62 additions and 2 deletions

View File

@ -32,9 +32,9 @@ kotlin.native.cacheKind.linuxX64=none
# Workaround: Ensure Gradle uses a JDK with `jlink` available for AGP's JDK image transform. # Workaround: Ensure Gradle uses a JDK with `jlink` available for AGP's JDK image transform.
# On this environment, the system JDK 21 installation lacks `jlink`, causing # On this environment, the system JDK 21 installation lacks `jlink`, causing
# :lynglib:androidJdkImage to fail. Point Gradle to JDK 17 which includes `jlink`. # :lynglib:androidJdkImage to fail. Point Gradle to a JDK that includes `jlink`.
# This affects only the JDK Gradle runs with; Kotlin/JVM target remains compatible. # This affects only the JDK Gradle runs with; Kotlin/JVM target remains compatible.
#org.gradle.java.home=/usr/lib/jvm/java-17-openjdk-amd64 org.gradle.java.home=/home/sergeych/.jdks/corretto-21.0.9
android.experimental.lint.migrateToK2=false android.experimental.lint.migrateToK2=false
android.lint.useK2Uast=false android.lint.useK2Uast=false
kotlin.mpp.applyDefaultHierarchyTemplate=true kotlin.mpp.applyDefaultHierarchyTemplate=true

View File

@ -176,6 +176,30 @@ kotlin.targets.configureEach {
} }
} }
// Ensure any SourcesJar tasks (for all targets/variants) are properly wired to the generator
tasks.withType<Jar>().configureEach {
if (name == "sourcesJar" || name.endsWith("SourcesJar")) {
// Declare both dependency and inputs to satisfy Gradle validation and up-to-date checks
dependsOn(generateLyngStdlib)
inputs.dir(generatedLyngStdlibDir)
}
}
// Extra safety: in case the SourcesJar task is not of type Jar (AGP/MPP variations),
// wire it up by name as well. This guarantees the dependency even if the concrete type differs.
tasks.configureEach {
if (name == "androidReleaseSourcesJar" || name == "sourcesJar" || name.endsWith("SourcesJar")) {
dependsOn(generateLyngStdlib)
inputs.dir(generatedLyngStdlibDir)
}
}
// Be explicit for the aggregate metadata sources task too
tasks.named("sourcesJar").configure {
dependsOn(generateLyngStdlib)
inputs.dir(generatedLyngStdlibDir)
}
android { android {
namespace = "org.jetbrains.kotlinx.multiplatform.library.template" namespace = "org.jetbrains.kotlinx.multiplatform.library.template"
compileSdk = libs.versions.android.compileSdk.get().toInt() compileSdk = libs.versions.android.compileSdk.get().toInt()

View File

@ -832,6 +832,7 @@ class Compiler(
} }
Token.Type.NEWLINE -> {} Token.Type.NEWLINE -> {}
Token.Type.MULTILINE_COMMENT, Token.Type.SINLGE_LINE_COMMENT -> {}
Token.Type.ID -> { Token.Type.ID -> {
// visibility // visibility

View File

@ -15,6 +15,7 @@
* *
*/ */
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
@ -30,6 +31,22 @@ import net.sergeych.tools.bm
import kotlin.test.* import kotlin.test.*
import kotlin.time.Duration.Companion.seconds import kotlin.time.Duration.Companion.seconds
/*
* Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
class ScriptTest { class ScriptTest {
@Test @Test
fun testVersion() { fun testVersion() {
@ -3766,4 +3783,22 @@ class ScriptTest {
""".trimIndent()) """.trimIndent())
} }
@Test
fun testCommentsInClassConstructor() = runTest {
eval("""
class T(
// comment 1
val x: Int,
// comment 2
val y: String
)
println( T(1, "2") )
"""
)
}
} }