diff --git a/build.gradle.kts b/build.gradle.kts index 7fdbcc9da7c..97fcae0b3ad 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,7 +52,6 @@ pill { excludedDirs( "out", "buildSrc/build", - "buildSrc/prepare-deps/android-dx/build", "buildSrc/prepare-deps/intellij-sdk/build" ) } @@ -332,6 +331,7 @@ extra["tasksWithWarnings"] = listOf( ":compiler:fir:checkers:compileKotlin", ":compiler:fir:java:compileKotlin", ":kotlin-scripting-compiler:compileKotlin", + ":kotlin-scripting-compiler:compileTestKotlin", ":plugins:uast-kotlin:compileKotlin", ":plugins:uast-kotlin:compileTestKotlin", ":plugins:uast-kotlin-idea:compileKotlin" diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index c8979e1aa73..3ec018187ed 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -81,8 +81,6 @@ extra["intellijReleaseType"] = when { else -> "releases" } -extra["versions.androidDxSources"] = "5.0.0_r2" - extra["customDepsOrg"] = "kotlin.build" repositories { diff --git a/buildSrc/src/main/kotlin/localDependencies.kt b/buildSrc/src/main/kotlin/localDependencies.kt index ab23a4af3f7..444fbe67695 100644 --- a/buildSrc/src/main/kotlin/localDependencies.kt +++ b/buildSrc/src/main/kotlin/localDependencies.kt @@ -76,8 +76,6 @@ fun Project.jpsStandalone() = "kotlin.build:jps-standalone:${rootProject.extra[" fun Project.nodeJSPlugin() = "kotlin.build:NodeJS:${rootProject.extra["versions.idea.NodeJS"]}" -fun Project.androidDxJar() = "org.jetbrains.kotlin:android-dx:${rootProject.extra["versions.androidBuildTools"]}" - fun Project.jpsBuildTest() = "com.jetbrains.intellij.idea:jps-build-test:${rootProject.extra["versions.intellijSdk"]}" fun Project.kotlinxCollectionsImmutable() = "org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:${rootProject.extra["versions.kotlinx-collections-immutable"]}" diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index 19e9a8649c0..a89d17ab830 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -65,7 +65,6 @@ dependencies { testRuntimeOnly(intellijPluginDep("java")) testRuntime(project(":kotlin-reflect")) - testRuntime(androidDxJar()) testRuntime(toolsJar()) antLauncherJar(commonDep("org.apache.ant", "ant")) diff --git a/compiler/cli/bin/kapt b/compiler/cli/bin/kapt index 29be2add330..510eabba860 100755 --- a/compiler/cli/bin/kapt +++ b/compiler/cli/bin/kapt @@ -1,18 +1,7 @@ #!/usr/bin/env bash -# Copyright 2010-2015 JetBrains s.r.o. -# -# 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. +# Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. +# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. export KOTLIN_TOOL=kotlin-annotation-processing-cli.jar diff --git a/compiler/cli/bin/kapt.bat b/compiler/cli/bin/kapt.bat index 7cd246de65b..6839f592a9d 100644 --- a/compiler/cli/bin/kapt.bat +++ b/compiler/cli/bin/kapt.bat @@ -1,18 +1,7 @@ @echo off -rem Copyright 2010-2015 JetBrains s.r.o. -rem -rem Licensed under the Apache License, Version 2.0 (the "License"); -rem you may not use this file except in compliance with the License. -rem You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. +rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. +rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. setlocal set _KOTLIN_COMPILER=org.jetbrains.kotlin.kapt.cli.KaptCli diff --git a/compiler/cli/bin/kotlin b/compiler/cli/bin/kotlin index 68a0da47ad9..8bd19228ecd 100755 --- a/compiler/cli/bin/kotlin +++ b/compiler/cli/bin/kotlin @@ -1,18 +1,7 @@ #!/usr/bin/env bash -# Copyright 2010-2015 JetBrains s.r.o. -# -# 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. +# Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. +# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. export KOTLIN_RUNNER=1 diff --git a/compiler/cli/bin/kotlin-dce-js b/compiler/cli/bin/kotlin-dce-js index aa4cfdd952e..552605469b7 100755 --- a/compiler/cli/bin/kotlin-dce-js +++ b/compiler/cli/bin/kotlin-dce-js @@ -1,18 +1,7 @@ #!/usr/bin/env bash -# Copyright 2010-2017 JetBrains s.r.o. -# -# 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. +# Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. +# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. export KOTLIN_COMPILER=org.jetbrains.kotlin.cli.js.dce.K2JSDce diff --git a/compiler/cli/bin/kotlin-dce-js.bat b/compiler/cli/bin/kotlin-dce-js.bat index ff6a9ce21c3..1fb2d6c80eb 100644 --- a/compiler/cli/bin/kotlin-dce-js.bat +++ b/compiler/cli/bin/kotlin-dce-js.bat @@ -1,18 +1,7 @@ @echo off -rem Copyright 2010-2015 JetBrains s.r.o. -rem -rem Licensed under the Apache License, Version 2.0 (the "License"); -rem you may not use this file except in compliance with the License. -rem You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. +rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. +rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. setlocal set _KOTLIN_COMPILER=org.jetbrains.kotlin.cli.js.dce.K2JSDce diff --git a/compiler/cli/bin/kotlin.bat b/compiler/cli/bin/kotlin.bat index 4817fa88038..769929eb0d7 100644 --- a/compiler/cli/bin/kotlin.bat +++ b/compiler/cli/bin/kotlin.bat @@ -1,18 +1,7 @@ @echo off -rem Copyright 2010-2015 JetBrains s.r.o. -rem -rem Licensed under the Apache License, Version 2.0 (the "License"); -rem you may not use this file except in compliance with the License. -rem You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. +rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. +rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. setlocal set _KOTLIN_RUNNER=1 diff --git a/compiler/cli/bin/kotlinc b/compiler/cli/bin/kotlinc index 7f45ac9146e..b1cd40143fd 100755 --- a/compiler/cli/bin/kotlinc +++ b/compiler/cli/bin/kotlinc @@ -1,13 +1,9 @@ #!/usr/bin/env bash -# -############################################################################## + +# Based on scalac from the Scala distribution # Copyright 2002-2011, LAMP/EPFL -# Copyright 2011-2015, JetBrains -# -# This is free software; see the distribution for copying conditions. -# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. -############################################################################## +# Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. +# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. cygwin=false; case "`uname`" in @@ -25,6 +21,17 @@ findKotlinHome() { (cd -P "$(dirname "$source")/.." && pwd) } +findJavaVersion() { + # Note that this only loads the first component of the version, so "1.8.0_265" -> "1". + # But it's fine because major version is 9 for JDK 9, and so on. + regex='^.*version "([[:digit:]]+).*$' + while read -r line; do + if [[ "$line" =~ $regex ]]; then + echo ${BASH_REMATCH[1]} + fi + done <<< $("${JAVACMD:=java}" -version 2>&1) +} + KOTLIN_HOME="$(findKotlinHome)" if $cygwin; then @@ -60,17 +67,24 @@ fi declare -a kotlin_app -if [ -n "$KOTLIN_RUNNER" ]; -then +java_version="$(findJavaVersion)" +if [[ $java_version -ge 9 ]]; then + # Workaround the illegal reflective access warning from ReflectionUtil to ResourceBundle.setParent, see IDEA-248785. + java_args=("${java_args[@]}" "--add-opens" "java.base/java.util=ALL-UNNAMED") +fi + +if [ -n "$KOTLIN_RUNNER" ]; then java_args=("${java_args[@]}" "-Dkotlin.home=${KOTLIN_HOME}") kotlin_app=("${KOTLIN_HOME}/lib/kotlin-runner.jar" "org.jetbrains.kotlin.runner.Main") else [ -n "$KOTLIN_COMPILER" ] || KOTLIN_COMPILER=org.jetbrains.kotlin.cli.jvm.K2JVMCompiler - java_args=("${java_args[@]}" "-noverify") + + if [[ $java_version < 13 ]]; then + java_args=("${java_args[@]}" "-noverify") + fi declare additional_classpath="" - if [ -n "$KOTLIN_TOOL" ]; - then + if [ -n "$KOTLIN_TOOL" ]; then additional_classpath=":${KOTLIN_HOME}/lib/${KOTLIN_TOOL}" fi diff --git a/compiler/cli/bin/kotlinc-js b/compiler/cli/bin/kotlinc-js index 72a04030a1f..1ed7904701d 100755 --- a/compiler/cli/bin/kotlinc-js +++ b/compiler/cli/bin/kotlinc-js @@ -1,18 +1,7 @@ #!/usr/bin/env bash -# Copyright 2010-2015 JetBrains s.r.o. -# -# 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. +# Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. +# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. export KOTLIN_COMPILER=org.jetbrains.kotlin.cli.js.K2JSCompiler diff --git a/compiler/cli/bin/kotlinc-js.bat b/compiler/cli/bin/kotlinc-js.bat index 9a549d133ae..b9455926582 100644 --- a/compiler/cli/bin/kotlinc-js.bat +++ b/compiler/cli/bin/kotlinc-js.bat @@ -1,18 +1,7 @@ @echo off -rem Copyright 2010-2015 JetBrains s.r.o. -rem -rem Licensed under the Apache License, Version 2.0 (the "License"); -rem you may not use this file except in compliance with the License. -rem You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. +rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. +rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. setlocal set _KOTLIN_COMPILER=org.jetbrains.kotlin.cli.js.K2JSCompiler diff --git a/compiler/cli/bin/kotlinc-jvm b/compiler/cli/bin/kotlinc-jvm index 9725efa56d7..4ca34f7f4f9 100755 --- a/compiler/cli/bin/kotlinc-jvm +++ b/compiler/cli/bin/kotlinc-jvm @@ -1,18 +1,7 @@ #!/usr/bin/env bash -# Copyright 2010-2015 JetBrains s.r.o. -# -# 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. +# Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. +# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. DIR="${BASH_SOURCE[0]%/*}" : ${DIR:="."} diff --git a/compiler/cli/bin/kotlinc-jvm.bat b/compiler/cli/bin/kotlinc-jvm.bat index dd60b1cb786..15690ed68ae 100644 --- a/compiler/cli/bin/kotlinc-jvm.bat +++ b/compiler/cli/bin/kotlinc-jvm.bat @@ -1,17 +1,6 @@ @echo off -rem Copyright 2010-2015 JetBrains s.r.o. -rem -rem Licensed under the Apache License, Version 2.0 (the "License"); -rem you may not use this file except in compliance with the License. -rem You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. +rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. +rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. call %~dps0kotlinc.bat %* diff --git a/compiler/cli/bin/kotlinc.bat b/compiler/cli/bin/kotlinc.bat index fdcd6af6171..ec084c06a8f 100644 --- a/compiler/cli/bin/kotlinc.bat +++ b/compiler/cli/bin/kotlinc.bat @@ -1,13 +1,9 @@ @echo off -rem based on scalac.bat from the Scala distribution -rem ########################################################################## -rem # Copyright 2002-2011, LAMP/EPFL -rem # Copyright 2011-2015, JetBrains -rem # -rem # This is free software; see the distribution for copying conditions. -rem # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A -rem # PARTICULAR PURPOSE. -rem ########################################################################## + +rem Based on scalac.bat from the Scala distribution +rem Copyright 2002-2011, LAMP/EPFL +rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. +rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. rem We adopt the following conventions: rem - System/user environment variables start with a letter @@ -19,11 +15,10 @@ call :set_home if "%_KOTLIN_COMPILER%"=="" set _KOTLIN_COMPILER=org.jetbrains.kotlin.cli.jvm.K2JVMCompiler if not "%JAVA_HOME%"=="" ( - if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe" + rem Prepend JAVA_HOME to local PATH to be able to simply execute "java" later in the script. + set "PATH=%JAVA_HOME%\bin;%PATH%" ) -if "%_JAVACMD%"=="" set _JAVACMD=java - rem We use the value of the JAVA_OPTS environment variable if defined if "%JAVA_OPTS%"=="" set JAVA_OPTS=-Xmx256M -Xms32M @@ -45,18 +40,29 @@ shift goto loop :loopend -if "%_KOTLIN_RUNNER%"=="1" ( - "%_JAVACMD%" %JAVA_OPTS% "-Dkotlin.home=%_KOTLIN_HOME%" -cp "%_KOTLIN_HOME%\lib\kotlin-runner.jar" ^ +setlocal EnableDelayedExpansion + +call :set_java_version +if !_java_major_version! geq 9 ( + rem Workaround the illegal reflective access warning from ReflectionUtil to ResourceBundle.setParent, see IDEA-248785. + set JAVA_OPTS=!JAVA_OPTS! "--add-opens" "java.base/java.util=ALL-UNNAMED" +) + +if "!_KOTLIN_RUNNER!"=="1" ( + java !JAVA_OPTS! "-Dkotlin.home=%_KOTLIN_HOME%" -cp "%_KOTLIN_HOME%\lib\kotlin-runner.jar" ^ org.jetbrains.kotlin.runner.Main %KOTLIN_OPTS% ) else ( - setlocal EnableDelayedExpansion - SET _ADDITIONAL_CLASSPATH= + set _ADDITIONAL_CLASSPATH= + + if !_java_major_version! lss 13 ( + set JAVA_OPTS=!JAVA_OPTS! "-noverify" + ) if not "%_KOTLIN_TOOL%"=="" ( set _ADDITIONAL_CLASSPATH=;%_KOTLIN_HOME%\lib\%_KOTLIN_TOOL% ) - "%_JAVACMD%" %JAVA_OPTS% -noverify -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^ + java !JAVA_OPTS! -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^ org.jetbrains.kotlin.preloading.Preloader -cp "%_KOTLIN_HOME%\lib\kotlin-compiler.jar!_ADDITIONAL_CLASSPATH!" ^ %_KOTLIN_COMPILER% %KOTLIN_OPTS% ) @@ -73,6 +79,29 @@ rem # subroutines set _KOTLIN_HOME=%_BIN_DIR%.. goto :eof +rem Parses "java -version" output and stores the major version to _java_major_version. +rem Note that this only loads the first component of the version, so "1.8.0_265" -> "1". +rem But it's fine because major version is 9 for JDK 9, and so on. +rem Needs to be executed in the EnableDelayedExpansion mode. +:set_java_version + set _version= + rem Parse output and take the third token from the string containing " version ". + rem It should be something like "1.8.0_275" or "15.0.1". + for /f "tokens=3" %%i in ('java -version 2^>^&1 ^| findstr /i " version "') do ( + rem Split the string by "-" or "." and take the first token. + for /f "delims=-. tokens=1" %%j in ("%%i") do ( + rem At this point, _version should be something like "1 or "15. Note the leading quote. + set _version=%%j + ) + ) + if "!_version!"=="" ( + rem If failed to parse the output, set the version to 1. + set _java_major_version=1 + ) else ( + rem Strip the leading quote. + set _java_major_version=!_version:~1! + ) +goto :eof + :end endlocal - diff --git a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt index 38d45247c73..e45d6fb20aa 100644 --- a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt +++ b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt @@ -374,10 +374,16 @@ object KotlinCompilerClient { // hide daemon window "-Djava.awt.headless=true", "-D$JAVA_RMI_SERVER_HOSTNAME=$serverHostname") + val javaVersion = System.getProperty("java.specification.version")?.toIntOrNull() + val javaIllegalAccessWorkaround = + if (javaVersion != null && javaVersion >= 17) + listOf("--illegal-access=permit") + else emptyList() val args = listOf( javaExecutable.absolutePath, "-cp", compilerId.compilerClasspath.joinToString(File.pathSeparator)) + platformSpecificOptions + daemonJVMOptions.mappers.flatMap { it.toArgs("-") } + + javaIllegalAccessWorkaround + COMPILER_DAEMON_CLASS_FQN + daemonOptions.mappers.flatMap { it.toArgs(COMPILE_DAEMON_CMDLINE_OPTIONS_PREFIX) } + compilerId.mappers.flatMap { it.toArgs(COMPILE_DAEMON_CMDLINE_OPTIONS_PREFIX) } diff --git a/compiler/fir/analysis-tests/build.gradle.kts b/compiler/fir/analysis-tests/build.gradle.kts index 867488761da..ce6a74b6be5 100644 --- a/compiler/fir/analysis-tests/build.gradle.kts +++ b/compiler/fir/analysis-tests/build.gradle.kts @@ -32,7 +32,6 @@ dependencies { testCompileOnly(project(":kotlin-reflect-api")) testRuntimeOnly(project(":kotlin-reflect")) testRuntimeOnly(project(":core:descriptors.runtime")) - testRuntimeOnly(androidDxJar()) testRuntimeOnly(project(":compiler:fir:fir2ir:jvm-backend")) testImplementation(intellijCoreDep()) { includeJars("intellij-core") } diff --git a/compiler/fir/tree/tree-generator/build.gradle.kts b/compiler/fir/tree/tree-generator/build.gradle.kts index 7324a7e7cfd..79b273788ac 100644 --- a/compiler/fir/tree/tree-generator/build.gradle.kts +++ b/compiler/fir/tree/tree-generator/build.gradle.kts @@ -11,6 +11,7 @@ val compileOnly by configurations runtimeOnly.extendsFrom(compileOnly) dependencies { + implementation(project(":generators")) implementation(project(":core:compiler.common")) implementation(project(":compiler:frontend.common")) implementation(project(":compiler:fir:cones")) diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Main.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Main.kt index 922cf17a26d..3570055ea64 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Main.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Main.kt @@ -5,8 +5,9 @@ package org.jetbrains.kotlin.fir.tree.generator -import org.jetbrains.kotlin.fir.tree.generator.printer.printElements +import org.jetbrains.kotlin.fir.tree.generator.printer.generateElements import org.jetbrains.kotlin.fir.tree.generator.util.* +import org.jetbrains.kotlin.generators.util.GeneratorsFileUtil import java.io.File @@ -19,8 +20,9 @@ fun main(args: Array) { ImplementationConfigurator.configureImplementations() configureInterfacesAndAbstractClasses(FirTreeBuilder) BuilderConfigurator.configureBuilders() - removePreviousGeneratedFiles(generationPath) - printElements(FirTreeBuilder, generationPath) -// printFieldUsageTable(FirTreeBuilder) -// printHierarchyGraph(FirTreeBuilder) + val previouslyGeneratedFiles = collectPreviouslyGeneratedFiles(generationPath) + val generatedFiles = generateElements(FirTreeBuilder, generationPath) + generatedFiles.forEach { GeneratorsFileUtil.writeFileIfContentChanged(it.file, it.newText, logNotChanged = false) } + removeExtraFilesFromPreviousGeneration(previouslyGeneratedFiles, generatedFiles.map { it.file }) } + diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/builder.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/builder.kt index 25bd5c33832..0469f8c03ad 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/builder.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/builder.kt @@ -9,11 +9,11 @@ import org.jetbrains.kotlin.fir.tree.generator.declarationAttributesType import org.jetbrains.kotlin.fir.tree.generator.model.* import java.io.File -fun Builder.generateCode(generationPath: File) { +fun Builder.generateCode(generationPath: File): GeneratedFile { val dir = generationPath.resolve(packageName.replace(".", "/")) - dir.mkdirs() val file = File(dir, "$type.kt") - file.useSmartPrinter { + val stringBuilder = StringBuilder() + SmartPrinter(stringBuilder).apply { printCopyright() println("package $packageName") println() @@ -25,6 +25,7 @@ fun Builder.generateCode(generationPath: File) { printGeneratedMessage() printBuilder(this@generateCode) } + return GeneratedFile(file, stringBuilder.toString()) } private fun SmartPrinter.printBuilder(builder: Builder) { diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/element.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/element.kt index ed18ca26e6f..6dd34ae87a2 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/element.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/element.kt @@ -12,11 +12,11 @@ import org.jetbrains.kotlin.fir.tree.generator.util.get import java.io.File -fun Element.generateCode(generationPath: File) { +fun Element.generateCode(generationPath: File): GeneratedFile { val dir = generationPath.resolve(packageName.replace(".", "/")) - dir.mkdirs() val file = File(dir, "$type.kt") - file.useSmartPrinter { + val stringBuilder = StringBuilder() + SmartPrinter(stringBuilder).apply { printCopyright() println("package $packageName") println() @@ -28,6 +28,7 @@ fun Element.generateCode(generationPath: File) { printGeneratedMessage() printElement(this@generateCode) } + return GeneratedFile(file, stringBuilder.toString()) } fun SmartPrinter.printElement(element: Element) { diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/implementation.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/implementation.kt index 031d4fe7e24..5008e12f2e7 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/implementation.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/implementation.kt @@ -10,11 +10,11 @@ import org.jetbrains.kotlin.fir.tree.generator.pureAbstractElementType import java.io.File -fun Implementation.generateCode(generationPath: File) { +fun Implementation.generateCode(generationPath: File): GeneratedFile { val dir = generationPath.resolve(packageName.replace(".", "/")) - dir.mkdirs() val file = File(dir, "$type.kt") - file.useSmartPrinter { + val stringBuilder = StringBuilder() + SmartPrinter(stringBuilder).apply { printCopyright() println("package $packageName") println() @@ -26,6 +26,7 @@ fun Implementation.generateCode(generationPath: File) { printGeneratedMessage() printImplementation(this@generateCode) } + return GeneratedFile(file, stringBuilder.toString()) } fun SmartPrinter.printImplementation(implementation: Implementation) { diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt index d2881db706a..bea66e0830c 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt @@ -19,15 +19,17 @@ val GENERATED_MESSAGE = """ */ """.trimIndent() -fun printElements(builder: AbstractFirTreeBuilder, generationPath: File) { - builder.elements.forEach { it.generateCode(generationPath) } - builder.elements.flatMap { it.allImplementations }.forEach { it.generateCode(generationPath) } - builder.elements.flatMap { it.allImplementations }.mapNotNull { it.builder }.forEach { it.generateCode(generationPath) } - builder.intermediateBuilders.forEach { it.generateCode(generationPath) } +fun generateElements(builder: AbstractFirTreeBuilder, generationPath: File): List { + val generatedFiles = mutableListOf() + builder.elements.mapTo(generatedFiles) { it.generateCode(generationPath) } + builder.elements.flatMap { it.allImplementations }.mapTo(generatedFiles) { it.generateCode(generationPath) } + builder.elements.flatMap { it.allImplementations }.mapNotNull { it.builder }.mapTo(generatedFiles) { it.generateCode(generationPath) } + builder.intermediateBuilders.mapTo(generatedFiles) { it.generateCode(generationPath) } - printVisitor(builder.elements, generationPath) - printVisitorVoid(builder.elements, generationPath) - printTransformer(builder.elements, generationPath) + generatedFiles += printVisitor(builder.elements, generationPath) + generatedFiles += printVisitorVoid(builder.elements, generationPath) + generatedFiles += printTransformer(builder.elements, generationPath) + return generatedFiles } fun SmartPrinter.printCopyright() { diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/transformer.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/transformer.kt index b9e8bd8f538..2b9565e36d4 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/transformer.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/transformer.kt @@ -11,10 +11,11 @@ import org.jetbrains.kotlin.fir.tree.generator.model.Element import java.io.File -fun printTransformer(elements: List, generationPath: File) { +fun printTransformer(elements: List, generationPath: File): GeneratedFile { val dir = File(generationPath, VISITOR_PACKAGE.replace(".", "/")) - dir.mkdirs() - File(dir, "FirTransformer.kt").useSmartPrinter { + val file = File(dir, "FirTransformer.kt") + val stringBuilder = StringBuilder() + SmartPrinter(stringBuilder).apply { printCopyright() println("package $VISITOR_PACKAGE") println() @@ -62,4 +63,5 @@ fun printTransformer(elements: List, generationPath: File) { } println("}") } + return GeneratedFile(file, stringBuilder.toString()) } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/utils.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/utils.kt index 59e535efbda..2a2c1947e75 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/utils.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/utils.kt @@ -10,6 +10,10 @@ import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeBuilder import org.jetbrains.kotlin.fir.tree.generator.firImplementationDetailType import org.jetbrains.kotlin.fir.tree.generator.model.* import org.jetbrains.kotlin.fir.tree.generator.pureAbstractElementType +import org.jetbrains.kotlin.utils.addToStdlib.runIf +import java.io.File + +class GeneratedFile(val file: File, val newText: String) enum class ImportKind(val postfix: String) { Element(""), Implementation(".impl"), Builder(".builder") diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/visitor.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/visitor.kt index bad81737cc2..8d1fc2162be 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/visitor.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/visitor.kt @@ -7,14 +7,13 @@ package org.jetbrains.kotlin.fir.tree.generator.printer import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeBuilder import org.jetbrains.kotlin.fir.tree.generator.model.Element - import java.io.File -import java.io.PrintWriter -fun printVisitor(elements: List, generationPath: File) { +fun printVisitor(elements: List, generationPath: File): GeneratedFile { val dir = File(generationPath, VISITOR_PACKAGE.replace(".", "/")) - dir.mkdirs() - File(dir, "FirVisitor.kt").useSmartPrinter { + val file = File(dir, "FirVisitor.kt") + val stringBuilder = StringBuilder() + SmartPrinter(stringBuilder).apply { printCopyright() println("package $VISITOR_PACKAGE") println() @@ -37,13 +36,15 @@ fun printVisitor(elements: List, generationPath: File) { popIndent() println("}") } + return GeneratedFile(file, stringBuilder.toString()) } -fun printVisitorVoid(elements: List, generationPath: File) { +fun printVisitorVoid(elements: List, generationPath: File): GeneratedFile { val dir = File(generationPath, VISITOR_PACKAGE.replace(".", "/")) - dir.mkdirs() - File(dir, "FirVisitorVoid.kt").useSmartPrinter { + val file = File(dir, "FirVisitorVoid.kt") + val stringBuilder = StringBuilder() + SmartPrinter(stringBuilder).apply { printCopyright() println("package $VISITOR_PACKAGE") println() @@ -83,4 +84,5 @@ fun printVisitorVoid(elements: List, generationPath: File) { } println("}") } + return GeneratedFile(file, stringBuilder.toString()) } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/util/Cleanuper.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/util/Cleanuper.kt index 5279ff9c051..bcd5ad8b220 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/util/Cleanuper.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/util/Cleanuper.kt @@ -6,12 +6,25 @@ package org.jetbrains.kotlin.fir.tree.generator.util import org.jetbrains.kotlin.fir.tree.generator.printer.GENERATED_MESSAGE +import org.jetbrains.kotlin.generators.util.GeneratorsFileUtil import java.io.File -fun removePreviousGeneratedFiles(generationPath: File) { - generationPath.walkTopDown().forEach { - if (it.isFile && it.readText().contains(GENERATED_MESSAGE)) { - it.delete() +fun collectPreviouslyGeneratedFiles(generationPath: File): List { + return generationPath.walkTopDown().filter { + it.isFile && it.readText().contains(GENERATED_MESSAGE) + }.toList() +} + +fun removeExtraFilesFromPreviousGeneration(previouslyGeneratedFiles: List, generatedFiles: List) { + val generatedFilesPath = generatedFiles.mapTo(mutableSetOf()) { it.absolutePath } + + for (file in previouslyGeneratedFiles) { + if (file.absolutePath !in generatedFilesPath) { + if (GeneratorsFileUtil.isTeamCityBuild) { + GeneratorsFileUtil.assertTeamCityMode() + } + println("Deleted: ${file.absolutePath}") + file.delete() } } -} \ No newline at end of file +} diff --git a/compiler/testData/binaryCompatibility/klibEvolution/newFakeOverride.kt.disabled b/compiler/testData/binaryCompatibility/klibEvolution/newFakeOverride.kt similarity index 75% rename from compiler/testData/binaryCompatibility/klibEvolution/newFakeOverride.kt.disabled rename to compiler/testData/binaryCompatibility/klibEvolution/newFakeOverride.kt index ef0dc94f9aa..1957d894f76 100644 --- a/compiler/testData/binaryCompatibility/klibEvolution/newFakeOverride.kt.disabled +++ b/compiler/testData/binaryCompatibility/klibEvolution/newFakeOverride.kt @@ -2,15 +2,12 @@ // FILE: A.kt // VERSION: 1 -open class X { - val hasFoo = false -} +open class X // FILE: B.kt // VERSION: 2 open class X { - val hasFoo = false open fun foo(): String = "new member" } @@ -33,15 +30,6 @@ fun qux(): String = Y().foo() // MODULE: mainLib(lib) // FILE: mainLib.kt -fun qux(): String { - val y = Y() - if (y.hasFoo()) { - foo() - } else { - "no foo" - } -} - fun lib(): String = when { qux() != "new member" -> "fail 1" diff --git a/compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments.kt b/compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments.kt index c29261ec4be..712d3deafde 100644 --- a/compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments.kt +++ b/compiler/testData/codegen/box/functions/bigArity/callWithIncorrectNumberOfArguments.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +FunctionTypesWithBigArity -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // TARGET_BACKEND: JVM // FILE: J.java diff --git a/compiler/testData/codegen/box/invokedynamic/sam/streamApi1.kt b/compiler/testData/codegen/box/invokedynamic/sam/streamApi1.kt index 9ca50ed75bc..29d4105043f 100644 --- a/compiler/testData/codegen/box/invokedynamic/sam/streamApi1.kt +++ b/compiler/testData/codegen/box/invokedynamic/sam/streamApi1.kt @@ -4,6 +4,10 @@ // SAM_CONVERSIONS: INDY // WITH_RUNTIME // FULL_JDK + +// no stream api on Android +// IGNORE_BACKEND: ANDROID + import java.util.stream.Collectors fun box(): String { diff --git a/compiler/testData/codegen/box/invokedynamic/sam/streamApi2.kt b/compiler/testData/codegen/box/invokedynamic/sam/streamApi2.kt index 7463f0f7d5e..acf3669d37f 100644 --- a/compiler/testData/codegen/box/invokedynamic/sam/streamApi2.kt +++ b/compiler/testData/codegen/box/invokedynamic/sam/streamApi2.kt @@ -4,6 +4,10 @@ // SAM_CONVERSIONS: INDY // WITH_RUNTIME // FULL_JDK + +// no stream api on Android +// IGNORE_BACKEND: ANDROID + import java.util.stream.* fun box(): String { diff --git a/compiler/tests-common-new/build.gradle.kts b/compiler/tests-common-new/build.gradle.kts index c3164bb369d..d7a5f84cec3 100644 --- a/compiler/tests-common-new/build.gradle.kts +++ b/compiler/tests-common-new/build.gradle.kts @@ -14,7 +14,6 @@ dependencies { testCompileOnly(project(":kotlin-reflect-api")) testRuntimeOnly(project(":kotlin-reflect")) testRuntimeOnly(project(":core:descriptors.runtime")) - testRuntimeOnly(androidDxJar()) testImplementation(projectTests(":generators:test-generator")) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/DxCheckerHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/DxCheckerHandler.kt index 29cc5360493..0508bdf41e6 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/DxCheckerHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/DxCheckerHandler.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.test.backend.handlers import org.jetbrains.kotlin.codegen.D8Checker -import org.jetbrains.kotlin.codegen.DxChecker import org.jetbrains.kotlin.test.directives.CodegenTestDirectives import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.IGNORE_DEXING import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.RUN_DEX_CHECKER @@ -21,7 +20,6 @@ class DxCheckerHandler(testServices: TestServices) : JvmBinaryArtifactHandler(te override fun processModule(module: TestModule, info: BinaryArtifacts.Jvm) { if (RUN_DEX_CHECKER !in module.directives || IGNORE_DEXING in module.directives) return - DxChecker.check(info.classFileFactory) D8Checker.check(info.classFileFactory) } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/utils/FirIdenticalCheckerHelper.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/utils/FirIdenticalCheckerHelper.kt index 7767aa1390b..cc730bdf849 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/utils/FirIdenticalCheckerHelper.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/utils/FirIdenticalCheckerHelper.kt @@ -11,6 +11,10 @@ import org.jetbrains.kotlin.test.services.assertions import java.io.File abstract class FirIdenticalCheckerHelper(private val testServices: TestServices) { + companion object { + private val isTeamCityBuild: Boolean = System.getProperty("TEAMCITY_VERSION") != null + } + abstract fun getClassicFileToCompare(testDataFile: File): File? abstract fun getFirFileToCompare(testDataFile: File): File? @@ -35,21 +39,31 @@ abstract class FirIdenticalCheckerHelper(private val testServices: TestServices) } fun addDirectiveToClassicFileAndAssert(testDataFile: File) { - val classicFileContent = testDataFile.readText() - testDataFile.writer().use { - it.appendLine("// ${FirDiagnosticsDirectives.FIR_IDENTICAL.name}") - it.append(classicFileContent) + if (!isTeamCityBuild) { + val classicFileContent = testDataFile.readText() + testDataFile.writer().use { + it.appendLine("// ${FirDiagnosticsDirectives.FIR_IDENTICAL.name}") + it.append(classicFileContent) + } + } + + val message = if (isTeamCityBuild) { + "Please remove .fir.txt dump and add // FIR_IDENTICAL to test source" + } else { + "Deleted .fir.txt dump, added // FIR_IDENTICAL to test source" } testServices.assertions.fail { """ Dumps via FIR & via old FE are the same. - Deleted .fir.txt dump, added // FIR_IDENTICAL to test source + $message Please re-run the test now """.trimIndent() } } fun deleteFirFile(testDataFile: File) { - getFirFileToCompare(testDataFile)?.takeIf { it.exists() }?.delete() + if (!isTeamCityBuild) { + getFirFileToCompare(testDataFile)?.takeIf { it.exists() }?.delete() + } } } diff --git a/compiler/tests-common/build.gradle.kts b/compiler/tests-common/build.gradle.kts index 74da03d5318..e9309a9b122 100644 --- a/compiler/tests-common/build.gradle.kts +++ b/compiler/tests-common/build.gradle.kts @@ -52,7 +52,6 @@ dependencies { testCompile(project(":kotlin-scripting-compiler-impl")) testCompile(projectTests(":compiler:test-infrastructure-utils")) testCompile(commonDep("junit:junit")) - testCompile(androidDxJar()) { isTransitive = false } testCompile(commonDep("com.android.tools:r8")) testCompileOnly(project(":kotlin-reflect-api")) testCompileOnly(toolsJar()) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java index 28920900454..503226c2192 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java @@ -315,8 +315,7 @@ public abstract class CodegenTestCase extends KotlinBaseTest InTextDirectivesUtils.isDirectiveDefined(it.getText(), "IGNORE_DEXING") ); - if (verifyWithDex() && DxChecker.RUN_DX_CHECKER && !ignoreDexing) { - DxChecker.check(classFileFactory); + if (verifyWithDex() && D8Checker.RUN_D8_CHECKER && !ignoreDexing) { D8Checker.check(classFileFactory); } } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/compatibility/binary/AbstractKlibBinaryCompatibilityTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/compatibility/binary/AbstractKlibBinaryCompatibilityTest.kt new file mode 100644 index 00000000000..3a7df264152 --- /dev/null +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/compatibility/binary/AbstractKlibBinaryCompatibilityTest.kt @@ -0,0 +1,104 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.compatibility.binary + +import org.jetbrains.kotlin.test.* +import org.jetbrains.kotlin.test.util.KtTestUtil +import org.jetbrains.kotlin.utils.DFS +import java.io.File + +class TestFile(val module: TestModule, fileName: String, text: String, directives: Directives) + : KotlinBaseTest.TestFile(fileName, text, directives) { + init { + module.files.add(this) + } + val version: Int? = directives["VERSION"]?.toInt() +} + +class TestModule(name: String, dependenciesSymbols: List, friends: List) + : KotlinBaseTest.TestModule(name, dependenciesSymbols, friends) { + + val files = mutableListOf() + val hasVersions get() = files.any { it.version != null } + fun versionFiles(version: Int) = files.filter { it.version == null || it.version == version } +} + +abstract class AbstractKlibBinaryCompatibilityTest : KotlinTestWithEnvironment() { + + private val pathToRootOutputDir = System.getProperty("kotlin.js.test.root.out.dir") ?: error("'kotlin.js.test.root.out.dir' is not set") + private val testGroupSuffix = "binaryCompatibility/" + protected lateinit var workingDir: File + + fun doTest(filePath: String) { + workingDir = File(pathToRootOutputDir + "out/$testGroupSuffix" + filePath) + workingDir.mkdirs() + doTestWithIgnoringByFailFile(filePath) + } + + fun doTestWithIgnoringByFailFile(filePath: String) { + val failFile = File("$filePath.fail") + try { + doTest(filePath, "OK") + } catch (e: Throwable) { + if (failFile.exists()) { + KotlinTestUtils.assertEqualsToFile(failFile, e.message ?: "") + } else { + throw e + } + } + } + + fun doTest(filePath: String, expectedResult: String) { + val file = File(filePath) + val fileContent = KtTestUtil.doLoadFile(file) + + val inputFiles = TestFiles.createTestFiles( + file.name, + fileContent, + object : TestFiles.TestFileFactory { + override fun createFile(module: TestModule?, fileName: String, text: String, directives: Directives) = + module?.let { + TestFile(module, fileName, text, directives) + } ?: error("Expected a module for $fileName in $filePath") + + override fun createModule(name: String, dependencies: List, friends: List) = + TestModule(name, dependencies, friends) + + }, + true, + true + ) + val modules = inputFiles + .map { it.module }.distinct() + .map { it.name to it }.toMap() + + val orderedModules = DFS.topologicalOrder(modules.values) { module -> + module.dependenciesSymbols.mapNotNull { modules[it] } + } + + val mainModuleName = DEFAULT_MODULE + val mainModule = modules[mainModuleName] ?: error("No module with name \"$mainModuleName\"") + + orderedModules.reversed().filterNot { it === mainModule }.forEach { + produceKlib(it, 1) + if (it.hasVersions) { + produceKlib(it, 2) + } + } + produceProgram(mainModule) + + runProgram(mainModule, expectedResult) + } + + abstract fun produceKlib(module: TestModule, version: Int) + abstract fun produceProgram(module: TestModule) + abstract fun runProgram(module: TestModule, expectedResult: String) + + companion object { + val TEST_FUNCTION = "box" + val DEFAULT_MODULE = "main" + } +} diff --git a/compiler/tests-compiler-utils/build.gradle.kts b/compiler/tests-compiler-utils/build.gradle.kts index 6cb933b3a15..b4f0990772d 100644 --- a/compiler/tests-compiler-utils/build.gradle.kts +++ b/compiler/tests-compiler-utils/build.gradle.kts @@ -25,7 +25,6 @@ dependencies { testCompile(project(":compiler:fir:entrypoint")) testCompile(projectTests(":compiler:test-infrastructure-utils")) testCompile(project(":kotlin-preloader")) - testCompile(androidDxJar()) { isTransitive = false } testCompile(commonDep("com.android.tools:r8")) testCompileOnly(intellijCoreDep()) { includeJars("intellij-core") } diff --git a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/D8Checker.java b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/D8Checker.java index 6f1755e181c..4849709db52 100644 --- a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/D8Checker.java +++ b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/D8Checker.java @@ -20,6 +20,8 @@ import java.util.function.Consumer; public class D8Checker { + public static final boolean RUN_D8_CHECKER = true; + private D8Checker() { } diff --git a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/DxChecker.java b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/DxChecker.java deleted file mode 100644 index bbdfa49ea31..00000000000 --- a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/DxChecker.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.codegen; - -import com.android.dx.cf.direct.DirectClassFile; -import com.android.dx.cf.direct.StdAttributeFactory; -import com.android.dx.command.dexer.Main; -import com.android.dx.dex.cf.CfTranslator; -import com.android.dx.dex.file.DexFile; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.backend.common.output.OutputFile; -import org.jetbrains.kotlin.test.KtAssert; -import org.jetbrains.org.objectweb.asm.Opcodes; - -import java.io.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class DxChecker { - - public static final boolean RUN_DX_CHECKER = true; - private static final Pattern STACK_TRACE_PATTERN = Pattern.compile("[\\s]+at .*"); - - private DxChecker() { - } - - public static void check(ClassFileFactory outputFiles) { - Main.Arguments arguments = new Main.Arguments(); - String[] array = new String[1]; - array[0] = "testArgs"; - arguments.parse(array); - - for (OutputFile file : ClassFileUtilsKt.getClassFiles(outputFiles)) { - try { - byte[] bytes = file.asByteArray(); - if (isJava6Class(bytes)) { - checkFileWithDx(bytes, file.getRelativePath(), arguments); - } - } - catch (Throwable e) { - KtAssert.fail(generateExceptionMessage(e)); - } - } - } - - private static boolean isJava6Class(byte[] bytes) throws IOException { - try (DataInputStream stream = new DataInputStream(new ByteArrayInputStream(bytes))) { - int header = stream.readInt(); - if (0xCAFEBABE != header) { - throw new IOException("Invalid header class header: " + header); - } - int minor = stream.readUnsignedShort(); - int major = stream.readUnsignedShort(); - return major == Opcodes.V1_6; - } - } - - public static void checkFileWithDx(byte[] bytes, @NotNull String relativePath) { - Main.Arguments arguments = new Main.Arguments(); - String[] array = new String[1]; - array[0] = "testArgs"; - arguments.parse(array); - checkFileWithDx(bytes, relativePath, arguments); - } - - private static void checkFileWithDx(byte[] bytes, @NotNull String relativePath, @NotNull Main.Arguments arguments) { - DirectClassFile cf = new DirectClassFile(bytes, relativePath, true); - cf.setAttributeFactory(StdAttributeFactory.THE_ONE); - CfTranslator.translate( - cf, - bytes, - arguments.cfOptions, - arguments.dexOptions, - new DexFile(arguments.dexOptions) - ); - } - - private static String generateExceptionMessage(Throwable e) { - StringWriter writer = new StringWriter(); - try (PrintWriter printWriter = new PrintWriter(writer)) { - e.printStackTrace(printWriter); - String stackTrace = writer.toString(); - Matcher matcher = STACK_TRACE_PATTERN.matcher(stackTrace); - return matcher.replaceAll(""); - } - } -} diff --git a/compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt b/compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt index 1521c342c19..32b24b54b04 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/cli/LauncherScriptTest.kt @@ -33,7 +33,8 @@ class LauncherScriptTest : TestCaseWithTmpdir() { expectedStdout: String = "", expectedStderr: String = "", expectedExitCode: Int = 0, - workDirectory: File? = null + workDirectory: File? = null, + environment: Map = emptyMap(), ) { val executableFileName = if (SystemInfo.isWindows) "$executableName.bat" else executableName val launcherFile = File(PathUtil.kotlinPathsForDistDirectory.homePath, "bin/$executableFileName") @@ -43,9 +44,10 @@ class LauncherScriptTest : TestCaseWithTmpdir() { // So, use ProcessBuilder instead. val pb = ProcessBuilder( launcherFile.absolutePath, - // In cmd, `=` is delimeter, so we need to surround parameter with quotes. + // In cmd, `=` is delimiter, so we need to surround parameter with quotes. *quoteIfNeeded(args) ) + pb.environment().putAll(environment) pb.directory(workDirectory) val process = pb.start() val stdout = @@ -334,4 +336,17 @@ fun f() : Result = Result.success(42) ) runProcess("kotlin", "-howtorun", "classfile", "test.HelloWorldKt", expectedStdout = "Hello!\n", workDirectory = tmpdir) } + + fun testKotlincJdk15() { + val jdk15 = mapOf("JAVA_HOME" to KtTestUtil.getJdk15Home().absolutePath) + runProcess( + "kotlinc", "$testDataDirectory/helloWorld.kt", "-d", tmpdir.path, + environment = jdk15, + ) + + runProcess( + "kotlin", "-e", "listOf('O'.toString() + 'K')", + expectedStdout = "[OK]\n", environment = jdk15, + ) + } } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/TestStdlibWithDxTest.kt b/compiler/tests/org/jetbrains/kotlin/codegen/TestStdlibWithDxTest.kt index e0d80f87884..c1e750849bc 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/TestStdlibWithDxTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/codegen/TestStdlibWithDxTest.kt @@ -39,7 +39,6 @@ class TestStdlibWithDxTest { for (entry in generateSequence { zip.nextEntry }) { if (entry.name.endsWith(".class") && !entry.name.startsWith("META-INF/")) { val bytes = zip.readBytes() - DxChecker.checkFileWithDx(bytes, entry.name) files.add(Pair(bytes, entry.name)) } } diff --git a/dependencies/android-dx/build.gradle.kts b/dependencies/android-dx/build.gradle.kts deleted file mode 100644 index 644e627a235..00000000000 --- a/dependencies/android-dx/build.gradle.kts +++ /dev/null @@ -1,100 +0,0 @@ -import java.net.URI - -plugins { - base - `maven-publish` - id("com.jfrog.bintray") version "1.8.4" -} - -apply(from = "../../gradle/versions.gradle.kts") - -val androidBuildToolsVersion = extra["versions.androidBuildTools"] as String -val androidDxSourcesVersion = extra["versions.androidDxSources"] as String - -group = "org.jetbrains.kotlin" -version = androidBuildToolsVersion - -repositories { - ivy { - url = URI("https://dl.google.com/android/repository") - - patternLayout { - artifact("[artifact]_[revision](-[classifier]).[ext]") - } - - metadataSources { - artifact() - } - } - - - ivy { - url = URI("https://android.googlesource.com/platform/dalvik/+archive/android-$androidDxSourcesVersion") - - patternLayout { - artifact("[artifact].[ext]") - } - - metadataSources { - artifact() - } - } -} - -val androidBuildTools by configurations.creating -val androidDxSources by configurations.creating - -val androidDxRevision = androidBuildToolsVersion - -dependencies { - androidBuildTools("google:build-tools:$androidBuildToolsVersion:linux@zip") - androidDxSources("google:dx:0@tar.gz") -} - -val unzipDxJar by tasks.registering { - val outputDir = File(buildDir, name) - val outputFile = File(outputDir, "dx.jar") - - dependsOn(androidBuildTools) - inputs.files(androidBuildTools) - outputs.files(outputFile) - - doFirst { - project.copy { - from(zipTree(androidBuildTools.singleFile).files) - include("**/dx.jar") - into(outputDir) - } - } -} - -val untarDxSources by tasks.registering { - val dxSourcesTargetDir = File(buildDir, name) - dependsOn(androidDxSources) - inputs.files(androidDxSources) - outputs.dir(dxSourcesTargetDir) - doFirst { - project.copy { - from(tarTree(androidDxSources.singleFile)) - include("src/**") - includeEmptyDirs = false - into(dxSourcesTargetDir) - } - } -} - -val prepareDxSourcesJar by tasks.registering(Jar::class) { - dependsOn(untarDxSources) - from(untarDxSources) - - archiveClassifier.set("sources") -} - -val dxArtifact = artifacts.add("default", unzipDxJar.outputs.files.singleFile) { - builtBy(unzipDxJar) -} - -artifacts.add("archives", dxArtifact) -artifacts.add("archives", prepareDxSourcesJar) - -apply(from="../publishing.gradle.kts") diff --git a/dependencies/android-dx/settings.gradle b/dependencies/android-dx/settings.gradle deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/generators/main/GeneratorsFileUtil.kt b/generators/main/GeneratorsFileUtil.kt index cf45f05a5e7..b1073fb75e9 100644 --- a/generators/main/GeneratorsFileUtil.kt +++ b/generators/main/GeneratorsFileUtil.kt @@ -11,6 +11,8 @@ import java.io.IOException import kotlin.io.path.* object GeneratorsFileUtil { + val isTeamCityBuild: Boolean = System.getProperty("TEAMCITY_VERSION") != null + @OptIn(ExperimentalPathApi::class) @JvmStatic @JvmOverloads @@ -18,6 +20,7 @@ object GeneratorsFileUtil { fun writeFileIfContentChanged(file: File, newText: String, logNotChanged: Boolean = true) { val parentFile = file.parentFile if (!parentFile.exists()) { + if (isTeamCityBuild) assertTeamCityMode() if (parentFile.mkdirs()) { println("Directory created: " + parentFile.absolutePath) } else { @@ -30,6 +33,7 @@ object GeneratorsFileUtil { } return } + if (isTeamCityBuild) assertTeamCityMode() val useTempFile = !SystemInfo.isWindows val targetFile = file.toPath() val tempFile = @@ -43,6 +47,10 @@ object GeneratorsFileUtil { println() } + fun assertTeamCityMode(): Nothing { + throw IllegalStateException("You should commit all newly generated files before pushing them to TeamCity") + } + fun isFileContentChangedIgnoringLineSeparators(file: File, content: String): Boolean { val currentContent: String = try { StringUtil.convertLineSeparators(file.readText(Charsets.UTF_8)) @@ -51,4 +59,4 @@ object GeneratorsFileUtil { } return StringUtil.convertLineSeparators(content) != currentContent } -} \ No newline at end of file +} diff --git a/gradle/versions.properties b/gradle/versions.properties index ca6dc95ec97..4d501d53c02 100644 --- a/gradle/versions.properties +++ b/gradle/versions.properties @@ -1,5 +1,4 @@ versions.intellijSdk=202.7660.26 -versions.androidBuildTools=r23.0.1 versions.idea.NodeJS=193.6494.7 versions.jar.asm-all=8.0.1 versions.jar.guava=29.0-jre diff --git a/gradle/versions.properties.201 b/gradle/versions.properties.201 index bd6471bb797..eaa5a3ee09e 100644 --- a/gradle/versions.properties.201 +++ b/gradle/versions.properties.201 @@ -1,5 +1,4 @@ versions.intellijSdk=201.7223.91 -versions.androidBuildTools=r23.0.1 versions.idea.NodeJS=193.6494.7 versions.jar.asm-all=7.0.1 versions.jar.guava=28.2-jre diff --git a/gradle/versions.properties.203 b/gradle/versions.properties.203 index 42e072d2d78..92025f080f8 100644 --- a/gradle/versions.properties.203 +++ b/gradle/versions.properties.203 @@ -1,5 +1,4 @@ versions.intellijSdk=203-SNAPSHOT -versions.androidBuildTools=r23.0.1 versions.idea.NodeJS=193.6494.7 versions.jar.asm-all=8.0.1 versions.jar.guava=29.0-jre diff --git a/gradle/versions.properties.as41 b/gradle/versions.properties.as41 index b0d438049d8..fbbe449bfc1 100644 --- a/gradle/versions.properties.as41 +++ b/gradle/versions.properties.as41 @@ -1,5 +1,4 @@ versions.intellijSdk=201.7223.91 -versions.androidBuildTools=r23.0.1 versions.idea.NodeJS=193.6494.7 versions.androidStudioRelease=4.1.0.18 versions.androidStudioBuild=201.6823847 diff --git a/gradle/versions.properties.as42 b/gradle/versions.properties.as42 index 31a6cad549b..7983c2a0f03 100644 --- a/gradle/versions.properties.as42 +++ b/gradle/versions.properties.as42 @@ -1,5 +1,4 @@ versions.intellijSdk=202.6397.94 -versions.androidBuildTools=r23.0.1 versions.idea.NodeJS=193.6494.7 versions.androidStudioRelease=4.2.0.16 versions.androidStudioBuild=202.6939830 diff --git a/idea/idea-android/build.gradle.kts b/idea/idea-android/build.gradle.kts index ac0aa2f8a32..695c128ab4c 100644 --- a/idea/idea-android/build.gradle.kts +++ b/idea/idea-android/build.gradle.kts @@ -17,8 +17,6 @@ dependencies { compile(project(":idea:ide-common")) compile(project(":idea:idea-gradle")) - compile(androidDxJar()) - compileOnly(project(":kotlin-android-extensions-runtime")) compileOnly(intellijDep()) compileOnly(intellijPluginDep("android")) diff --git a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt index 0042c3b6ee6..de2b7e14f67 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt @@ -8,7 +8,11 @@ package org.jetbrains.kotlin.generators.tests import org.jetbrains.kotlin.generators.impl.generateTestGroupSuite import org.jetbrains.kotlin.js.test.AbstractDceTest import org.jetbrains.kotlin.js.test.AbstractJsLineNumberTest -import org.jetbrains.kotlin.js.test.es6.semantics.* +import org.jetbrains.kotlin.js.test.compatibility.binary.AbstractJsKlibBinaryCompatibilityTest +import org.jetbrains.kotlin.js.test.es6.semantics.AbstractIrBoxJsES6Test +import org.jetbrains.kotlin.js.test.es6.semantics.AbstractIrJsCodegenBoxES6Test +import org.jetbrains.kotlin.js.test.es6.semantics.AbstractIrJsCodegenInlineES6Test +import org.jetbrains.kotlin.js.test.es6.semantics.AbstractIrJsTypeScriptExportES6Test import org.jetbrains.kotlin.js.test.ir.semantics.* import org.jetbrains.kotlin.js.test.semantics.* import org.jetbrains.kotlin.js.test.wasm.semantics.AbstractIrCodegenBoxWasmTest @@ -124,5 +128,11 @@ fun main(args: Array) { model("codegen/box/arrays", targetBackend = TargetBackend.JS) } } + + testGroup("js/js.tests/tests-gen", "compiler/testData/binaryCompatibility", testRunnerMethodName = "runTest0") { + testClass { + model("klibEvolution", targetBackend = TargetBackend.JS_IR) + } + } } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/compatibility/binary/AbstractJsKlibBinaryCompatibilityTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/compatibility/binary/AbstractJsKlibBinaryCompatibilityTest.kt new file mode 100644 index 00000000000..7aba2083ece --- /dev/null +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/compatibility/binary/AbstractJsKlibBinaryCompatibilityTest.kt @@ -0,0 +1,111 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.js.test.compatibility.binary + +import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.cli.js.K2JSCompiler +import org.jetbrains.kotlin.compatibility.binary.* +import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles +import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment +import org.jetbrains.kotlin.config.* +import org.jetbrains.kotlin.js.test.V8JsTestChecker +import org.jetbrains.kotlin.library.KLIB_FILE_EXTENSION +import java.io.File + +abstract class AbstractJsKlibBinaryCompatibilityTest : AbstractKlibBinaryCompatibilityTest() { + + override fun createEnvironment() = + KotlinCoreEnvironment.createForTests(testRootDisposable, CompilerConfiguration(), EnvironmentConfigFiles.JS_CONFIG_FILES) + + private fun TestModule.name(version: Int) = if (this.hasVersions) "version$version/${this.name}" else this.name + + private fun List.toLibrariesArg(version: Int): String { + val fileNames = this.map { it.name(version) } + val allDependencies = fileNames.map { File(workingDir, it.klib).absolutePath } + STDLIB_DEPENDENCY + return allDependencies.joinToString(File.pathSeparator) + } + + private fun TestModule.dependenciesToLibrariesArg(version: Int): String = + this.dependencies.map { it as? TestModule ?: error("Unexpected dependency kind: $it") }.toLibrariesArg(version) + + private val TestModule.jsPath get() = File(workingDir, "${this.name}.js").absolutePath + + private fun createFiles(files: List): List = + files.map { + val file = File(workingDir, it.name) + file.writeText(it.content) + file.absolutePath + } + + private fun runnerFunctionFile(): String { + val file = File(workingDir, RUNNER_FUNCTION_FILE) + file.writeText(runnerFileText) + return file.absolutePath + } + + override fun produceKlib(module: TestModule, version: Int) { + val args = K2JSCompilerArguments().apply { + freeArgs = createFiles(module.versionFiles(version)) + libraries = module.dependenciesToLibrariesArg(version = version) + outputFile = File(workingDir, "${module.name(version)}.$KLIB_FILE_EXTENSION").absolutePath + irProduceKlibFile = true + irOnly = true + irModuleName = module.name + repositries = "$workingDir${File.pathSeparator}$workingDir/version$version" + } + K2JSCompiler().exec(TestMessageCollector(), Services.EMPTY, args) + } + + override fun produceProgram(module: TestModule) { + assert(!module.hasVersions) + val args = K2JSCompilerArguments().apply { + freeArgs = createFiles(module.files) + runnerFunctionFile() + libraries = module.dependenciesToLibrariesArg(version = 2) + outputFile = File(workingDir, module.name.js).absolutePath + irProduceJs = true + irOnly = true + irModuleName = module.name + repositries = "$workingDir${File.pathSeparator}$workingDir/version2" + } + K2JSCompiler().exec(TestMessageCollector(), Services.EMPTY, args) + } + + override fun runProgram(module: TestModule, expectedResult: String) { + testChecker.check(listOf(module.jsPath), module.name, null, RUNNER_FUNCTION, expectedResult, false) + } + + // TODO: ask js folks what to use here. + protected open val testChecker get() = V8JsTestChecker + + companion object { + private val String.klib: String get() = "$this.$KLIB_FILE_EXTENSION" + private val String.js: String get() = "$this.js" + + private val STDLIB_DEPENDENCY = System.getProperty("kotlin.js.full.stdlib.path") + + // A @JsExport wrapper for box(). + // Otherwise box() is not available in js. + private const val RUNNER_FUNCTION = "__js_exported_wrapper_function" + private const val RUNNER_FUNCTION_FILE = "js_exported_wrapper_function.kt" + private val runnerFileText = """ + @JsExport + fun $RUNNER_FUNCTION() = $TEST_FUNCTION() + """ + } +} + +abstract class AbstractJsKlibBinaryCompatibilityErrorTest : AbstractJsKlibBinaryCompatibilityTest() + +private class TestMessageCollector : MessageCollector { + override fun clear() {} + override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageSourceLocation?) { + if (severity.isError()) error(message) + } + override fun hasErrors(): Boolean = error("Unsupported operation") +} diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/compatibility/binary/JsKlibBinaryCompatibilityTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/compatibility/binary/JsKlibBinaryCompatibilityTestGenerated.java new file mode 100644 index 00000000000..d5862b67e21 --- /dev/null +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/compatibility/binary/JsKlibBinaryCompatibilityTestGenerated.java @@ -0,0 +1,227 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.js.test.compatibility.binary; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/binaryCompatibility/klibEvolution") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class JsKlibBinaryCompatibilityTestGenerated extends AbstractJsKlibBinaryCompatibilityTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + @TestMetadata("addAbstractMemberBody.kt") + public void testAddAbstractMemberBody() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/addAbstractMemberBody.kt"); + } + + @TestMetadata("addCompanionObject.kt") + public void testAddCompanionObject() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/addCompanionObject.kt"); + } + + @TestMetadata("addDefaultImplementations.kt") + public void testAddDefaultImplementations() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/addDefaultImplementations.kt"); + } + + @TestMetadata("addEnumClassMember.kt") + public void testAddEnumClassMember() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/addEnumClassMember.kt"); + } + + @TestMetadata("addLateinitToVar.kt") + public void testAddLateinitToVar() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/addLateinitToVar.kt"); + } + + @TestMetadata("addOpenToClass.kt") + public void testAddOpenToClass() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/addOpenToClass.kt"); + } + + @TestMetadata("addOpenToMember.kt") + public void testAddOpenToMember() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/addOpenToMember.kt"); + } + + @TestMetadata("addOrRemoveConst.kt") + public void testAddOrRemoveConst() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/addOrRemoveConst.kt"); + } + + @TestMetadata("addOrRemoveInitBlock.kt") + public void testAddOrRemoveInitBlock() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/addOrRemoveInitBlock.kt"); + } + + @TestMetadata("addOverloads.kt") + public void testAddOverloads() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/addOverloads.kt"); + } + + @TestMetadata("addParameterDefaulValue.kt") + public void testAddParameterDefaulValue() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/addParameterDefaulValue.kt"); + } + + @TestMetadata("addProeprtyAccessor.kt") + public void testAddProeprtyAccessor() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/addProeprtyAccessor.kt"); + } + + @TestMetadata("addingSealedClassMember.kt") + public void testAddingSealedClassMember() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/addingSealedClassMember.kt"); + } + + public void testAllFilesPresentInKlibEvolution() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/binaryCompatibility/klibEvolution"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @TestMetadata("changeBaseClassOrder.kt") + public void testChangeBaseClassOrder() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/changeBaseClassOrder.kt"); + } + + @TestMetadata("changeCompanionToNestedObject.kt") + public void testChangeCompanionToNestedObject() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/changeCompanionToNestedObject.kt"); + } + + @TestMetadata("changeConstInitialization.kt") + public void testChangeConstInitialization() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/changeConstInitialization.kt"); + } + + @TestMetadata("changeNamesOfTypeParameters.kt") + public void testChangeNamesOfTypeParameters() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/changeNamesOfTypeParameters.kt"); + } + + @TestMetadata("changeObjectToCompanion.kt") + public void testChangeObjectToCompanion() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/changeObjectToCompanion.kt"); + } + + @TestMetadata("changeParameterDefaultValue.kt") + public void testChangeParameterDefaultValue() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/changeParameterDefaultValue.kt"); + } + + @TestMetadata("changePropertyFromValToVar.kt") + public void testChangePropertyFromValToVar() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/changePropertyFromValToVar.kt"); + } + + @TestMetadata("changePropertyInitialization.kt") + public void testChangePropertyInitialization() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/changePropertyInitialization.kt"); + } + + @TestMetadata("constructorParameterMarkValVar.kt") + public void testConstructorParameterMarkValVar() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/constructorParameterMarkValVar.kt"); + } + + @TestMetadata("deleteOverrideMember.kt") + public void testDeleteOverrideMember() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/deleteOverrideMember.kt"); + } + + @TestMetadata("deletePrivateMembers.kt") + public void testDeletePrivateMembers() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/deletePrivateMembers.kt"); + } + + @TestMetadata("inlineBodyChange.kt") + public void testInlineBodyChange() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/inlineBodyChange.kt"); + } + + @TestMetadata("inlineFunction.kt") + public void testInlineFunction() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/inlineFunction.kt"); + } + + @TestMetadata("makeFunctionInfixOrTailrec.kt") + public void testMakeFunctionInfixOrTailrec() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/makeFunctionInfixOrTailrec.kt"); + } + + @TestMetadata("moreSpecificBaseClass.kt") + public void testMoreSpecificBaseClass() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/moreSpecificBaseClass.kt"); + } + + @TestMetadata("moveMemberUpInHierarchy.kt") + public void testMoveMemberUpInHierarchy() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/moveMemberUpInHierarchy.kt"); + } + + @TestMetadata("newFakeOverride.kt") + public void testNewFakeOverride() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/newFakeOverride.kt"); + } + + @TestMetadata("newOverrideMember.kt") + public void testNewOverrideMember() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/newOverrideMember.kt"); + } + + @TestMetadata("removeAbstractFromClass.kt") + public void testRemoveAbstractFromClass() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/removeAbstractFromClass.kt"); + } + + @TestMetadata("removeInfixOrTailrecFromFunction.kt") + public void testRemoveInfixOrTailrecFromFunction() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/removeInfixOrTailrecFromFunction.kt"); + } + + @TestMetadata("removeLateinitFromVar.kt") + public void testRemoveLateinitFromVar() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/removeLateinitFromVar.kt"); + } + + @TestMetadata("removePropertyAccessor.kt") + public void testRemovePropertyAccessor() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/removePropertyAccessor.kt"); + } + + @TestMetadata("renameArguments.kt") + public void testRenameArguments() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/renameArguments.kt"); + } + + @TestMetadata("reorderClassConstructors.kt") + public void testReorderClassConstructors() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/reorderClassConstructors.kt"); + } + + @TestMetadata("turnClassIntoDataClass.kt") + public void testTurnClassIntoDataClass() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/turnClassIntoDataClass.kt"); + } + + @TestMetadata("widenSuperMemberVisibility.kt") + public void testWidenSuperMemberVisibility() throws Exception { + runTest("compiler/testData/binaryCompatibility/klibEvolution/widenSuperMemberVisibility.kt"); + } +} diff --git a/kotlin-native/gradle.properties b/kotlin-native/gradle.properties index 2748bd2a5fc..2a24dff6d16 100644 --- a/kotlin-native/gradle.properties +++ b/kotlin-native/gradle.properties @@ -18,12 +18,12 @@ buildKotlinVersion=1.5.0-dev-2205 buildKotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.0-dev-2205,branch:default:any,pinned:true/artifacts/content/maven remoteRoot=konan_tests -kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.20-dev-7,branch:default:any,pinned:true/artifacts/content/maven -kotlinVersion=1.5.20-dev-7 -kotlinStdlibRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.20-dev-7,branch:default:any,pinned:true/artifacts/content/maven -kotlinStdlibVersion=1.5.20-dev-7 -kotlinStdlibTestsVersion=1.5.20-dev-7 -testKotlinCompilerVersion=1.5.20-dev-7 +kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.20-dev-60,branch:default:any,pinned:true/artifacts/content/maven +kotlinVersion=1.5.20-dev-60 +kotlinStdlibRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.20-dev-60,branch:default:any,pinned:true/artifacts/content/maven +kotlinStdlibVersion=1.5.20-dev-60 +kotlinStdlibTestsVersion=1.5.20-dev-60 +testKotlinCompilerVersion=1.5.20-dev-60 konanVersion=1.5.0 # A version of Xcode required to build the Kotlin/Native compiler. diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BuildCacheRelocationIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BuildCacheRelocationIT.kt index ffe9d8974ba..fe648cd1278 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BuildCacheRelocationIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BuildCacheRelocationIT.kt @@ -128,7 +128,8 @@ class BuildCacheRelocationIT : BaseGradleIT() { cacheableTaskNames = listOf( "kaptKotlin", "kaptGenerateStubsKotlin", "compileKotlin", "compileTestKotlin", "compileJava" ), - initProject = { File(projectDir, "build.gradle").appendText("\nkapt.useBuildCache = true") } + initProject = { File(projectDir, "build.gradle").appendText("\nkapt.useBuildCache = true") }, + withAnotherGradleHome = true ), TestCase("kotlin2JsDceProject", taskToExecute = arrayOf("assemble", "runDceKotlinJs"), diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/KaptWithoutKotlincTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/KaptWithoutKotlincTask.kt index 13ddd296c08..e6c23f37ad8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/KaptWithoutKotlincTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/KaptWithoutKotlincTask.kt @@ -50,7 +50,7 @@ abstract class KaptWithoutKotlincTask @Inject constructor(private val workerExec @get:Input internal val kotlinAndroidPluginWrapperPluginDoesNotExist = project.plugins.none { it is KotlinAndroidPluginWrapper } - @get:Input + @get:Classpath internal val kotlinStdlibClasspath = findKotlinStdlibClasspath(project) @get:Internal diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/DefaultLanguageSettingsBuilder.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/DefaultLanguageSettingsBuilder.kt index 2282e663d4d..8591786e969 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/DefaultLanguageSettingsBuilder.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/DefaultLanguageSettingsBuilder.kt @@ -131,7 +131,16 @@ internal fun applyLanguageSettingsToKotlinOptions( } } -private val apiVersionValues = ApiVersion.run { listOf(KOTLIN_1_0, KOTLIN_1_1, KOTLIN_1_2, KOTLIN_1_3, KOTLIN_1_4) } +private val apiVersionValues = ApiVersion.run { + listOf( + KOTLIN_1_0, + KOTLIN_1_1, + KOTLIN_1_2, + KOTLIN_1_3, + KOTLIN_1_4, + KOTLIN_1_5 + ) +} internal fun parseLanguageVersionSetting(versionString: String) = LanguageVersion.fromVersionString(versionString) internal fun parseApiVersionSettings(versionString: String) = apiVersionValues.find { it.versionString == versionString }