[MERGE] KT: build-1.5.20-dev-1166 KT/N: 149cc4065 OLD: 3ee0dc112

This commit is contained in:
Vasily Levchenko
2021-02-24 11:01:19 +01:00
2728 changed files with 41319 additions and 31007 deletions
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Generate FIR Checker Components and FIR/IDE Diagnostics" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":compiler:fir:checkers:generateCheckersComponents" />
<option value=":idea:idea-frontend-fir:generateCode" />
</list>
</option>
<option name="vmOptions" value="" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2" />
</configuration>
</component>
@@ -94,6 +94,10 @@ open class IncrementalJvmCache(
fun sourcesByInternalName(internalName: String): Collection<File> =
internalNameToSource[internalName]
fun getAllPartsOfMultifileFacade(facade: JvmClassName): Collection<String>? {
return multifileFacadeToParts[facade]
}
fun isMultifileFacade(className: JvmClassName): Boolean =
className in multifileFacadeToParts
@@ -425,6 +429,8 @@ open class IncrementalJvmCache(
private inner class MultifileClassFacadeMap(storageFile: File) :
BasicStringMap<Collection<String>>(storageFile, StringCollectionExternalizer) {
@Synchronized
operator fun set(className: JvmClassName, partNames: Collection<String>) {
storage[className.internalName] = partNames
}
@@ -435,6 +441,7 @@ open class IncrementalJvmCache(
operator fun contains(className: JvmClassName): Boolean =
className.internalName in storage
@Synchronized
fun remove(className: JvmClassName) {
storage.remove(className.internalName)
}
@@ -444,6 +451,8 @@ open class IncrementalJvmCache(
private inner class MultifileClassPartMap(storageFile: File) :
BasicStringMap<String>(storageFile, EnumeratorStringDescriptor.INSTANCE) {
@Synchronized
fun set(partName: String, facadeName: String) {
storage[partName] = facadeName
}
@@ -451,6 +460,7 @@ open class IncrementalJvmCache(
fun get(partName: JvmClassName): String? =
storage[partName.internalName]
@Synchronized
fun remove(className: JvmClassName) {
storage.remove(className.internalName)
}
+8 -9
View File
@@ -325,16 +325,8 @@ extra["tasksWithWarnings"] = listOf(
":kotlin-stdlib:compileTestKotlin",
":kotlin-stdlib-jdk7:compileTestKotlin",
":kotlin-stdlib-jdk8:compileTestKotlin",
":compiler:cli:compileKotlin",
":compiler:frontend:compileKotlin",
":compiler:fir:tree:compileKotlin",
":compiler:fir:resolve:compileKotlin",
":compiler:fir:checkers:compileKotlin",
":compiler:fir:java:compileKotlin",
":kotlin-scripting-compiler:compileKotlin",
":plugins:uast-kotlin:compileKotlin",
":plugins:uast-kotlin:compileTestKotlin",
":plugins:uast-kotlin-idea:compileKotlin"
":plugins:uast-kotlin:compileTestKotlin"
)
val tasksWithWarnings: List<String> by extra
@@ -773,6 +765,7 @@ tasks {
register("toolsTest") {
dependsOn(":tools:kotlinp:test")
dependsOn(":native:kotlin-klib-commonizer:test")
dependsOn(":native:kotlin-klib-commonizer-api:test")
}
register("examplesTest") {
@@ -952,6 +945,12 @@ tasks {
}
}
register("publishGradlePluginArtifacts") {
idePluginDependency {
dependsOnKotlinGradlePluginPublish()
}
}
register("publishIdeArtifacts") {
idePluginDependency {
dependsOn(
+3 -2
View File
@@ -128,8 +128,9 @@ java {
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.freeCompilerArgs +=
listOf("-Xopt-in=kotlin.RequiresOptIn", "-Xskip-runtime-version-check")
kotlinOptions.freeCompilerArgs += listOf(
"-Xopt-in=kotlin.RequiresOptIn", "-Xskip-runtime-version-check", "-Xsuppress-version-warnings"
)
}
tasks["build"].dependsOn(":prepare-deps:build")
+48 -35
View File
@@ -20,41 +20,54 @@ import java.lang.Character.isUpperCase
import java.nio.file.Files
import java.nio.file.Path
fun Task.dependsOnKotlinPluginInstall() {
dependsOn(
":kotlin-allopen:install",
":kotlin-noarg:install",
":kotlin-sam-with-receiver:install",
":kotlin-android-extensions:install",
":kotlin-parcelize-compiler:install",
":kotlin-build-common:install",
":kotlin-compiler-embeddable:install",
":native:kotlin-native-utils:install",
":kotlin-util-klib:install",
":kotlin-util-io:install",
":kotlin-compiler-runner:install",
":kotlin-daemon-embeddable:install",
":kotlin-daemon-client:install",
":kotlin-gradle-plugin-api:install",
":kotlin-gradle-plugin:install",
":kotlin-gradle-plugin-model:install",
":kotlin-reflect:install",
":kotlin-annotation-processing-gradle:install",
":kotlin-test:install",
":kotlin-gradle-subplugin-example:install",
":kotlin-stdlib-common:install",
":kotlin-stdlib:install",
":kotlin-stdlib-jdk8:install",
":kotlin-stdlib-js:install",
":examples:annotation-processor-example:install",
":kotlin-script-runtime:install",
":kotlin-scripting-common:install",
":kotlin-scripting-jvm:install",
":kotlin-scripting-compiler-embeddable:install",
":kotlin-scripting-compiler-impl-embeddable:install",
":kotlin-test-js-runner:install",
":native:kotlin-klib-commonizer-embeddable:install"
)
val kotlinGradlePluginAndItsRequired = arrayOf(
":kotlin-allopen",
":kotlin-noarg",
":kotlin-sam-with-receiver",
":kotlin-android-extensions",
":kotlin-parcelize-compiler",
":kotlin-build-common",
":kotlin-compiler-embeddable",
":native:kotlin-native-utils",
":kotlin-util-klib",
":kotlin-util-io",
":kotlin-compiler-runner",
":kotlin-daemon-embeddable",
":kotlin-daemon-client",
":kotlin-gradle-plugin-api",
":kotlin-gradle-plugin",
":kotlin-gradle-plugin-model",
":kotlin-reflect",
":kotlin-annotation-processing-gradle",
":kotlin-test",
":kotlin-gradle-subplugin-example",
":kotlin-stdlib-common",
":kotlin-stdlib",
":kotlin-stdlib-jdk8",
":kotlin-stdlib-js",
":examples:annotation-processor-example",
":kotlin-script-runtime",
":kotlin-scripting-common",
":kotlin-scripting-jvm",
":kotlin-scripting-compiler-embeddable",
":kotlin-scripting-compiler-impl-embeddable",
":kotlin-test-js-runner",
":native:kotlin-klib-commonizer-embeddable",
":native:kotlin-klib-commonizer-api"
)
fun Task.dependsOnKotlinGradlePluginInstall() {
kotlinGradlePluginAndItsRequired.forEach {
dependsOn("${it}:install")
}
}
fun Task.dependsOnKotlinGradlePluginPublish() {
kotlinGradlePluginAndItsRequired.forEach {
project.rootProject.tasks.findByPath("${it}:publish")?.let { task ->
dependsOn(task)
}
}
}
fun Project.projectTest(
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:4.1.2'
}
}
apply plugin: 'com.android.application'
@@ -37,14 +37,6 @@ android {
packagingOptions { exclude 'META-INF/build.txt' }
//TODO run under java 6, cause there is error on implicit 'stream' import in 'asWithMutable' test
lintOptions {
abortOnError false
}
compileOptions {
incremental = false
}
dexOptions {
dexInProcess false
@@ -80,6 +72,22 @@ android {
reflect0 {
dimension "box"
}
common_ir0 {
dimension "box"
}
common_ir1 {
dimension "box"
}
common_ir2 {
dimension "box"
}
reflect_ir0 {
dimension "box"
}
}
}
@@ -1,62 +0,0 @@
/*
* 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.
*/
package org.jetbrains.kotlin.android.tests;
import org.jetbrains.kotlin.jps.build.BaseKotlinJpsBuildTestCase;
import org.junit.Ignore;
import java.io.File;
import java.io.IOException;
@Ignore
public class AndroidJpsBuildTestCase extends BaseKotlinJpsBuildTestCase {
private static final String PROJECT_NAME = "android-module";
private static final String SDK_NAME = "Android_SDK";
private final File workDir = new File(AndroidRunner.getPathManager().getTmpFolder());
public void doTest() {
initProject();
rebuildAllModules();
buildAllModules().assertSuccessful();
}
@Override
protected String getProjectName() {
return "android-module";
}
@Override
protected void runTest() {
doTest();
}
@Override
public String getName() {
return "AndroidJpsTest";
}
@Override
protected File doGetProjectDir() throws IOException {
return workDir;
}
private void initProject() {
addJdk(SDK_NAME, AndroidRunner.getPathManager().getPlatformFolderInAndroidSdk() + "/android.jar");
loadProject(workDir.getAbsolutePath() + File.separator + PROJECT_NAME + ".ipr");
}
}
@@ -46,12 +46,8 @@ public class AndroidRunner {
CodegenTestsOnAndroidGenerator.generate(pathManager);
System.out.println("Run tests on android...");
TestSuite suite = CodegenTestsOnAndroidRunner.runTestsInEmulator(pathManager);
//AndroidJpsBuildTestCase indirectly depends on UsefulTestCase which compiled against java 8
//TODO: Need add separate run configuration for AndroidJpsBuildTestCase
//suite.addTest(new AndroidJpsBuildTestCase());
return suite;
System.out.println("Run tests on Android...");
return CodegenTestsOnAndroidRunner.runTestsInEmulator(pathManager);
}
public void tearDown() throws Exception {
@@ -12,7 +12,6 @@ import com.intellij.openapi.util.io.FileUtilRt
import org.jetbrains.kotlin.cli.common.output.writeAllTo
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.codegen.CodegenTestCase
import org.jetbrains.kotlin.codegen.CodegenTestFiles
import org.jetbrains.kotlin.codegen.GenerationUtils
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
@@ -22,8 +21,6 @@ import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.*
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
import org.jetbrains.kotlin.test.directives.model.singleOrZeroValue
import org.jetbrains.kotlin.test.model.DependencyKind
import org.jetbrains.kotlin.test.model.FrontendKinds
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
@@ -57,15 +54,18 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
//keep it globally to avoid test grouping on TC
private val generatedTestNames = hashSetOf<String>()
private val COMMON = FlavorConfig("common", 3)
private val REFLECT = FlavorConfig("reflect", 1)
private val COMMON = FlavorConfig(TargetBackend.ANDROID,"common", 3)
private val REFLECT = FlavorConfig(TargetBackend.ANDROID, "reflect", 1)
class FlavorConfig(private val prefix: String, val limit: Int) {
private val COMMON_IR = FlavorConfig(TargetBackend.ANDROID_IR, "common_ir", 3)
private val REFLECT_IR = FlavorConfig(TargetBackend.ANDROID_IR,"reflect_ir", 1)
class FlavorConfig(private val backend: TargetBackend, private val prefix: String, val limit: Int) {
private var writtenFilesCount = 0
fun printStatistics() {
println("FlavorTestCompiler: $prefix, generated file count: $writtenFilesCount")
println("FlavorTestCompiler for $backend: $prefix, generated file count: $writtenFilesCount")
}
fun getFlavorForNewFiles(newFilesCount: Int): String {
@@ -148,25 +148,47 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
private fun generateTestsAndFlavourSuites() {
println("Generating test files...")
generateTestMethodsForDirectories(File("compiler/testData/codegen/box"), File("compiler/testData/codegen/boxInline"))
val folders = arrayOf(
File("compiler/testData/codegen/box"),
File("compiler/testData/codegen/boxInline")
)
generateTestMethodsForDirectories(
TargetBackend.ANDROID,
COMMON,
REFLECT,
*folders
)
generateTestMethodsForDirectories(
TargetBackend.ANDROID_IR,
COMMON_IR,
REFLECT_IR,
*folders
)
pendingUnitTestGenerators.values.forEach { it.generate() }
}
private fun generateTestMethodsForDirectories(vararg dirs: File) {
private fun generateTestMethodsForDirectories(
backend: TargetBackend,
commonFlavor: FlavorConfig,
reflectionFlavor: FlavorConfig,
vararg dirs: File
) {
val holders = mutableMapOf<ConfigurationKey, FilesWriter>()
for (dir in dirs) {
val files = dir.listFiles() ?: error("Folder with testData is empty: ${dir.absolutePath}")
processFiles(files, holders)
processFiles(files, holders, backend, commonFlavor, reflectionFlavor)
}
holders.values.forEach {
it.writeFilesOnDisk()
}
COMMON.printStatistics()
REFLECT.printStatistics()
commonFlavor.printStatistics()
reflectionFlavor.printStatistics()
}
internal inner class FilesWriter(
@@ -254,7 +276,10 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
@Throws(IOException::class)
private fun processFiles(
files: Array<File>,
holders: MutableMap<ConfigurationKey, FilesWriter>
holders: MutableMap<ConfigurationKey, FilesWriter>,
backend: TargetBackend,
commmonFlavor: FlavorConfig,
reflectionFlavor: FlavorConfig
) {
holders.values.forEach {
it.writeFilesOnDiskIfNeeded()
@@ -264,7 +289,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
if (file.isDirectory) {
val listFiles = file.listFiles()
if (listFiles != null) {
processFiles(listFiles, holders)
processFiles(listFiles, holders, backend, commmonFlavor, reflectionFlavor)
}
} else if (FileUtilRt.getExtension(file.name) != KotlinFileType.EXTENSION) {
// skip non kotlin files
@@ -273,7 +298,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
continue
}
if (!InTextDirectivesUtils.isPassingTarget(TargetBackend.JVM, file) ||
if (!InTextDirectivesUtils.isPassingTarget(backend.compatibleWith, file) ||
InTextDirectivesUtils.isIgnoredTarget(TargetBackend.ANDROID, file)
) {
continue
@@ -304,7 +329,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
if (fullFileText.contains("// SKIP_JDK6")) continue
if (hasBoxMethod(fullFileText)) {
val testConfiguration = createTestConfiguration(file)
val testConfiguration = createTestConfiguration(file, backend)
val services = testConfiguration.testServices
val moduleStructure = try {
@@ -335,7 +360,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
keyConfiguration.languageVersionSettings = module.languageVersionSettings
val key = ConfigurationKey(kind, jdkKind, keyConfiguration.toString())
val compiler = if (kind.withReflection) REFLECT else COMMON
val compiler = if (kind.withReflection) reflectionFlavor else commmonFlavor
val compilerConfigurationProvider = services.compilerConfigurationProvider as CompilerConfigurationProviderImpl
val filesHolder = holders.getOrPut(key) {
FilesWriter(compiler, compilerConfigurationProvider.createCompilerConfiguration(module)).also {
@@ -349,9 +374,9 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
}
}
private fun createTestConfiguration(testDataFile: File): TestConfiguration {
private fun createTestConfiguration(testDataFile: File, backend: TargetBackend): TestConfiguration {
return TestConfigurationBuilder().apply {
testConfiguration()
configure(backend)
testInfo = KotlinTestInfo(
"org.jetbrains.kotlin.android.tests.AndroidRunner",
"test${testDataFile.nameWithoutExtension.capitalize()}",
@@ -360,10 +385,10 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
}.build(testDataFile.path)
}
private val testConfiguration: TestConfigurationBuilder.() -> Unit = {
private fun TestConfigurationBuilder.configure(backend: TargetBackend) {
globalDefaults {
frontend = FrontendKinds.ClassicFrontend
targetBackend = TargetBackend.ANDROID
targetBackend = backend
targetPlatform = JvmPlatforms.defaultJvmPlatform
dependencyKind = DependencyKind.Binary
}
@@ -386,9 +411,6 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
useDirectives(*AbstractKotlinCompilerTest.defaultDirectiveContainers.toTypedArray())
}
private fun createTestFiles(file: File, expectedText: String): List<KotlinBaseTest.TestFile> =
CodegenTestCase.createTestFilesFromFile(file, expectedText, false, TargetBackend.JVM)
companion object {
const val GRADLE_VERSION = "6.8.1" // update GRADLE_SHA_256 on change
const val GRADLE_SHA_256 = "fd591a34af7385730970399f473afabdb8b28d57fd97d6625c388d090039d6fd"
@@ -71,15 +71,20 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P
return rootSuite
}
private fun processReport(suite: TestSuite, resultOutput: String) {
private fun processReport(rootSuite: TestSuite, resultOutput: String) {
val reportFolder = File(flavorFolder())
try {
val folders = reportFolder.listFiles()
assertTrue(folders != null && folders.isNotEmpty(), "No folders in ${reportFolder.path}")
folders.forEach {
assertTrue("${it.path} is not directory") { it.isDirectory }
val isIr = it.name.contains("_ir")
val testCases = parseSingleReportInFolder(it)
testCases.forEach { aCase -> suite.addTest(aCase) }
testCases.forEach { aCase ->
if (isIr) aCase.name += "_ir"
rootSuite.addTest(aCase)
}
Assert.assertNotEquals("There is no test results in report", 0, testCases.size.toLong())
}
} catch (e: Throwable) {
@@ -87,10 +92,6 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P
}
}
private fun renameFlavorFolder() {
val reportFolder = File(flavorFolder())
reportFolder.renameTo(File(reportFolder.parentFile, reportFolder.name + "_d8"))
}
private fun flavorFolder() = pathManager.tmpFolder + "/build/test/results/connected/flavors"
@@ -119,7 +120,7 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P
private fun cleanAndBuildProject(gradleRunner: GradleRunner) {
gradleRunner.clean()
gradleRunner.build()
gradleRunner.assembleAndroidTest()
}
@Throws(IOException::class, SAXException::class, ParserConfigurationException::class)
@@ -138,21 +139,14 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P
return (0 until testCases.length).map { i ->
val item = testCases.item(i) as Element
val failure = item.getElementsByTagName("failure")
val failure = item.getElementsByTagName("failure").takeIf { it.length != 0 }?.item(0)
val name = item.getAttribute("name")
if (failure.length == 0) {
object : TestCase(name) {
@Throws(Throwable::class)
override fun runTest() {
}
}
} else {
object : TestCase(name) {
@Throws(Throwable::class)
override fun runTest() {
Assert.fail(failure.item(0).textContent)
object : TestCase(name) {
@Throws(Throwable::class)
override fun runTest() {
if (failure != null) {
Assert.fail(failure.textContent)
}
}
}
@@ -45,9 +45,9 @@ public class GradleRunner {
OutputUtils.checkResult(result);
}
public void build() {
public void assembleAndroidTest() {
System.out.println("Building gradle project...");
GeneralCommandLine build = generateCommandLine("build");
GeneralCommandLine build = generateCommandLine("assembleAndroidTest");
build.addParameter("--stacktrace");
build.addParameter("--warn");
RunResult result = RunUtils.execute(build);
@@ -20,11 +20,9 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
import org.jetbrains.kotlin.resolve.calls.components.hasDefaultValue
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.resolve.descriptorUtil.overriddenTreeUniqueAsSequence
import org.jetbrains.kotlin.utils.DFS
import org.jetbrains.kotlin.utils.mapToIndex
class ArgumentAndDeclIndex(val arg: ResolvedValueArgument, val declIndex: Int)
@@ -70,12 +68,8 @@ abstract class ArgumentGenerator {
generateExpression(declIndex, argument)
}
is DefaultValueArgument -> {
if (calleeDescriptor?.defaultValueFromJava(declIndex) == true) {
generateDefaultJava(declIndex, argument)
} else {
defaultArgs.mark(declIndex)
generateDefault(declIndex, argument)
}
defaultArgs.mark(declIndex)
generateDefault(declIndex, argument)
}
is VarargValueArgument -> {
generateVararg(declIndex, argument)
@@ -103,10 +97,6 @@ abstract class ArgumentGenerator {
throw UnsupportedOperationException("Unsupported vararg value argument #$i: $argument")
}
protected open fun generateDefaultJava(i: Int, argument: DefaultValueArgument) {
throw UnsupportedOperationException("Unsupported default java argument #$i: $argument")
}
protected open fun generateOther(i: Int, argument: ResolvedValueArgument) {
throw UnsupportedOperationException("Unsupported value argument #$i: $argument")
}
@@ -116,28 +106,6 @@ abstract class ArgumentGenerator {
}
}
private fun CallableDescriptor.defaultValueFromJava(index: Int): Boolean = DFS.ifAny(
listOf(this),
{ current -> current.original.overriddenDescriptors.map { it.original } },
{ descriptor ->
descriptor.original.overriddenDescriptors.isEmpty() &&
descriptor is JavaCallableMemberDescriptor &&
descriptor.valueParameters[index].declaresDefaultValue()
}
)
fun shouldInvokeDefaultArgumentsStub(resolvedCall: ResolvedCall<*>): Boolean {
val descriptor = resolvedCall.resultingDescriptor
val valueArgumentsByIndex = resolvedCall.valueArgumentsByIndex ?: return false
for (index in valueArgumentsByIndex.indices) {
val resolvedValueArgument = valueArgumentsByIndex[index]
if (resolvedValueArgument is DefaultValueArgument && !descriptor.defaultValueFromJava(index)) {
return true
}
}
return false
}
fun getFunctionWithDefaultArguments(functionDescriptor: FunctionDescriptor): FunctionDescriptor {
if (functionDescriptor.containingDeclaration !is ClassDescriptor) return functionDescriptor
if (functionDescriptor.overriddenDescriptors.isEmpty()) return functionDescriptor
@@ -155,4 +123,4 @@ fun getFunctionWithDefaultArguments(functionDescriptor: FunctionDescriptor): Fun
function.valueParameters.any { valueParameter -> valueParameter.hasDefaultValue() }
}
?: functionDescriptor
}
}
@@ -72,12 +72,6 @@ class CallBasedArgumentGenerator(
callGenerator.putValueIfNeeded(getJvmKotlinType(i), lazyVararg, ValueKind.GENERAL_VARARG, i)
}
override fun generateDefaultJava(i: Int, argument: DefaultValueArgument) {
val argumentValue = valueParameters[i].findJavaDefaultArgumentValue(valueParameterTypes[i], codegen.typeMapper)
callGenerator.putValueIfNeeded(getJvmKotlinType(i), argumentValue)
}
override fun reorderArgumentsIfNeeded(args: List<ArgumentAndDeclIndex>) {
callGenerator.reorderArgumentsIfNeeded(args, valueParameterTypes)
}
@@ -74,7 +74,10 @@ import org.jetbrains.kotlin.resolve.constants.*;
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluatorKt;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
import org.jetbrains.kotlin.resolve.jvm.*;
import org.jetbrains.kotlin.resolve.jvm.AsmTypes;
import org.jetbrains.kotlin.resolve.jvm.JvmBindingContextSlices;
import org.jetbrains.kotlin.resolve.jvm.JvmConstantsKt;
import org.jetbrains.kotlin.resolve.jvm.RuntimeAssertionInfo;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
@@ -2690,7 +2693,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
}
@NotNull
Callable resolveToCallable(@NotNull FunctionDescriptor fd, boolean superCall, @NotNull ResolvedCall resolvedCall) {
Callable resolveToCallable(@NotNull FunctionDescriptor fd, boolean superCall, @NotNull ResolvedCall<?> resolvedCall) {
IntrinsicMethod intrinsic = state.getIntrinsics().getIntrinsic(fd);
if (intrinsic != null) {
return intrinsic.toCallable(fd, superCall, resolvedCall, this);
@@ -2698,7 +2701,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
fd = SamCodegenUtil.resolveSamAdapter(fd);
if (ArgumentGeneratorKt.shouldInvokeDefaultArgumentsStub(resolvedCall)) {
List<ResolvedValueArgument> valueArguments = resolvedCall.getValueArgumentsByIndex();
if (valueArguments != null && valueArguments.stream().anyMatch(it -> it instanceof DefaultValueArgument)) {
// When we invoke a function with some arguments mapped as defaults,
// we later reroute this call to an overridden function in a base class that processes the default arguments.
// If the base class is generic, this overridden function can have a different Kotlin signature
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.load.java.SpecialBuiltinMembers;
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.*;
import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt;
import org.jetbrains.kotlin.resolve.annotations.ThrowUtilKt;
import org.jetbrains.kotlin.resolve.calls.util.UnderscoreUtilKt;
import org.jetbrains.kotlin.resolve.constants.ArrayValue;
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
@@ -1105,7 +1105,7 @@ public class FunctionCodegen {
return Collections.emptyList();
}
AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(AnnotationUtilKt.JVM_THROWS_ANNOTATION_FQ_NAME);
AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(ThrowUtilKt.JVM_THROWS_ANNOTATION_FQ_NAME);
if (annotation == null) return Collections.emptyList();
Collection<ConstantValue<?>> values = annotation.getAllValueArguments().values();
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
internal class ObjectSuperCallArgumentGenerator(
@@ -65,12 +64,6 @@ internal class ObjectSuperCallArgumentGenerator(
pushDefaultValueOnStack(type, iv)
}
public override fun generateDefaultJava(i: Int, argument: DefaultValueArgument) {
val type = parameters[i].asmType
val value = superValueParameters[i].findJavaDefaultArgumentValue(type, typeMapper)
value.put(type, iv)
}
public override fun generateVararg(i: Int, argument: VarargValueArgument) {
generateSuperCallArgument(i)
}
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.codegen.context.CodegenContext;
import org.jetbrains.kotlin.codegen.context.FieldOwnerContext;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.config.LanguageFeature;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl;
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil;
@@ -79,7 +80,8 @@ public class SamWrapperCodegen {
this.samType = samType;
this.parentCodegen = parentCodegen;
visibility = isInsideInline ? ACC_PUBLIC : NO_FLAG_PACKAGE_PRIVATE;
classFlags = visibility | ACC_FINAL | ACC_SUPER;
int synth = state.getLanguageVersionSettings().supportsFeature(LanguageFeature.SamWrapperClassesAreSynthetic) ? ACC_SYNTHETIC : 0;
classFlags = visibility | ACC_FINAL | ACC_SUPER | synth;
}
@NotNull
@@ -5,18 +5,7 @@
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.codegen.AsmUtil.unboxPrimitiveTypeOrNull
import org.jetbrains.kotlin.codegen.StackValue.*
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.load.java.Constant
import org.jetbrains.kotlin.load.java.EnumEntry
import org.jetbrains.kotlin.load.java.descriptors.NullDefaultValue
import org.jetbrains.kotlin.load.java.descriptors.StringDefaultValue
import org.jetbrains.kotlin.load.java.descriptors.getDefaultValueFromAnnotation
import org.jetbrains.kotlin.load.java.lexicalCastFrom
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.utils.DFS
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
@@ -86,40 +75,3 @@ class FunctionCallStackValue(
resultKotlinType: KotlinType?,
lambda: (v: InstructionAdapter) -> Unit
) : OperationStackValue(resultType, resultKotlinType, lambda)
fun ValueParameterDescriptor.findJavaDefaultArgumentValue(targetType: Type, typeMapper: KotlinTypeMapper): StackValue {
val descriptorWithDefaultValue = DFS.dfs(
listOf(this.original),
{ it.original.overriddenDescriptors.map(ValueParameterDescriptor::getOriginal) },
object : DFS.AbstractNodeHandler<ValueParameterDescriptor, ValueParameterDescriptor?>() {
var result: ValueParameterDescriptor? = null
override fun beforeChildren(current: ValueParameterDescriptor?): Boolean {
if (current?.declaresDefaultValue() == true && current.getDefaultValueFromAnnotation() != null) {
result = current
return false
}
return true
}
override fun result(): ValueParameterDescriptor? = result
}
) ?: error("Should be at least one descriptor with default value: $this")
val defaultValue = descriptorWithDefaultValue.getDefaultValueFromAnnotation()
if (defaultValue is NullDefaultValue) {
return constant(null, targetType)
}
val value = (defaultValue as StringDefaultValue).value
val castResult = type.lexicalCastFrom(value) ?: error("Should be checked in frontend")
return when (castResult) {
is EnumEntry -> enumEntry(castResult.descriptor, typeMapper)
is Constant -> {
val unboxedType = unboxPrimitiveTypeOrNull(targetType) ?: targetType
return coercion(constant(castResult.value, unboxedType), targetType, null)
}
}
}
@@ -462,6 +462,29 @@ class AnonymousObjectTransformer(
val indexToFunctionalArgument = transformationInfo.functionalArguments
val capturedParams = HashSet<Int>()
// Possible cases where we need to add each lambda's captures separately:
//
// 1. Top-level object in an inline lambda that is *not* being inlined into another object. In this case, we
// have no choice but to add a separate field for each captured variable. `capturedLambdas` is either empty
// (already have the fields) or contains the parent lambda object (captures used to be read from it, but
// the object will be removed and its contents inlined).
//
// 2. Top-level object in a named inline function. Again, there's no option but to add separate fields.
// `capturedLambdas` contains all lambdas used by this object and nested objects.
//
// 3. Nested object, either in an inline lambda or an inline function. This case has two subcases:
// * The object's captures are passed as separate arguments (e.g. KT-28064 style object that used to be in a lambda);
// we *could* group them into `this$0` now, but choose not to. Lambdas are replaced by their captures to match.
// * The object's captures are already grouped into `this$0`; this includes captured lambda parameters (for objects in
// inline functions) and a reference to the outer object or lambda (for objects in lambdas), so `capturedLambdas` is
// empty anyway.
//
// The only remaining case is a top-level object inside a (crossinline) lambda that is inlined into another object.
// Then, the reference to the soon-to-be-removed lambda class containing the captures (and it exists, or else the object
// would not have needed regeneration in the first place) is simply replaced with a reference to the outer object, and
// that object will contain loose fields for everything we need to capture.
val topLevelInCrossinlineLambda = parentFieldRemapper is InlinedLambdaRemapper && !parentFieldRemapper.parent!!.isRoot
//load captured parameters and patch instruction list
// NB: there is also could be object fields
val toDelete = arrayListOf<AbstractInsnNode>()
@@ -470,10 +493,12 @@ class AnonymousObjectTransformer(
val parameterAload = fieldNode.previous as VarInsnNode
val varIndex = parameterAload.`var`
val functionalArgument = indexToFunctionalArgument[varIndex]
val newFieldName = if (isThis0(fieldName) && shouldRenameThis0(parentFieldRemapper, indexToFunctionalArgument.values))
getNewFieldName(fieldName, true)
else
fieldName
// If an outer `this` is already captured by this object, rename it if any inline lambda will capture
// one of the same type, causing the code below to create a clash. Note that the values can be different.
// TODO: this is only really necessary if there will be a name *and* type clash.
val shouldRename = !topLevelInCrossinlineLambda && isThis0(fieldName) &&
indexToFunctionalArgument.values.any { it is LambdaInfo && it.capturedVars.any { it.fieldName == fieldName } }
val newFieldName = if (shouldRename) addUniqueField(fieldName + INLINE_FUN_THIS_0_SUFFIX) else fieldName
val info = capturedParamBuilder.addCapturedParam(
Type.getObjectType(transformationInfo.oldClassName), fieldName, newFieldName,
Type.getType(fieldNode.desc), functionalArgument is LambdaInfo, null
@@ -508,35 +533,17 @@ class AnonymousObjectTransformer(
//For all inlined lambdas add their captured parameters
//TODO: some of such parameters could be skipped - we should perform additional analysis
val allRecapturedParameters = ArrayList<CapturedParamDesc>()
if (parentFieldRemapper !is InlinedLambdaRemapper || parentFieldRemapper.parent!!.isRoot) {
// Possible cases:
//
// 1. Top-level object in an inline lambda that is *not* being inlined into another object. In this case, we
// have no choice but to add a separate field for each captured variable. `capturedLambdas` is either empty
// (already have the fields) or contains the parent lambda object (captures used to be read from it, but
// the object will be removed and its contents inlined).
//
// 2. Top-level object in a named inline function. Again, there's no option but to add separate fields.
// `capturedLambdas` contains all lambdas used by this object and nested objects.
//
// 3. Nested object, either in an inline lambda or an inline function. This case has two subcases:
// * The object's captures are passed as separate arguments (e.g. KT-28064 style object that used to be in a lambda);
// we could group them into `this$0` now, but choose not to. Lambdas are replaced by their captures.
// * The object's captures are already grouped into `this$0`; this includes captured lambda parameters (for objects in
// inline functions) and a reference to the outer object or lambda (for objects in lambdas), so `capturedLambdas` is
// empty and the choice doesn't matter.
//
val alreadyAdded = HashMap<String, CapturedParamInfo>()
if (!topLevelInCrossinlineLambda) {
val capturedOuterThisTypes = mutableSetOf<String>()
for (info in capturedLambdas) {
for (desc in info.capturedVars) {
val key = desc.fieldName + "$$$" + desc.type.className
val alreadyAddedParam = alreadyAdded[key]
val recapturedParamInfo = capturedParamBuilder.addCapturedParam(
desc,
alreadyAddedParam?.newFieldName ?: getNewFieldName(desc.fieldName, false),
alreadyAddedParam != null
)
// Merge all outer `this` of the same type captured by inlined lambdas, since they have to be the same
// object. Outer `this` captured by the original object itself should have been renamed above,
// and can have a different value even if the same type is captured by a lambda.
val recapturedParamInfo = if (isThis0(desc.fieldName))
capturedParamBuilder.addCapturedParam(desc, desc.fieldName, !capturedOuterThisTypes.add(desc.type.className))
else
capturedParamBuilder.addCapturedParam(desc, addUniqueField(desc.fieldName + INLINE_TRANSFORMATION_SUFFIX), false)
if (info is ExpressionLambda && info.isCapturedSuspend(desc)) {
recapturedParamInfo.functionalArgument = NonInlineableArgumentForInlineableParameterCalledInSuspend
}
@@ -551,10 +558,6 @@ class AnonymousObjectTransformer(
allRecapturedParameters.add(desc)
constructorParamBuilder.addCapturedParam(recapturedParamInfo, recapturedParamInfo.newFieldName).remapValue = composed
if (isThis0(desc.fieldName)) {
alreadyAdded.put(key, recapturedParamInfo)
}
}
}
} else if (capturedLambdas.isNotEmpty()) {
@@ -579,24 +582,6 @@ class AnonymousObjectTransformer(
return constructorAdditionalFakeParams
}
private fun shouldRenameThis0(parentFieldRemapper: FieldRemapper, values: Collection<FunctionalArgument>): Boolean {
return if (isFirstDeclSiteLambdaFieldRemapper(parentFieldRemapper)) {
values.any { it is LambdaInfo && it.capturedVars.any { isThis0(it.fieldName) } }
} else false
}
private fun getNewFieldName(oldName: String, originalField: Boolean): String {
if (AsmUtil.CAPTURED_THIS_FIELD == oldName) {
return if (!originalField) {
oldName
} else {
//rename original 'this$0' in declaration site lambda (inside inline function) to use this$0 only for outer lambda/object access on call site
addUniqueField(oldName + INLINE_FUN_THIS_0_SUFFIX)
}
}
return addUniqueField(oldName + INLINE_TRANSFORMATION_SUFFIX)
}
private fun addUniqueField(name: String): String {
val existNames = fieldNames.getOrPut(name) { LinkedList() }
val suffix = if (existNames.isEmpty()) "" else "$" + existNames.size
@@ -604,7 +589,4 @@ class AnonymousObjectTransformer(
existNames.add(newName)
return newName
}
private fun isFirstDeclSiteLambdaFieldRemapper(parentRemapper: FieldRemapper): Boolean =
parentRemapper !is RegeneratedLambdaFieldRemapper && parentRemapper !is InlinedLambdaRemapper
}
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethods
import org.jetbrains.kotlin.codegen.optimization.OptimizationClassBuilderFactory
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.config.LanguageVersion.*
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
@@ -49,6 +50,7 @@ import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeApproximator
import org.jetbrains.org.objectweb.asm.Type
import java.io.File
import java.util.*
class GenerationState private constructor(
val project: Project,
@@ -204,16 +206,20 @@ class GenerationState private constructor(
val target = configuration.get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
val runtimeStringConcat =
if (target.majorVersion >= JvmTarget.JVM_9.majorVersion)
configuration.get(JVMConfigurationKeys.STRING_CONCAT) ?: JvmStringConcat.INLINE
configuration.get(JVMConfigurationKeys.STRING_CONCAT) ?: JvmStringConcat.INDY_WITH_CONSTANTS
else JvmStringConcat.INLINE
val samConversionsScheme = run {
val fromConfig = configuration.get(JVMConfigurationKeys.SAM_CONVERSIONS)
?: JvmClosureGenerationScheme.DEFAULT
if (target >= fromConfig.minJvmTarget)
if (fromConfig != null && target >= fromConfig.minJvmTarget)
fromConfig
else
JvmClosureGenerationScheme.DEFAULT
else {
// TODO wait for KT-44844 (properly support 'invokedynamic' in JPS incremental compilation)
// Use JvmClosureGenerationScheme.INDY if
// JVM target is at least JVM_1_8 &&
// SamWrapperClassesAreSynthetic language feature is supported
JvmClosureGenerationScheme.CLASS
}
}
val lambdasScheme = run {
@@ -316,8 +322,7 @@ class GenerationState private constructor(
val metadataVersion =
configuration.get(CommonConfigurationKeys.METADATA_VERSION)
?: if (languageVersionSettings.languageVersion >= LanguageVersion.LATEST_STABLE) JvmMetadataVersion.INSTANCE
else JvmMetadataVersion(1, 1, 18)
?: LANGUAGE_TO_METADATA_VERSION.getValue(languageVersionSettings.languageVersion)
val abiStability = configuration.get(JVMConfigurationKeys.ABI_STABILITY)
@@ -388,6 +393,24 @@ class GenerationState private constructor(
private fun shouldOnlyCollectSignatures(origin: JvmDeclarationOrigin) =
classBuilderMode == ClassBuilderMode.LIGHT_CLASSES && origin.originKind in doNotGenerateInLightClassMode
companion object {
private val LANGUAGE_TO_METADATA_VERSION = EnumMap<LanguageVersion, JvmMetadataVersion>(LanguageVersion::class.java).apply {
val oldMetadataVersion = JvmMetadataVersion(1, 1, 18)
this[KOTLIN_1_0] = oldMetadataVersion
this[KOTLIN_1_1] = oldMetadataVersion
this[KOTLIN_1_2] = oldMetadataVersion
this[KOTLIN_1_3] = oldMetadataVersion
this[KOTLIN_1_4] = JvmMetadataVersion(1, 4, 3)
this[KOTLIN_1_5] = JvmMetadataVersion.INSTANCE
this[KOTLIN_1_6] = JvmMetadataVersion(1, 6, 0)
check(size == LanguageVersion.values().size) {
"Please add mappings from the missing LanguageVersion instances to the corresponding JvmMetadataVersion " +
"in `GenerationState.LANGUAGE_TO_METADATA_VERSION`"
}
}
}
}
private val doNotGenerateInLightClassMode = setOf(CLASS_MEMBER_DELEGATION_TO_DEFAULT_IMPL, BRIDGE, COLLECTION_STUB, AUGMENTED_BUILTIN_API)
+3 -1
View File
@@ -56,7 +56,9 @@ tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions {
languageVersion = "1.3"
apiVersion = "1.3"
freeCompilerArgs = freeCompilerArgs - "-progressive" + "-Xskip-prerelease-check"
freeCompilerArgs = freeCompilerArgs - "-progressive" + listOf(
"-Xskip-prerelease-check", "-Xsuppress-version-warnings"
)
}
}
@@ -0,0 +1,13 @@
/*
* 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.cli.common.arguments
@Retention(AnnotationRetention.RUNTIME)
annotation class DeprecatedOption(
val message: String = "This option has no effect and will be removed in a future release.",
val removeAfter: String,
val level: DeprecationLevel
)
@@ -5,8 +5,7 @@
package org.jetbrains.kotlin.cli.common.arguments
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.CALL
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.NO_CALL
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.*
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.config.ApiVersion
@@ -126,6 +125,13 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-Xir-dce", description = "Perform experimental dead code elimination")
var irDce: Boolean by FreezableVar(false)
@Argument(
value = "-Xir-dce-runtime-diagnostic",
valueDescription = "{$DCE_RUNTIME_DIAGNOSTIC_LOG|$DCE_RUNTIME_DIAGNOSTIC_EXCEPTION}",
description = "Enable runtime diagnostics when performing DCE instead of removing declarations"
)
var irDceRuntimeDiagnostic: String? by NullableStringFreezableVar(null)
@Argument(value = "-Xir-dce-driven", description = "Perform a more experimental faster dead code elimination")
var irDceDriven: Boolean by FreezableVar(false)
@@ -25,6 +25,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
description = "List of directories and JAR/ZIP archives to search for user class files")
var classpath: String? by NullableStringFreezableVar(null)
@DeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.ERROR)
@GradleOption(DefaultValues.BooleanFalseDefault::class)
@Argument(value = "-include-runtime", description = "Include Kotlin runtime into the resulting JAR")
var includeRuntime: Boolean by FreezableVar(false)
@@ -41,10 +42,12 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-no-jdk", description = "Don't automatically include the Java runtime into the classpath")
var noJdk: Boolean by FreezableVar(false)
@DeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.ERROR)
@GradleOption(DefaultValues.BooleanTrueDefault::class)
@Argument(value = "-no-stdlib", description = "Don't automatically include the Kotlin/JVM stdlib and Kotlin reflection into the classpath")
var noStdlib: Boolean by FreezableVar(false)
@DeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.ERROR)
@GradleOption(DefaultValues.BooleanTrueDefault::class)
@Argument(value = "-no-reflect", description = "Don't automatically include Kotlin reflection into the classpath")
var noReflect: Boolean by FreezableVar(false)
@@ -111,6 +114,14 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
)
var doNotClearBindingContext: Boolean by FreezableVar(false)
@Argument(
value = "-Xparallel-backend-threads",
description = "When using the IR backend, run lowerings by file in N parallel threads.\n" +
"0 means use a thread per processor core.\n" +
"Default value is 1"
)
var parallelBackendThreads: String by FreezableVar("1")
@Argument(value = "-Xmodule-path", valueDescription = "<path>", description = "Paths where to find Java 9+ modules")
var javaModulePath: String? by NullableStringFreezableVar(null)
@@ -358,7 +369,9 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
description = """Select code generation scheme for string concatenation.
-Xstring-concat=indy-with-constants Concatenate strings using `invokedynamic` `makeConcatWithConstants`. Requires `-jvm-target 9` or greater.
-Xstring-concat=indy Concatenate strings using `invokedynamic` `makeConcat`. Requires `-jvm-target 9` or greater.
-Xstring-concat=inline Concatenate strings using `StringBuilder`"""
-Xstring-concat=inline Concatenate strings using `StringBuilder`
default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise"""
)
var stringConcat: String? by NullableStringFreezableVar(JvmStringConcat.INLINE.description)
@@ -28,4 +28,7 @@ public interface K2JsArgumentConstants {
String SOURCE_MAP_SOURCE_CONTENT_ALWAYS = "always";
String SOURCE_MAP_SOURCE_CONTENT_NEVER = "never";
String SOURCE_MAP_SOURCE_CONTENT_INLINING = "inlining";
String DCE_RUNTIME_DIAGNOSTIC_LOG = "log";
String DCE_RUNTIME_DIAGNOSTIC_EXCEPTION = "exception";
}
@@ -88,7 +88,7 @@ fun buildKLib(
configuration = configuration,
allDependencies = allDependencies,
friendDependencies = emptyList(),
irFactory = PersistentIrFactory,
irFactory = PersistentIrFactory(), // TODO: IrFactoryImpl?
outputKlibPath = outputPath,
nopack = true
)
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.cli.common.ExitCode.COMPILATION_ERROR
import org.jetbrains.kotlin.cli.common.ExitCode.OK
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.*
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
import org.jetbrains.kotlin.cli.common.extensions.ScriptEvaluationExtension
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
@@ -199,7 +200,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
configuration = config.configuration,
allDependencies = resolvedLibraries,
friendDependencies = friendDependencies,
irFactory = PersistentIrFactory,
irFactory = PersistentIrFactory(), // TODO IrFactoryImpl?
outputKlibPath = outputFile.path,
nopack = arguments.irProduceKlibDir
)
@@ -259,12 +260,17 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
mainArguments = mainCallArguments,
generateFullJs = !arguments.irDce,
generateDceJs = arguments.irDce,
dceRuntimeDiagnostic = DceRuntimeDiagnostic.resolve(
arguments.irDceRuntimeDiagnostic,
messageCollector
),
dceDriven = arguments.irDceDriven,
multiModule = arguments.irPerModule,
relativeRequirePath = true,
propertyLazyInitialization = arguments.irPropertyLazyInitialization,
)
val jsCode = if (arguments.irDce && !arguments.irDceDriven) compiledModule.dceJsCode!! else compiledModule.jsCode!!
outputFile.writeText(jsCode.mainModule)
jsCode.dependencies.forEach { (name, content) ->
@@ -422,6 +428,19 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
}
}
fun DceRuntimeDiagnostic.Companion.resolve(
value: String?,
messageCollector: MessageCollector
): DceRuntimeDiagnostic? = when (value?.toLowerCase()) {
DCE_RUNTIME_DIAGNOSTIC_LOG -> DceRuntimeDiagnostic.LOG
DCE_RUNTIME_DIAGNOSTIC_EXCEPTION -> DceRuntimeDiagnostic.EXCEPTION
null -> null
else -> {
messageCollector.report(STRONG_WARNING, "Unknown DCE runtime diagnostic '$value'")
null
}
}
fun messageCollectorLogger(collector: MessageCollector) = object : Logger {
override fun warning(message: String) = collector.report(STRONG_WARNING, message)
override fun error(message: String) = collector.report(ERROR, message)
@@ -291,6 +291,10 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
}
arguments.declarationsOutputPath?.let { put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, it) }
val nThreadsRaw = arguments.parallelBackendThreads.toIntOrNull() ?: 1
val nThreads = if (nThreadsRaw == 0) Runtime.getRuntime().availableProcessors() else nThreadsRaw
put(CommonConfigurationKeys.PARALLEL_BACKEND_THREADS, nThreads)
}
fun CompilerConfiguration.configureKlibPaths(arguments: K2JVMCompilerArguments) {
@@ -5,6 +5,8 @@
package org.jetbrains.kotlin.config
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
enum class JvmClosureGenerationScheme(
val description: String,
val minJvmTarget: JvmTarget
@@ -17,7 +19,9 @@ enum class JvmClosureGenerationScheme(
val DEFAULT = CLASS
@JvmStatic
fun fromString(string: String?) =
values().find { it.description == string }
fun fromString(string: String?): JvmClosureGenerationScheme? {
val lowerStr = string?.toLowerCaseAsciiOnly() ?: return null
return values().find { it.description == lowerStr }
}
}
}
@@ -50,6 +50,10 @@ object CommonConfigurationKeys {
@JvmField
val USE_FIR_EXTENDED_CHECKERS = CompilerConfigurationKey.create<Boolean>("fir extended checkers")
@JvmField
val PARALLEL_BACKEND_THREADS =
CompilerConfigurationKey.create<Int>("When using the IR backend, run lowerings by file in N parallel threads")
}
var CompilerConfiguration.languageVersionSettings: LanguageVersionSettings
@@ -29,6 +29,10 @@ inline fun <reified T : Any> StorageComponentContainer.useImpl() {
registerSingleton(T::class.java)
}
inline fun <reified T : Any> StorageComponentContainer.useImplIf(cond: Boolean) {
if (cond) useImpl<T>()
}
inline fun <reified T : Any> ComponentProvider.get(): T {
return getService(T::class.java)
}
@@ -50,6 +50,7 @@ dependencies {
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions {
apiVersion = "1.3"
freeCompilerArgs += "-Xsuppress-version-warnings"
}
}
@@ -42,6 +42,7 @@ tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions {
// This module is being run from within Gradle, older versions of which only have kotlin-stdlib 1.3 in the runtime classpath.
apiVersion = "1.3"
freeCompilerArgs += "-Xsuppress-version-warnings"
}
}
@@ -376,7 +376,7 @@ object KotlinCompilerClient {
"-D$JAVA_RMI_SERVER_HOSTNAME=$serverHostname")
val javaVersion = System.getProperty("java.specification.version")?.toIntOrNull()
val javaIllegalAccessWorkaround =
if (javaVersion != null && javaVersion >= 17)
if (javaVersion != null && javaVersion >= 16)
listOf("--illegal-access=permit")
else emptyList()
val args = listOf(
@@ -715,6 +715,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/invokeWithReceiverAndArgument.kt");
}
@TestMetadata("kt37056.kt")
public void testKt37056() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt");
}
@TestMetadata("lambdaAsReceiver.kt")
public void testLambdaAsReceiver() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/lambdaAsReceiver.kt");
@@ -2885,6 +2890,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.kt");
}
@TestMetadata("smartcastToTypeParameter.kt")
public void testSmartcastToTypeParameter() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToTypeParameter.kt");
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -2944,6 +2954,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
public void testFunctionCallBound() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/functionCallBound.kt");
}
@TestMetadata("thisAssignment.kt")
public void testThisAssignment() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/thisAssignment.kt");
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures")
@@ -3251,6 +3266,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
public void testCapturedParametersOfInnerClasses() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.kt");
}
@TestMetadata("castToBareType.kt")
public void testCastToBareType() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/types/castToBareType.kt");
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/visibility")
@@ -1484,24 +1484,6 @@ public class FirTypeEnhancementTestGenerated extends AbstractFirTypeEnhancementT
}
}
@TestMetadata("compiler/testData/loadJava/compiledJava/signatureAnnotations")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class SignatureAnnotations extends AbstractFirTypeEnhancementTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInSignatureAnnotations() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava/compiledJava/signatureAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true);
}
@TestMetadata("StableName.java")
public void testStableName() throws Exception {
runTest("compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.java");
}
}
@TestMetadata("compiler/testData/loadJava/compiledJava/signaturePropagation")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -132,67 +132,4 @@ public class OwnFirTypeEnhancementTestGenerated extends AbstractOwnFirTypeEnhanc
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/enhancement/mapping"), Pattern.compile("^(.+)\\.java$"), null, true);
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class SignatureAnnotations extends AbstractOwnFirTypeEnhancementTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInSignatureAnnotations() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true);
}
@TestMetadata("DefaultEnum.java")
public void testDefaultEnum() throws Exception {
runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultEnum.java");
}
@TestMetadata("DefaultLongLiteral.java")
public void testDefaultLongLiteral() throws Exception {
runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultLongLiteral.java");
}
@TestMetadata("DefaultNull.java")
public void testDefaultNull() throws Exception {
runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNull.java");
}
@TestMetadata("DefaultNullAndParameter.java")
public void testDefaultNullAndParameter() throws Exception {
runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNullAndParameter.java");
}
@TestMetadata("DefaultParameter.java")
public void testDefaultParameter() throws Exception {
runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultParameter.java");
}
@TestMetadata("EmptyParameterName.java")
public void testEmptyParameterName() throws Exception {
runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/EmptyParameterName.java");
}
@TestMetadata("ReorderedParameterNames.java")
public void testReorderedParameterNames() throws Exception {
runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/ReorderedParameterNames.java");
}
@TestMetadata("SameParameterName.java")
public void testSameParameterName() throws Exception {
runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SameParameterName.java");
}
@TestMetadata("SpecialCharsParameterName.java")
public void testSpecialCharsParameterName() throws Exception {
runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SpecialCharsParameterName.java");
}
@TestMetadata("StaticMethodWithDefaultValue.java")
public void testStaticMethodWithDefaultValue() throws Exception {
runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/StaticMethodWithDefaultValue.java");
}
}
}
@@ -65,9 +65,6 @@ abstract class AbstractFirTypeEnhancementTest : KtUsefulTestCase() {
private fun createEnvironment(content: String): KotlinCoreEnvironment {
val classpath = mutableListOf(getAnnotationsJar(), ForTestCompileRuntime.runtimeJarForTests())
if (InTextDirectivesUtils.isDirectiveDefined(content, "ANDROID_ANNOTATIONS")) {
classpath.add(ForTestCompileRuntime.androidAnnotationsForTests())
}
if (InTextDirectivesUtils.isDirectiveDefined(content, "JVM_ANNOTATIONS")) {
classpath.add(ForTestCompileRuntime.jvmAnnotationsForTests())
}
+1 -1
View File
@@ -1 +1 @@
Most FIR enhancement tests use compiler/testData/loadJava/compilerJava
Most FIR enhancement tests use compiler/testData/loadJava/compiledJava
@@ -1,33 +0,0 @@
public/*package*/ open class A : R|kotlin/Any| {
public open fun a(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(HELLO)) arg: R|ft<@FlexibleNullability Signs, Signs?>!| = R|/Signs.HELLO|): R|ft<@FlexibleNullability Signs, Signs?>!|
public open fun bar(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(X)) arg: R|ft<@FlexibleNullability Signs, Signs?>!| = R|/Signs.X|): R|ft<@FlexibleNullability Signs, Signs?>!|
public open fun baz(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(NOT_ENTRY_EITHER)) arg: R|ft<@FlexibleNullability Signs, Signs?>!|): R|ft<@FlexibleNullability Signs, Signs?>!|
public open fun bam(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(NOT_ENTRY_EITHER)) arg: R|ft<@FlexibleNullability Mixed, Mixed?>!| = R|/Mixed.NOT_ENTRY_EITHER|): R|ft<@FlexibleNullability Mixed, Mixed?>!|
public/*package*/ constructor(): R|A|
}
public final enum class Mixed : R|kotlin/Enum<ft<@FlexibleNullability Mixed, Mixed?>!>| {
public final static enum entry NOT_ENTRY_EITHER: R|@FlexibleNullability Mixed|
public final static fun values(): R|kotlin/Array<Mixed>| {
}
public final static fun valueOf(value: R|kotlin/String|): R|Mixed| {
}
}
public final enum class Signs : R|kotlin/Enum<ft<@FlexibleNullability Signs, Signs?>!>| {
public final static enum entry HELLO: R|@FlexibleNullability Signs|
public final static enum entry WORLD: R|@FlexibleNullability Signs|
public final static field X: R|ft<@FlexibleNullability Signs, Signs?>!|
public final static fun values(): R|kotlin/Array<Signs>| {
}
public final static fun valueOf(value: R|kotlin/String|): R|Signs| {
}
}
@@ -1,39 +0,0 @@
// FILE: Signs.java
// ANDROID_ANNOTATIONS
public enum Signs {
HELLO,
WORLD;
public static final Signs X;
public static final class NOT_ENTRY_EITHER {}
}
// FILE: Mixed.java
public enum Mixed {
NOT_ENTRY_EITHER;
public static final class NOT_ENTRY_EITHER {}
}
// FILE: A.java
import kotlin.annotations.jvm.internal.*;
class A {
public Signs a(@DefaultValue("HELLO") Signs arg) {
return arg;
}
public Signs bar(@DefaultValue("X") Signs arg) {
return arg;
}
public Signs baz(@DefaultValue("NOT_ENTRY_EITHER") Signs arg) {
return arg;
}
public Mixed bam(@DefaultValue("NOT_ENTRY_EITHER") Mixed arg) {
return arg;
}
}
@@ -1,24 +0,0 @@
public open class A : R|kotlin/Any| {
public open fun first(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0x1F)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!| = Long(31)): R|kotlin/Unit|
public open fun second(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0X1F)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!| = Long(31)): R|kotlin/Unit|
public open fun third(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0b1010)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!| = Long(10)): R|kotlin/Unit|
public open fun fourth(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0B1010)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!| = Long(10)): R|kotlin/Unit|
public constructor(): R|A|
}
public open class B : R|kotlin/Any| {
public open fun first(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0x)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!|): R|kotlin/Unit|
public open fun second(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0xZZ)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!|): R|kotlin/Unit|
public open fun third(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0b)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!|): R|kotlin/Unit|
public open fun fourth(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0B1234)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!|): R|kotlin/Unit|
public constructor(): R|B|
}
@@ -1,36 +0,0 @@
// FILE: A.java
// ANDROID_ANNOTATIONS
import kotlin.annotations.jvm.internal.*;
public class A {
public void first(@DefaultValue("0x1F") Long value) {
}
public void second(@DefaultValue("0X1F") Long value) {
}
public void third(@DefaultValue("0b1010") Long value) {
}
public void fourth(@DefaultValue("0B1010") Long value) {
}
}
// FILE: B.java
import kotlin.annotations.jvm.internal.*;
public class B {
public void first(@DefaultValue("0x") Long value) {
}
public void second(@DefaultValue("0xZZ") Long value) {
}
public void third(@DefaultValue("0b") Long value) {
}
public void fourth(@DefaultValue("0B1234") Long value) {
}
}
@@ -1,14 +0,0 @@
public open class A : R|kotlin/Any| {
public open fun foo(@R|kotlin/annotations/jvm/internal/DefaultNull|() x: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Null(null)): R|kotlin/Unit|
public open fun bar(@R|kotlin/annotations/jvm/internal/DefaultNull|() x: R|kotlin/Int| = Null(null)): R|kotlin/Unit|
public constructor(): R|A|
}
public open class B<T : R|ft<kotlin/Any, kotlin/Any?>!|> : R|kotlin/Any| {
public open fun foo(@R|kotlin/annotations/jvm/internal/DefaultNull|() t: R|ft<@FlexibleNullability T, T?>!| = Null(null)): R|kotlin/Unit|
public constructor<T : R|ft<kotlin/Any, kotlin/Any?>!|>(): R|B<T>|
}
@@ -1,17 +0,0 @@
// FILE: A.java
// ANDROID_ANNOTATIONS
import kotlin.annotations.jvm.internal.*;
public class A {
public void foo(@DefaultNull Integer x) {}
public void bar(@DefaultNull int x) {}
}
// FILE: B.java
import kotlin.annotations.jvm.internal.*;
public class B<T> {
public void foo(@DefaultNull T t) { }
}
@@ -1,32 +0,0 @@
public open class A : R|kotlin/Any| {
public open fun foo(@R|kotlin/annotations/jvm/internal/DefaultNull|() i: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Null(null)): R|kotlin/Unit|
public open fun bar(@R|kotlin/annotations/jvm/internal/DefaultNull|() a: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Null(null)): R|kotlin/Unit|
public open fun bam(@R|kotlin/annotations/jvm/internal/DefaultNull|() a: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Null(null)): R|kotlin/Unit|
public open fun baz(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(42)) a: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Int(42)): R|kotlin/Unit|
public constructor(): R|A|
}
public abstract interface AInt : R|kotlin/Any| {
public abstract fun foo(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(42)) i: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Int(42)): R|kotlin/Unit|
public abstract fun bar(@R|kotlin/annotations/jvm/internal/DefaultNull|() a: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Null(null)): R|kotlin/Unit|
}
public open class B : R|A| {
public open fun foo(i: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!|): R|kotlin/Unit|
public open fun bar(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(42)) a: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Int(42)): R|kotlin/Unit|
public open fun bam(@R|kotlin/annotations/jvm/internal/DefaultNull|() @R|kotlin/annotations/jvm/internal/DefaultValue|(String(42)) a: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Int(42)): R|kotlin/Unit|
public constructor(): R|B|
}
public open class C : R|A|, R|AInt| {
public constructor(): R|C|
}
@@ -1,38 +0,0 @@
// FILE: A.java
// ANDROID_ANNOTATIONS
import kotlin.annotations.jvm.internal.*;
public class A {
public void foo(@DefaultNull Integer i) {}
public void bar(@DefaultNull Integer a) {}
public void bam(@DefaultNull Integer a) {}
public void baz(@DefaultValue("42") Integer a) {}
}
// FILE: AInt.java
import kotlin.annotations.jvm.internal.*;
public interface AInt {
public void foo(@DefaultValue("42") Integer i) {}
public void bar(@DefaultNull Integer a) {}
}
// FILE: B.java
import kotlin.annotations.jvm.internal.*;
public class B extends A {
public void foo(Integer i) {}
public void bar(@DefaultValue("42") Integer a) {}
public void bam(@DefaultNull @DefaultValue("42") Integer a) {}
}
// FILE: C.java
public class C extends A implements AInt {
}
@@ -1,14 +0,0 @@
public/*package*/ open class A : R|kotlin/Any| {
public open fun first(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(hello)) value: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = String(hello)): R|kotlin/Unit|
public open fun second(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(first)) a: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = String(first), @R|kotlin/annotations/jvm/internal/DefaultValue|(String(second)) b: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = String(second)): R|kotlin/Unit|
public open fun third(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(first)) a: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = String(first), b: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit|
public open fun fourth(first: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|, @R|kotlin/annotations/jvm/internal/DefaultValue|(String(second)) second: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = String(second)): R|kotlin/Unit|
public open fun wrong(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(hello)) i: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!|): R|kotlin/Unit|
public/*package*/ constructor(): R|A|
}
@@ -1,23 +0,0 @@
// FILE: A.java
// ANDROID_ANNOTATIONS
import kotlin.annotations.jvm.internal.*;
class A {
public void first(@DefaultValue("hello") String value) {
}
public void second(@DefaultValue("first") String a, @DefaultValue("second") String b) {
}
public void third(@DefaultValue("first") String a, String b) {
}
public void fourth(String first, @DefaultValue("second") String second) {
}
public void wrong(@DefaultValue("hello") Integer i) {
}
}
@@ -1,10 +0,0 @@
public/*package*/ open class A : R|kotlin/Any| {
public open fun emptyName(@R|kotlin/annotations/jvm/internal/ParameterName|(String()) first: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|, @R|kotlin/annotations/jvm/internal/ParameterName|(String(ok)) second: R|kotlin/Int|): R|kotlin/Unit|
public open fun missingName(@R|kotlin/annotations/jvm/internal/ParameterName|() first: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit|
public open fun numberName(@R|kotlin/annotations/jvm/internal/ParameterName|(Int(42)) first: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit|
public/*package*/ constructor(): R|A|
}
@@ -1,16 +0,0 @@
// FILE: A.java
// ANDROID_ANNOTATIONS
import kotlin.annotations.jvm.internal.*;
class A {
public void emptyName(@ParameterName("") String first, @ParameterName("ok") int second) {
}
public void missingName(@ParameterName() String first) {
}
public void numberName(@ParameterName(42) String first) {
}
}
@@ -1,6 +0,0 @@
public open class A : R|kotlin/Any| {
public open fun connect(@R|kotlin/annotations/jvm/internal/ParameterName|(String(host)) host: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|, @R|kotlin/annotations/jvm/internal/ParameterName|(String(port)) port: R|kotlin/Int|): R|kotlin/Unit|
public constructor(): R|A|
}
@@ -1,10 +0,0 @@
// FILE: A.java
// ANDROID_ANNOTATIONS
import kotlin.annotations.jvm.internal.*;
public class A {
public void connect(@ParameterName("host") String host, @ParameterName("port") int port) {
}
}
@@ -1,6 +0,0 @@
public open class A : R|kotlin/Any| {
public open fun same(@R|kotlin/annotations/jvm/internal/ParameterName|(String(ok)) first: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|, @R|kotlin/annotations/jvm/internal/ParameterName|(String(ok)) second: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit|
public constructor(): R|A|
}
@@ -1,10 +0,0 @@
// FILE: A.java
// ANDROID_ANNOTATIONS
import kotlin.annotations.jvm.internal.*;
public class A {
public void same(@ParameterName("ok") String first, @ParameterName("ok") String second) {
}
}
@@ -1,8 +0,0 @@
public open class A : R|kotlin/Any| {
public open fun dollarName(@R|kotlin/annotations/jvm/internal/ParameterName|(String($)) host: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit|
public open fun numberName(@R|kotlin/annotations/jvm/internal/ParameterName|(String(42)) field: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit|
public constructor(): R|A|
}
@@ -1,13 +0,0 @@
// FILE: A.java
// ANDROID_ANNOTATIONS
import kotlin.annotations.jvm.internal.*;
import kotlin.internal.*;
public class A {
public void dollarName(@ParameterName("$") String host) {
}
public void numberName(@ParameterName("42") String field) {
}
}
@@ -1,6 +0,0 @@
public/*package*/ open class A : R|kotlin/Any| {
public open static fun withDefault(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(OK)) arg: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = String(OK)): R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|
public/*package*/ constructor(): R|A|
}
@@ -1,13 +0,0 @@
// IGNORE_BACKEND: JS, NATIVE
// FILE: A.java
// ANDROID_ANNOTATIONS
import kotlin.annotations.jvm.internal.*;
class A {
public static String withDefault(@DefaultValue("OK") String arg) {
return arg;
}
}
@@ -12,7 +12,7 @@ public sealed class Sealed : R|kotlin/Any| {
public final val z: R|test/Z|
public get(): R|test/Z|
@R|test/Ann|() internal constructor(@R|test/Ann|() z: R|test/Z|): R|test/Sealed|
@R|test/Ann|() protected constructor(@R|test/Ann|() z: R|test/Z|): R|test/Sealed|
}
@@ -14,7 +14,7 @@ public sealed class SealedClass : R|kotlin/Any| {
}
internal constructor(): R|test/SealedClass|
protected constructor(): R|test/SealedClass|
}
@@ -15,5 +15,5 @@ class B : A() {
}
fun test(b: B) {
b.<!HIDDEN{LT}!><!HIDDEN{PSI}!>foo<!>("")<!>
b.<!HIDDEN!>foo<!>("")
}
@@ -8,19 +8,19 @@ fun test() {
foo(1, 2.0, true)
foo(1, third = true)
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>(0, 0.0, false, "")<!>
<!INAPPLICABLE_CANDIDATE!>foo<!>()
<!INAPPLICABLE_CANDIDATE!>foo<!>(0, 0.0, false, "")
bar(1, third = true)
bar(1, 2.0, true)
bar(1, 2.0, true, "my")
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>bar<!>(1, true)<!>
<!INAPPLICABLE_CANDIDATE!>bar<!>(1, true)
baz(1)
baz(1, "my", "yours")
baz(1, z = true)
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>baz<!>(0, "", false)<!>
<!INAPPLICABLE_CANDIDATE!>baz<!>(0, "", false)
}
@@ -15,8 +15,8 @@ fun foo(a: A) {
a.foo()
a.foo(1)
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>bar<!>()<!>
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>bar<!>("")<!>
a.<!INAPPLICABLE_CANDIDATE!>bar<!>()
a.<!INAPPLICABLE_CANDIDATE!>bar<!>("")
a.bar(y = 1)
a.bar("", 2)
}
@@ -17,9 +17,9 @@ fun test_1() {
}
fun test_2() {
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeInt<!>(10000000000)<!>
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(10000000000)
takeLong(10000000000)
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(1000)<!>
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1000)
}
fun test_3() {
@@ -35,8 +35,8 @@ fun test_4() {
}
fun test_5() {
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeString<!>(1)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeString<!>(run { 1 })<!>
<!INAPPLICABLE_CANDIDATE!>takeString<!>(1)
<!INAPPLICABLE_CANDIDATE!>takeString<!>(run { 1 })
}
annotation class Ann(val x: Byte)
@@ -13,6 +13,6 @@ fun takeOutA(array: Array<out A>) {}
fun test(array: Array<B>) {
A.take(array)
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeA<!>(array)<!>
<!INAPPLICABLE_CANDIDATE!>takeA<!>(array)
takeOutA(array)
}
@@ -10,8 +10,8 @@ fun test() {
foo({})
// Bad
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>(1) {}<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>(f = {}) {}<!>
<!INAPPLICABLE_CANDIDATE!>foo<!>(1) {}
<!INAPPLICABLE_CANDIDATE!>foo<!>(f = {}) {}
// OK
bar(1) {}
@@ -20,15 +20,15 @@ fun test() {
bar(x = 1, f = {})
// Bad
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>bar<!> {}<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>bar<!>({})<!>
<!INAPPLICABLE_CANDIDATE!>bar<!> {}
<!INAPPLICABLE_CANDIDATE!>bar<!>({})
// OK
baz(other = false, f = {})
baz({}, false)
// Bad
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>baz<!> {}<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>baz<!>() {}<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>baz<!>(other = false) {}<!>
<!INAPPLICABLE_CANDIDATE!>baz<!> {}
<!INAPPLICABLE_CANDIDATE!>baz<!>() {}
<!INAPPLICABLE_CANDIDATE!>baz<!>(other = false) {}
}
@@ -1,14 +1,14 @@
fun <R> materialize(): R = null!!
fun test_1() {
<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>myRun<!> {
<!UNRESOLVED_REFERENCE!>myRun<!> {
val x = 1
x * 2
}<!>
}
}
fun test_2() {
<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>myRun<!> {
<!UNRESOLVED_REFERENCE!>myRun<!> {
materialize()
}<!>
}
}
@@ -31,33 +31,33 @@ fun test_3() {
fun takeByte(b: Byte) {}
fun test_4() {
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(1 + 1)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(1 + 127)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(1 - 1)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(-100 - 100)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(10 * 10)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(100 * 100)<!>
<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>taleByte<!>(10 / 10)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(100 % 10)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(1000 % 10)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(1000 and 100)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(128 and 511)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(100 or 100)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(1000 or 0)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(511 xor 511)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(512 xor 511)<!>
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1 + 1)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1 + 127)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1 - 1)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(-100 - 100)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(10 * 10)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(100 * 100)
<!UNRESOLVED_REFERENCE!>taleByte<!>(10 / 10)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(100 % 10)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1000 % 10)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1000 and 100)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(128 and 511)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(100 or 100)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1000 or 0)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(511 xor 511)
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(512 xor 511)
}
fun test_5() {
takeByte(-1)
takeByte(+1)
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(1.inv())<!>
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1.inv())
}
fun test_6() {
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(run { 127 + 1 })<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(1 + run { 1 })<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeByte<!>(run { 1 + 1 })<!>
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(run { 127 + 1 })
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(1 + run { 1 })
<!INAPPLICABLE_CANDIDATE!>takeByte<!>(run { 1 + 1 })
1 + 1
run { 1 }
1 + run { 1 }
@@ -7,11 +7,11 @@ fun test() {
foo(1, second = 3.14, third = false, fourth = "!?")
foo(third = false, second = 2.71, fourth = "?!", first = 0)
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>(0.0, false, 0, "")<!>
<!INAPPLICABLE_CANDIDATE!>foo<!>()
<!INAPPLICABLE_CANDIDATE!>foo<!>(0.0, false, 0, "")
foo(1, 2.0, third = true, "")
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>(second = 0.0, first = 0, fourth = "")<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>(first = 0.0, second = 0, third = "", fourth = false)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>(first = 0, second = 0.0, third = false, fourth = "", first = 1)<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>(0, 0.0, false, foth = "")<!>
<!INAPPLICABLE_CANDIDATE!>foo<!>(second = 0.0, first = 0, fourth = "")
<!INAPPLICABLE_CANDIDATE!>foo<!>(first = 0.0, second = 0, third = "", fourth = false)
<!INAPPLICABLE_CANDIDATE!>foo<!>(first = 0, second = 0.0, third = false, fourth = "", first = 1)
<!INAPPLICABLE_CANDIDATE!>foo<!>(0, 0.0, false, foth = "")
}
@@ -7,11 +7,11 @@ fun test() {
foo(1, "my", "yours")
foo(1, *arrayOf("my", "yours"))
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>("")<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>(1, 2)<!>
<!INAPPLICABLE_CANDIDATE!>foo<!>("")
<!INAPPLICABLE_CANDIDATE!>foo<!>(1, 2)
bar(1, z = true, y = *arrayOf("my", "yours"))
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>bar<!>(0, z = false, y = "", y = "other")<!>
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>bar<!>(0, "", true)<!>
<!INAPPLICABLE_CANDIDATE!>bar<!>(0, z = false, y = "", y = "other")
<!INAPPLICABLE_CANDIDATE!>bar<!>(0, "", true)
}
+2 -2
View File
@@ -11,9 +11,9 @@ class A {
import foo.A as B
fun test_1() {
val a = <!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>A<!>()<!>
val a = <!UNRESOLVED_REFERENCE!>A<!>()
val b = B() // should be OK
val c: B = <!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>A<!>()<!>
val c: B = <!UNRESOLVED_REFERENCE!>A<!>()
}
fun test_2(b: B) {
@@ -9,11 +9,11 @@ fun bar(x: B) {}
fun test(c: C) {
// Argument mapping error
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>("")<!>
<!INAPPLICABLE_CANDIDATE!>foo<!>("")
// Ambiguity
<!AMBIGUITY{LT}!><!AMBIGUITY{PSI}!>bar<!>(c)<!>
<!AMBIGUITY!>bar<!>(c)
// Unresolved reference
<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>baz<!>()<!>
<!UNRESOLVED_REFERENCE!>baz<!>()
}
@@ -0,0 +1,58 @@
FILE: kt37056.kt
public final fun case1(a: R|A?|): R|kotlin/Unit| {
lval test: R|kotlin/String?| = R|<local>/a|?.{ $subj$.R|kotlin/let|<R|A|, R|kotlin/String|>(<L> = let@fun <anonymous>(it: R|A|): R|kotlin/String| <kind=EXACTLY_ONCE> {
Q|Case1|.R|/Case1.Companion.invoke|(R|<local>/it|)
Q|Case1|.R|/Case1.Companion.invoke|(R|<local>/it|)
^ Q|Case1|.R|/Case1.Companion.invoke|(R|/A.A|())
}
) }
Q|Case1|.R|/Case1.Companion.invoke|(R|/A.A|())
Q|Case1|.R|/Case1.Companion.invoke|(a = R|/A.A|())
}
public final class Case1 : R|kotlin/Any| {
private constructor(a: R|A|): R|Case1| {
super<R|kotlin/Any|>()
}
public final val a: R|A| = R|<local>/a|
public get(): R|A|
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|Case1.Companion| {
super<R|kotlin/Any|>()
}
public final operator fun invoke(a: R|A|): R|kotlin/String| {
^invoke String()
}
}
}
public final fun case2(a: R|A|): R|kotlin/Unit| {
Q|Case2|.R|/Case2.Companion.invoke|(R|<local>/a|)
Q|Case2|.R|/Case2.Companion.invoke|(a = R|<local>/a|)
}
public final class Case2 : R|kotlin/Any| {
public constructor(): R|Case2| {
super<R|kotlin/Any|>()
}
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|Case2.Companion| {
super<R|kotlin/Any|>()
}
public final operator fun invoke(a: R|A|): R|kotlin/String| {
^invoke String()
}
}
}
public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
}
@@ -0,0 +1,32 @@
fun case1(a: A?) {
val test = a?.let {
Case1.invoke(it)
Case1(it)
Case1(A())
}
Case1(A())
Case1(a = A())
}
class Case1 private constructor(val a: A) {
companion object {
operator fun invoke(a: A) = ""
}
}
fun case2(a: A) {
Case2(a)
Case2(a =a)
}
class Case2 {
companion object {
operator fun invoke(a: A) = "" //(1)
}
}
class A()
@@ -9,6 +9,6 @@ fun main1() {
}
fun main2() {
{ "" }.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>bar<!>()<!>
{ "" }.<!INAPPLICABLE_CANDIDATE!>bar<!>()
"".bar()
}
@@ -19,7 +19,7 @@ fun test_2(x: Any, y: Any) {
val a = select(
id(
run {
y.<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>inc<!>()<!> // Bad
y.<!UNRESOLVED_REFERENCE!>inc<!>() // Bad
x as Int
}
),
@@ -39,14 +39,14 @@ fun test_3(x: Any, y: Any) {
val a = select(
id(
run {
y.<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>inc<!>()<!> // Bad
y.<!UNRESOLVED_REFERENCE!>inc<!>() // Bad
x as Int
materialize()
}
),
run {
y as Int
x.<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>inc<!>()<!> // Bad
x.<!UNRESOLVED_REFERENCE!>inc<!>() // Bad
y.inc() // OK
1
}
@@ -60,19 +60,19 @@ fun test_4(x: Any, y: Any) {
val a = select(
id(
myRun {
y.<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>inc<!>()<!> // Bad
y.<!UNRESOLVED_REFERENCE!>inc<!>() // Bad
x as Int
}
),
y as Int,
myRun {
x.<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>inc<!>()<!> // Bad
x.<!UNRESOLVED_REFERENCE!>inc<!>() // Bad
y.inc() // OK
1
}
)
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>takeInt<!>(x)<!> // Bad
<!INAPPLICABLE_CANDIDATE!>takeInt<!>(x) // Bad
takeInt(y) // OK
takeInt(a) // Bad
}
@@ -1,5 +1,5 @@
FILE: innerClassInAnonymousObject.kt
public final val x: R|<anonymous>| = object : R|kotlin/Any| {
public final val x: R|kotlin/Any| = object : R|kotlin/Any| {
private constructor(): R|<anonymous>| {
super<R|kotlin/Any|>()
}
@@ -16,4 +16,4 @@ FILE: innerClassInAnonymousObject.kt
}
public get(): R|<anonymous>|
public get(): R|kotlin/Any|
@@ -44,7 +44,7 @@ FILE: constantValues.kt
}
public sealed class Value : R|kotlin/Any| {
private constructor(): R|KClassValue.Value| {
protected constructor(): R|KClassValue.Value| {
super<R|kotlin/Any|>()
}
@@ -22,7 +22,7 @@ class B : A() {
}
fun g() {
super.<!ABSTRACT_SUPER_CALL{LT}!><!ABSTRACT_SUPER_CALL{PSI}!>f<!>()<!>
super.<!ABSTRACT_SUPER_CALL!>f<!>()
super.t()
super.x
@@ -32,7 +32,7 @@ class B : A() {
abstract class J : A() {
fun r() {
super.<!ABSTRACT_SUPER_CALL{LT}!><!ABSTRACT_SUPER_CALL{PSI}!>f<!>()<!>
super.<!ABSTRACT_SUPER_CALL!>f<!>()
super.t()
super.x
@@ -13,5 +13,5 @@ open class B {
class A : IWithToString, B() {
override fun toString(): String = super.toString() // resolve to Any.toString
override fun foo(): String = super.foo() // resolve to B.foo()
override fun bar(): String = super.<!ABSTRACT_SUPER_CALL{LT}!><!ABSTRACT_SUPER_CALL{PSI}!>bar<!>()<!> // should be an error
override fun bar(): String = super.<!ABSTRACT_SUPER_CALL!>bar<!>() // should be an error
}
@@ -8,7 +8,7 @@ FILE: annotationArgumentKClassLiteralTypeError.kt
public get(): R|kotlin/Array<kotlin/reflect/KClass<*>>|
}
public final val <reified T> R|T|.test: R|<anonymous><T>|
public final val <reified T> R|T|.test: R|kotlin/Any|
public get(): R|<anonymous><T>| {
^ @R|Ann|(<implicitArrayOf>(<getClass>(R|T|), <getClass>(Q|kotlin/Array|))) object : R|kotlin/Any| {
private constructor(): R|<anonymous><T>| {
@@ -90,14 +90,14 @@ FILE: conflictingOverloads.kt
}
public final val Companion: R|<anonymous>| = object : R|kotlin/Any| {
public final val Companion: R|kotlin/Any| = object : R|kotlin/Any| {
private constructor(): R|<anonymous>| {
super<R|kotlin/Any|>()
}
}
public get(): R|<anonymous>|
public get(): R|kotlin/Any|
}
public final fun R|B|.foo(): R|kotlin/Unit| {
@@ -63,5 +63,5 @@ class M {
}
class U : M {
<!INAPPLICABLE_CANDIDATE!>constructor()<!>
constructor()
}
@@ -3,16 +3,16 @@ class A(x: Int) {
}
class B : A {
<!EXPLICIT_DELEGATION_CALL_REQUIRED, NONE_APPLICABLE!>constructor()<!>
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
constructor(z: String) : this()
}
<!SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR!>class C : A(20) {
<!EXPLICIT_DELEGATION_CALL_REQUIRED, NONE_APPLICABLE!>constructor()<!>
<!EXPLICIT_DELEGATION_CALL_REQUIRED!>constructor()<!>
constructor(z: String) : this()
}<!>
class D() : A(20) {
<!NONE_APPLICABLE, PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor(x: Int)<!>
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor(x: Int)<!>
constructor(z: String) : this()
}
@@ -3,36 +3,36 @@ object Delegate {
operator fun setValue(instance: Any?, property: Any, value: String) {}
}
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit var test: Int<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit var kest by Delegate<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var test: Int
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var kest by Delegate
lateinit var good: String
class A {
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit val fest = "10"<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> val fest = "10"
lateinit var mest: String
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit var xest: String?<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit var nest: Int<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit var west: Char<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit var qest: Boolean<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit var aest: Short<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit var hest: Byte<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit var jest: Long<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit val dest: String
get() = "KEKER"<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var xest: String?
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var nest: Int
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var west: Char
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var qest: Boolean
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var aest: Short
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var hest: Byte
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var jest: Long
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> val dest: String
get() = "KEKER"
}
class B<T> {
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit var best: T<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var best: T
}
class C<K : Any> {
lateinit var pest: K
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit var vest: K?<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var vest: K?
}
fun rest() {
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit var i: Int<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var i: Int
lateinit var a: A
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit var b: B<String> = B()<!>
<!INAPPLICABLE_LATEINIT_MODIFIER!>lateinit<!> var b: B<String> = B()
}
@@ -30,13 +30,13 @@ FILE: incompatibleModifiers.kt
}
public final class F : R|kotlin/Any| {
private constructor(): R|F| {
protected constructor(): R|F| {
super<R|kotlin/Any|>()
}
}
public sealed class G : R|kotlin/Any| {
private constructor(): R|G| {
protected constructor(): R|G| {
super<R|kotlin/Any|>()
}
@@ -57,7 +57,7 @@ FILE: incompatibleModifiers.kt
}
public sealed data class I : R|kotlin/Any| {
private constructor(i: R|kotlin/Int|): R|I| {
protected constructor(i: R|kotlin/Int|): R|I| {
super<R|kotlin/Any|>()
}
@@ -126,7 +126,7 @@ FILE: incompatibleModifiers.kt
}
public sealed inner class Z : R|kotlin/Any| {
private constructor(): R|X.Z| {
protected constructor(): R|X.Z| {
super<R|kotlin/Any|>()
}
@@ -1,5 +1,5 @@
class A {
constructor(x: Int = <!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>getSomeInt<!>()<!>, other: A = <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>, header: String = <!UNRESOLVED_REFERENCE!>keker<!>) {}
constructor(x: Int = <!UNRESOLVED_REFERENCE!>getSomeInt<!>(), other: A = <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>, header: String = <!UNRESOLVED_REFERENCE!>keker<!>) {}
fun getSomeInt() = 10
var keker = "test"
}
@@ -21,7 +21,7 @@ FILE: localEntitytNotAllowed.kt
public abstract interface X : R|kotlin/Any| {
}
public final val a: R|<anonymous>| = object : R|kotlin/Any| {
public final val a: R|kotlin/Any| = object : R|kotlin/Any| {
private constructor(): R|<anonymous>| {
super<R|kotlin/Any|>()
}
@@ -48,7 +48,7 @@ FILE: localEntitytNotAllowed.kt
}
public get(): R|<anonymous>|
public get(): R|kotlin/Any|
public final fun b(): R|kotlin/Unit| {
local final object E : R|kotlin/Any| {
@@ -17,3 +17,18 @@ FILE: nonConstValInAnnotationArgument.kt
public get(): R|kotlin/Int|
@R|Ann|(<implicitArrayOf>(R|/foo|, R|/foo|.R|kotlin/String.plus|(R|/cnst|.R|kotlin/Any.toString|()))) public final fun test(): R|kotlin/Unit| {
}
public final const val A: R|kotlin/String| = String(foo)
public get(): R|kotlin/String|
public final const val B: R|kotlin/Int| = Int(100)
public get(): R|kotlin/Int|
public final annotation class S : R|kotlin/Annotation| {
public constructor(s: R|kotlin/String|): R|S| {
super<R|kotlin/Any|>()
}
public final val s: R|kotlin/String| = R|<local>/s|
public get(): R|kotlin/String|
}
@R|S|(R|/A|.R|kotlin/String.plus|(R|/B|)) public final fun foo(): R|kotlin/Unit| {
}
@@ -11,3 +11,11 @@ const val cnst = 2
)<!>
)
fun test() {}
const val A = "foo"
const val B = 100
annotation class S(val s: String)
@S(A + B)
fun foo() {}
@@ -4,7 +4,7 @@ class A {
class B : A {
fun g() {
<!NOT_A_SUPERTYPE!>super<String><!>.<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>f<!>()<!>
<!NOT_A_SUPERTYPE!>super<String><!>.<!UNRESOLVED_REFERENCE!>f<!>()
super<A>.f()
}
}
@@ -6,7 +6,7 @@ FILE: redundantModifier.kt
}
public sealed class B : R|kotlin/Any| {
private constructor(): R|B| {
protected constructor(): R|B| {
super<R|kotlin/Any|>()
}
@@ -1,9 +1,9 @@
FILE: sealedClassConstructorCall.kt
public sealed class A : R|kotlin/Any| {
private constructor(): R|A| {
protected constructor(): R|A| {
super<R|kotlin/Any|>()
}
}
public final val b: R|A| = R|/A.A|()
public final val b: R|A| = <HIDDEN: /A.A is invisible>#()
public get(): R|A|
@@ -1,3 +1,3 @@
sealed class A
val b = <!SEALED_CLASS_CONSTRUCTOR_CALL{LT}!><!SEALED_CLASS_CONSTRUCTOR_CALL{PSI}!>A<!>()<!>
val b = <!HIDDEN!>A<!>()
@@ -1,6 +1,6 @@
FILE: sealedSupertype.kt
public sealed class A : R|kotlin/Any| {
private constructor(): R|A| {
protected constructor(): R|A| {
super<R|kotlin/Any|>()
}
@@ -22,7 +22,7 @@ FILE: sealedSupertype.kt
}
public sealed class P : R|kotlin/Any| {
private constructor(): R|P| {
protected constructor(): R|P| {
super<R|kotlin/Any|>()
}
@@ -13,8 +13,8 @@ FILE: superIsNotAnExpression.kt
public final fun act(): R|kotlin/Unit| {
<Super cannot be a callee>#()
<Unresolved name: invoke>#()
<Super cannot be a callee>#(<L> = <Super cannot be a callee>@fun <implicit>.<anonymous>(): <implicit> {
println#(ERROR_EXPR(Incorrect character: 'weird'))
<Super cannot be a callee>#(<L> = <Super cannot be a callee>@fun <anonymous>(): R|ERROR CLASS: Unresolved name: println| {
^ <Unresolved name: println>#(ERROR_EXPR(Incorrect character: 'weird'))
}
)
}
@@ -4,10 +4,10 @@ class B: A() {
fun act() {
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>()
<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>invoke<!>()<!>
<!UNRESOLVED_REFERENCE!>invoke<!>()
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!> {
println(<!ILLEGAL_CONST_EXPRESSION!>'weird'<!>)
<!UNRESOLVED_REFERENCE!>println<!>(<!ILLEGAL_CONST_EXPRESSION!>'weird'<!>)
}
}
}
@@ -1,20 +1,20 @@
fun String.f() {
<!SUPER_NOT_AVAILABLE!>super@f<!>.<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>compareTo<!>("")<!>
<!SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>compareTo<!>("")<!>
<!SUPER_NOT_AVAILABLE!>super@f<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
<!SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
}
fun foo() {
<!SUPER_NOT_AVAILABLE!>super<!>
<!SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>foo<!>()<!>
<!SUPER_NOT_AVAILABLE!>super<Nothing><!>.<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>foo<!>()<!>
<!SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
<!SUPER_NOT_AVAILABLE!>super<Nothing><!>.<!UNRESOLVED_REFERENCE!>foo<!>()
}
class A {
fun act() {
<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>println<!>("Test")<!>
<!UNRESOLVED_REFERENCE!>println<!>("Test")
}
fun String.fact() {
<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>println<!>("Fest")<!>
<!UNRESOLVED_REFERENCE!>println<!>("Fest")
}
}
@@ -17,8 +17,8 @@ object Best {
}
val a = <!TYPE_ARGUMENTS_NOT_ALLOWED!>rest<Int><!>.<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>MyClass<!><String><!>
val b = Best.<!UNRESOLVED_REFERENCE{LT}!><!UNRESOLVED_REFERENCE{PSI}!>MyClass<!><String><!>
val a = <!TYPE_ARGUMENTS_NOT_ALLOWED!>rest<Int><!>.<!UNRESOLVED_REFERENCE!>MyClass<!><String>
val b = Best.<!UNRESOLVED_REFERENCE!>MyClass<!><String>
class B<E>
class C<F<!SYNTAX{PSI}!><<!><!SYNTAX{PSI}!>Boolean<!><!SYNTAX{PSI}!>><!><!SYNTAX{PSI}!>><!> <!SYNTAX{PSI}!>:<!> <!SYNTAX{PSI}!>B<!><!SYNTAX{PSI}!><<!><!SYNTAX{PSI}!>F<!><!SYNTAX{PSI}!><<!><!SYNTAX{PSI}!>Boolean<!><!SYNTAX{PSI}!>><!><!SYNTAX{PSI}!>><!><!SYNTAX{PSI}!>(<!><!SYNTAX{PSI}!>)<!>

Some files were not shown because too many files have changed in this diff Show More