diff --git a/.idea/misc.xml b/.idea/misc.xml index 8f4e3ebc3de..b6513e71f2e 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -52,7 +52,13 @@ - diff --git a/.idea/runConfigurations/Generate_Tests.xml b/.idea/runConfigurations/Generate_Tests.xml new file mode 100644 index 00000000000..2e6cf6fc804 --- /dev/null +++ b/.idea/runConfigurations/Generate_Tests.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/tools.protobuf.xml b/.idea/tools.protobuf.xml new file mode 100644 index 00000000000..c42da106537 --- /dev/null +++ b/.idea/tools.protobuf.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/ReadMe.md b/ReadMe.md index 08d1c6d58a0..1283f41ba67 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,6 +1,6 @@ [![official project](http://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub) -[![TeamCity (simple build status)](https://img.shields.io/teamcity/http/teamcity.jetbrains.com/s/bt345.svg)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=bt345&branch_Kotlin=%3Cdefault%3E&tab=buildTypeStatusDiv) +[![TeamCity (simple build status)](https://img.shields.io/teamcity/http/teamcity.jetbrains.com/s/Kotlin_dev_Compiler.svg)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=Kotlin_dev_Compiler&branch_Kotlin_dev=%3Cdefault%3E&tab=buildTypeStatusDiv) [![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlin/kotlin-maven-plugin.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.jetbrains.kotlin%22) [![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) @@ -40,6 +40,8 @@ In order to build Kotlin distribution you need to have: For local development, if you're not working on bytecode generation or the standard library, it's OK to have only JDK 8 installed, and to point all of the environment variables mentioned above to your JDK 8 installation. +You also can use [Gradle properties](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_properties_and_system_properties) to setup JDK_* variables. + > Note: The JDK 6 for MacOS is not available on Oracle's site. You can [download it here](https://support.apple.com/kb/DL1572). ## Building @@ -85,8 +87,6 @@ Refer to [libraries/ReadMe.md](libraries/ReadMe.md) for details. Working with the Kotlin project requires IntelliJ IDEA 2017.3. You can download an Early Access Preview version of IntelliJ IDEA 2017.3 [here](https://www.jetbrains.com/idea/nextversion/). -The [root Kotlin project](https://github.com/JetBrains/kotlin) should be imported into IDEA as gradle project. - To import the project in Intellij choose project directory in Open project dialog. Then, after project opened, Select `File` -> `New...` -> `Module from Existing Sources` in the menu, and select `build.gradle.kts` file in the project's root folder. @@ -127,6 +127,11 @@ Also the [JavaScript translation](https://github.com/JetBrains/kotlin/blob/maste Some of the code in the standard library is created by generating code from templates. See the [README](libraries/stdlib/ReadMe.md) in the stdlib section for how run the code generator. The existing templates can be used as examples for creating new ones. +### Running specific generated tests + +If you need to debug a specific generated test, ensure that you have the `Working directory` in your IntelliJ run configuration set +to the root directory of this project. If you don't, every test you try to run will fail with a `No such file or directory` exception. + ## Submitting patches The best way to submit a patch is to [fork the project on github](https://help.github.com/articles/fork-a-repo/) then send us a diff --git a/build-common/build.gradle.kts b/build-common/build.gradle.kts index 44cf00a7674..43ccbff7f5e 100644 --- a/build-common/build.gradle.kts +++ b/build-common/build.gradle.kts @@ -24,6 +24,8 @@ sourceSets { } runtimeJar() +sourcesJar() +javadocJar() testsJar() diff --git a/build-common/test/org/jetbrains/kotlin/serialization/js/ast/DebugJsAstProtoBuf.java b/build-common/test/org/jetbrains/kotlin/serialization/js/ast/DebugJsAstProtoBuf.java index 5ee90c76468..8f32bf61ac4 100644 --- a/build-common/test/org/jetbrains/kotlin/serialization/js/ast/DebugJsAstProtoBuf.java +++ b/build-common/test/org/jetbrains/kotlin/serialization/js/ast/DebugJsAstProtoBuf.java @@ -211,6 +211,22 @@ public final class DebugJsAstProtoBuf { * UNBOX_CHAR = 4; */ UNBOX_CHAR(3, 4), + /** + * SUSPEND_CALL = 5; + */ + SUSPEND_CALL(4, 5), + /** + * COROUTINE_RESULT = 6; + */ + COROUTINE_RESULT(5, 6), + /** + * COROUTINE_CONTROLLER = 7; + */ + COROUTINE_CONTROLLER(6, 7), + /** + * COROUTINE_RECEIVER = 8; + */ + COROUTINE_RECEIVER(7, 8), ; /** @@ -229,6 +245,22 @@ public final class DebugJsAstProtoBuf { * UNBOX_CHAR = 4; */ public static final int UNBOX_CHAR_VALUE = 4; + /** + * SUSPEND_CALL = 5; + */ + public static final int SUSPEND_CALL_VALUE = 5; + /** + * COROUTINE_RESULT = 6; + */ + public static final int COROUTINE_RESULT_VALUE = 6; + /** + * COROUTINE_CONTROLLER = 7; + */ + public static final int COROUTINE_CONTROLLER_VALUE = 7; + /** + * COROUTINE_RECEIVER = 8; + */ + public static final int COROUTINE_RECEIVER_VALUE = 8; public final int getNumber() { return value; } @@ -239,6 +271,10 @@ public final class DebugJsAstProtoBuf { case 2: return WRAP_FUNCTION; case 3: return TO_BOXED_CHAR; case 4: return UNBOX_CHAR; + case 5: return SUSPEND_CALL; + case 6: return COROUTINE_RESULT; + case 7: return COROUTINE_CONTROLLER; + case 8: return COROUTINE_RECEIVER; default: return null; } } @@ -49361,10 +49397,12 @@ public final class DebugJsAstProtoBuf { "t.Fragment*@\n\013SideEffects\022\021\n\rAFFECTS_STA" + "TE\020\001\022\024\n\020DEPENDS_ON_STATE\020\002\022\010\n\004PURE\020\003*?\n\016" + "InlineStrategy\022\017\n\013AS_FUNCTION\020\000\022\014\n\010IN_PL" + - "ACE\020\001\022\016\n\nNOT_INLINE\020\002*c\n\017SpecialFunction" + - "\022\032\n\026DEFINE_INLINE_FUNCTION\020\001\022\021\n\rWRAP_FUN" + - "CTION\020\002\022\021\n\rTO_BOXED_CHAR\020\003\022\016\n\nUNBOX_CHAR" + - "\020\004B\024B\022DebugJsAstProtoBuf" + "ACE\020\001\022\016\n\nNOT_INLINE\020\002*\275\001\n\017SpecialFunctio" + + "n\022\032\n\026DEFINE_INLINE_FUNCTION\020\001\022\021\n\rWRAP_FU" + + "NCTION\020\002\022\021\n\rTO_BOXED_CHAR\020\003\022\016\n\nUNBOX_CHA" + + "R\020\004\022\020\n\014SUSPEND_CALL\020\005\022\024\n\020COROUTINE_RESUL" + + "T\020\006\022\030\n\024COROUTINE_CONTROLLER\020\007\022\026\n\022COROUTI" + + "NE_RECEIVER\020\010B\024B\022DebugJsAstProtoBuf" }; org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new org.jetbrains.kotlin.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { diff --git a/build.gradle.kts b/build.gradle.kts index 920d9dd71df..592dc6498cd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,11 +6,11 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile buildscript { - val repos = listOf( + val repos = listOfNotNull( System.getProperty("bootstrap.kotlin.repo"), "https://repo.gradle.org/gradle/repo", "https://plugins.gradle.org/m2", - "http://repository.jetbrains.com/utils/").filterNotNull() + "http://repository.jetbrains.com/utils/") extra["bootstrapKotlinVersion"] = bootstrapKotlinVersion @@ -105,7 +105,6 @@ extra["JDK_9"] = jdkPathIfFound("9") extra["versions.protobuf-java"] = "2.6.1" extra["versions.javax.inject"] = "1" extra["versions.jsr305"] = "1.3.9" -extra["versions.cli-parser"] = "1.1.2" extra["versions.jansi"] = "1.16" extra["versions.jline"] = "3.3.1" extra["versions.junit"] = "4.12" diff --git a/buildSrc/src/main/kotlin/instrument.kt b/buildSrc/src/main/kotlin/instrument.kt new file mode 100644 index 00000000000..31a5408f5c5 --- /dev/null +++ b/buildSrc/src/main/kotlin/instrument.kt @@ -0,0 +1,170 @@ +@file:Suppress("unused") // usages in build scripts are not tracked properly + +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.gradle.api.Project +import org.gradle.api.artifacts.ProjectDependency +import org.gradle.api.file.ConfigurableFileCollection +import org.gradle.api.file.FileCollection +import org.gradle.api.internal.ConventionTask +import org.gradle.api.plugins.ExtensionAware +import org.gradle.api.plugins.JavaPluginConvention +import org.gradle.api.tasks.* +import org.gradle.api.tasks.compile.AbstractCompile +import org.gradle.kotlin.dsl.* +import java.io.File + +fun Project.configureInstrumentation() { + plugins.matching { it::class.java.canonicalName.startsWith("org.jetbrains.kotlin.gradle.plugin") }.all { + // When we change the output classes directory, Gradle will automatically configure + // the test compile tasks to use the instrumented classes. Normally this is fine, + // however, it causes problems for Kotlin projects: + + // The "internal" modifier can be used to restrict access to the same module. + // To make it possible to use internal methods from the main source set in test classes, + // the Kotlin Gradle plugin adds the original output directory of the Java task + // as "friendly directory" which makes it possible to access internal members + // of the main module. Also this directory should be available on classpath during compilation + + // This fails when we change the classes dir. The easiest fix is to prepend the + // classes from the "friendly directory" to the compile classpath. + val testCompile = tasks.findByName("compileTestKotlin") as AbstractCompile? + testCompile?.doFirst { + val mainSourceSet = the().sourceSets.getByName("main") + testCompile.classpath = (testCompile.classpath + - mainSourceSet.output.classesDirs + + files((mainSourceSet as ExtensionAware).extra.get("classesDirsCopy"))) + } + } + + afterEvaluate { + the().sourceSets.all { sourceSetParam -> + // This copy will ignore filters, but they are unlikely to be used. + val classesDirs = (sourceSetParam.output.classesDirs as ConfigurableFileCollection).from as Collection + + val classesDirsCopy = project.files(classesDirs.toTypedArray()).filter { it.exists() } + (sourceSetParam as ExtensionAware).extra.set("classesDirsCopy", classesDirsCopy) + + logger.info("Saving old sources dir for project ${project.name}") + val instrumentedClassesDir = File(project.buildDir, "classes/${sourceSetParam.name}-instrumented") + (sourceSetParam.output.classesDirs as ConfigurableFileCollection).setFrom(instrumentedClassesDir) + val instrumentTask = project.tasks.create(sourceSetParam.getTaskName("instrument", "classes"), IntelliJInstrumentCodeTask::class.java) + instrumentTask.apply { + dependsOn(sourceSetParam.classesTaskName).onlyIf { !classesDirsCopy.isEmpty } + sourceSet = sourceSetParam + originalClassesDirs = classesDirsCopy + output = instrumentedClassesDir + } + + instrumentTask.outputs.dir(instrumentedClassesDir) + // Ensure that our task is invoked when the source set is built + sourceSetParam.compiledBy(instrumentTask) + @Suppress("UNUSED_EXPRESSION") + true + } + } +} + +@CacheableTask +open class IntelliJInstrumentCodeTask : ConventionTask() { + companion object { + private const val FILTER_ANNOTATION_REGEXP_CLASS = "com.intellij.ant.ClassFilterAnnotationRegexp" + private const val LOADER_REF = "java2.loader" + } + + var sourceSet: SourceSet? = null + + @Input + var originalClassesDirs: FileCollection? = null + + @get:InputFiles + val sourceDirs: FileCollection + get() = project.files(sourceSet!!.allSource.srcDirs.filter { !sourceSet!!.resources.contains(it) && it.exists() }) + + @get:OutputDirectory + var output: File? = null + + @TaskAction + fun instrumentClasses() { + logger.info("input files are: ${originalClassesDirs?.joinToString("; ", transform = { "'${it.name}'${if (it.exists()) "" else " (does not exists)" }"})}") + copyOriginalClasses() + + val classpath = project.ideaSdkDeps("javac2.jar", "jdom.jar", "asm-all.jar", "jgoodies-forms.jar") + + ant.withGroovyBuilder { + "taskdef"("name" to "instrumentIdeaExtensions", + "classpath" to classpath.asPath, + "loaderref" to LOADER_REF, + "classname" to "com.intellij.ant.InstrumentIdeaExtensions") + } + + logger.info("Compiling forms and instrumenting code with nullability preconditions") + val instrumentNotNull = prepareNotNullInstrumenting(classpath) + instrumentCode(sourceDirs, instrumentNotNull) + } + + private fun copyOriginalClasses() { + project.copy { + from(originalClassesDirs) + into(output) + } + } + + private fun prepareNotNullInstrumenting(classpath: ConfigurableFileCollection): Boolean { + ant.withGroovyBuilder { + "typedef"("name" to "skip", + "classpath" to classpath.asPath, + "loaderref" to LOADER_REF, + "classname" to FILTER_ANNOTATION_REGEXP_CLASS) + } + return true + } + + private fun instrumentCode(srcDirs: FileCollection, instrumentNotNull: Boolean) { + val headlessOldValue = System.setProperty("java.awt.headless", "true") + + // Instrumentation needs to have access to sources of forms for inclusion + val depSourceDirectorySets = project.configurations["compile"].dependencies.withType(ProjectDependency::class.java) + .map { p -> p.dependencyProject.the().sourceSets.getByName("main").allSource.sourceDirectories } + val instrumentationClasspath = + depSourceDirectorySets.fold(sourceSet!!.compileClasspath) { acc, v -> acc + v }.asPath.also { + logger.info("Using following dependency source dirs: $it") + } + + logger.info("Running instrumentIdeaExtensions with srcdir=${srcDirs.asPath}}, destdir=$output and classpath=$instrumentationClasspath") + + ant.withGroovyBuilder { + "instrumentIdeaExtensions"("srcdir" to srcDirs.asPath, + "destdir" to output, + "classpath" to instrumentationClasspath, + "includeantruntime" to false, + "instrumentNotNull" to instrumentNotNull) { + if (instrumentNotNull) { + ant.withGroovyBuilder { + "skip"("pattern" to "kotlin/Metadata") + } + } + } + } + + if (headlessOldValue != null) { + System.setProperty("java.awt.headless", headlessOldValue) + } else { + System.clearProperty("java.awt.headless") + } + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/jdksFinder.kt b/buildSrc/src/main/kotlin/jdksFinder.kt index d8677660167..ae4607a1a2d 100644 --- a/buildSrc/src/main/kotlin/jdksFinder.kt +++ b/buildSrc/src/main/kotlin/jdksFinder.kt @@ -19,7 +19,8 @@ data class JdkId(val explicit: Boolean, val majorVersion: JdkMajorVersion, var v fun Project.getConfiguredJdks(): List { val res = arrayListOf() for (jdkMajorVersion in JdkMajorVersion.values()) { - val explicitJdkEnvVal = System.getenv(jdkMajorVersion.name) + val explicitJdkEnvVal = findProperty(jdkMajorVersion.name)?.toString() + ?: System.getenv(jdkMajorVersion.name) ?: jdkAlternativeVarNames[jdkMajorVersion]?.mapNotNull { System.getenv(it) }?.firstOrNull() ?: continue val explicitJdk = File(explicitJdkEnvVal) diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.kt b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.kt index 576c587717f..f2a99c572b7 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.kt +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression @@ -161,4 +162,8 @@ object CodegenUtil { (1..arity).joinToString(prefix = "callableReferenceFakeCall(", separator = ", ", postfix = ")") { "p$it" } return KtPsiFactory(project, markGenerated = false).createExpression(fakeFunctionCall) as KtCallExpression } + + @JvmStatic + fun getActualDeclarations(file: KtFile): List = + file.declarations.filterNot(KtDeclaration::hasExpectModifier) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 840793fe7cb..40af774d941 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -103,9 +103,7 @@ import java.util.*; import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isInt; import static org.jetbrains.kotlin.codegen.AsmUtil.*; -import static org.jetbrains.kotlin.codegen.CodegenUtilKt.extractReificationArgument; -import static org.jetbrains.kotlin.codegen.CodegenUtilKt.isPossiblyUninitializedSingleton; -import static org.jetbrains.kotlin.codegen.CodegenUtilKt.unwrapInitialSignatureDescriptor; +import static org.jetbrains.kotlin.codegen.CodegenUtilKt.*; import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.*; import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.*; import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtilsKt.*; @@ -1611,7 +1609,7 @@ public class ExpressionCodegen extends KtVisitor impleme return null; } - public void returnExpression(KtExpression expr) { + public void returnExpression(@NotNull KtExpression expr) { boolean isBlockedNamedFunction = expr instanceof KtBlockExpression && expr.getParent() instanceof KtNamedFunction; FunctionDescriptor originalSuspendLambdaDescriptor = getOriginalSuspendLambdaDescriptorFromContext(context); @@ -1644,7 +1642,7 @@ public class ExpressionCodegen extends KtVisitor impleme } } - private static boolean endsWithReturn(KtElement bodyExpression) { + private static boolean endsWithReturn(@NotNull KtElement bodyExpression) { if (bodyExpression instanceof KtBlockExpression) { List statements = ((KtBlockExpression) bodyExpression).getStatements(); return statements.size() > 0 && statements.get(statements.size() - 1) instanceof KtReturnExpression; @@ -1653,7 +1651,7 @@ public class ExpressionCodegen extends KtVisitor impleme return bodyExpression instanceof KtReturnExpression; } - private static boolean isLambdaVoidBody(KtElement bodyExpression, Type returnType) { + private static boolean isLambdaVoidBody(@NotNull KtElement bodyExpression, @NotNull Type returnType) { if (bodyExpression instanceof KtBlockExpression) { PsiElement parent = bodyExpression.getParent(); if (parent instanceof KtFunctionLiteral) { @@ -2658,6 +2656,15 @@ public class ExpressionCodegen extends KtVisitor impleme return cur; } + private boolean canSkipArrayCopyForSpreadArgument(KtExpression spreadArgument) { + ResolvedCall resolvedCall = CallUtilKt.getResolvedCall(spreadArgument, bindingContext); + if (resolvedCall == null) return false; + + CallableDescriptor calleeDescriptor = resolvedCall.getResultingDescriptor(); + return (calleeDescriptor instanceof ConstructorDescriptor) || + CompileTimeConstantUtils.isArrayFunctionCall(resolvedCall) || + (DescriptorUtils.getFqName(calleeDescriptor).asString().equals("kotlin.arrayOfNulls")); + } @NotNull public StackValue genVarargs(@NotNull VarargValueArgument valueArgument, @NotNull KotlinType outType) { @@ -2680,10 +2687,13 @@ public class ExpressionCodegen extends KtVisitor impleme if (size == 1) { Type arrayType = getArrayType(arrayOfReferences ? AsmTypes.OBJECT_TYPE : elementType); return StackValue.operation(type, adapter -> { - gen(arguments.get(0).getArgumentExpression(), type); - v.dup(); - v.arraylength(); - v.invokestatic("java/util/Arrays", "copyOf", Type.getMethodDescriptor(arrayType, arrayType, Type.INT_TYPE), false); + KtExpression spreadArgument = arguments.get(0).getArgumentExpression(); + gen(spreadArgument, type); + if (!canSkipArrayCopyForSpreadArgument(spreadArgument)) { + v.dup(); + v.arraylength(); + v.invokestatic("java/util/Arrays", "copyOf", Type.getMethodDescriptor(arrayType, arrayType, Type.INT_TYPE), false); + } if (arrayOfReferences) { v.checkcast(type); } @@ -3904,7 +3914,9 @@ public class ExpressionCodegen extends KtVisitor impleme boolean isGetter = OperatorNameConventions.GET.equals(operationDescriptor.getName()); - Callable callable = resolveToCallable(operationDescriptor, false, isGetter ? resolvedGetCall : resolvedSetCall); + ResolvedCall resolvedCall = isGetter ? resolvedGetCall : resolvedSetCall; + assert resolvedCall != null : "No resolved call for " + operationDescriptor; + Callable callable = resolveToCallable(accessibleFunctionDescriptor(resolvedCall), false, resolvedCall); Callable callableMethod = resolveToCallableMethod(operationDescriptor, false); Type[] argumentTypes = callableMethod.getParameterTypes(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionGenerationStrategy.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionGenerationStrategy.java index 70e647d1220..d11e209f615 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionGenerationStrategy.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionGenerationStrategy.java @@ -20,6 +20,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.codegen.context.MethodContext; import org.jetbrains.kotlin.codegen.state.GenerationState; import org.jetbrains.kotlin.psi.KtDeclarationWithBody; +import org.jetbrains.kotlin.psi.KtExpression; +import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature; import org.jetbrains.org.objectweb.asm.MethodVisitor; @@ -49,7 +51,9 @@ public abstract class FunctionGenerationStrategy { @Override public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) { - codegen.returnExpression(declaration.getBodyExpression()); + KtExpression bodyExpression = declaration.getBodyExpression(); + assert bodyExpression != null : "Function has no body: " + PsiUtilsKt.getElementTextWithContext(declaration); + codegen.returnExpression(bodyExpression); } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java index f9b35847729..25b92ce0b9a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java @@ -813,27 +813,37 @@ public abstract class MemberCodegen() - for (declaration in element.declarations) { - when (declaration) { - is KtNamedFunction -> { - val functionDescriptor = bindingContext.get(BindingContext.FUNCTION, declaration) - members.add(functionDescriptor ?: throw AssertionError("Function ${declaration.name} is not bound in ${element.name}")) - } - is KtProperty -> { - val property = bindingContext.get(BindingContext.VARIABLE, declaration) - members.add(property ?: throw AssertionError("Property ${declaration.name} is not bound in ${element.name}")) - } - } - } - - val extension = JvmSerializerExtension(v.serializationBindings, state) - val serializer = DescriptorSerializer.createTopLevel(extension) - val builder = serializer.packagePartProto(packageFragment.fqName, members) - extension.serializeJvmPackage(builder, partType) - val packageProto = builder.build() + val (serializer, packageProto) = PackagePartCodegen.serializePackagePartMembers(this, partType) val extraFlags = if (shouldGeneratePartHierarchy) JvmAnnotationNames.METADATA_MULTIFILE_PARTS_INHERIT_FLAG else 0 diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PackageCodegenImpl.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/PackageCodegenImpl.java index 7a635d9a4ec..4245c86fa24 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PackageCodegenImpl.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PackageCodegenImpl.java @@ -22,6 +22,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.SmartList; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.backend.common.CodegenUtil; import org.jetbrains.kotlin.codegen.context.PackageContext; import org.jetbrains.kotlin.codegen.state.GenerationState; import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor; @@ -31,7 +32,6 @@ import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus; import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt; import org.jetbrains.org.objectweb.asm.Type; @@ -98,9 +98,7 @@ public class PackageCodegenImpl implements PackageCodegen { List classOrObjects = new ArrayList<>(); - for (KtDeclaration declaration : file.getDeclarations()) { - if (PsiUtilsKt.hasExpectModifier(declaration)) continue; - + for (KtDeclaration declaration : CodegenUtil.getActualDeclarations(file)) { if (declaration instanceof KtProperty || declaration instanceof KtNamedFunction || declaration instanceof KtTypeAlias) { generatePackagePart = true; } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PackagePartCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/PackagePartCodegen.java index 67057075f71..7df705e0c07 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PackagePartCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PackagePartCodegen.java @@ -17,22 +17,21 @@ package org.jetbrains.kotlin.codegen; import com.intellij.util.ArrayUtil; +import kotlin.Pair; import kotlin.Unit; +import kotlin.collections.CollectionsKt; import org.jetbrains.annotations.NotNull; +import org.jetbrains.kotlin.backend.common.CodegenUtil; import org.jetbrains.kotlin.codegen.annotation.AnnotatedSimple; import org.jetbrains.kotlin.codegen.context.FieldOwnerContext; import org.jetbrains.kotlin.codegen.serialization.JvmSerializerExtension; import org.jetbrains.kotlin.codegen.state.GenerationState; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; -import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor; -import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor; -import org.jetbrains.kotlin.descriptors.VariableDescriptor; import org.jetbrains.kotlin.descriptors.annotations.Annotated; import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.kotlin.descriptors.annotations.AnnotationsImpl; import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader; import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.serialization.DescriptorSerializer; import org.jetbrains.kotlin.serialization.ProtoBuf; @@ -88,9 +87,7 @@ public class PackagePartCodegen extends MemberCodegen { @Override protected void generateBody() { - for (KtDeclaration declaration : element.getDeclarations()) { - if (PsiUtilsKt.hasExpectModifier(declaration)) continue; - + for (KtDeclaration declaration : CodegenUtil.getActualDeclarations(element)) { if (declaration instanceof KtNamedFunction || declaration instanceof KtProperty || declaration instanceof KtTypeAlias) { genSimpleMember(declaration); } @@ -103,34 +100,42 @@ public class PackagePartCodegen extends MemberCodegen { @Override protected void generateKotlinMetadataAnnotation() { - List members = new ArrayList<>(); - for (KtDeclaration declaration : element.getDeclarations()) { - if (declaration instanceof KtNamedFunction) { - SimpleFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, declaration); - members.add(functionDescriptor); - } - else if (declaration instanceof KtProperty) { - VariableDescriptor property = bindingContext.get(BindingContext.VARIABLE, declaration); - members.add(property); - } - else if (declaration instanceof KtTypeAlias) { - TypeAliasDescriptor typeAlias = bindingContext.get(BindingContext.TYPE_ALIAS, declaration); - members.add(typeAlias); - } - } - - JvmSerializerExtension extension = new JvmSerializerExtension(v.getSerializationBindings(), state); - DescriptorSerializer serializer = DescriptorSerializer.createTopLevel(extension); - ProtoBuf.Package.Builder builder = serializer.packagePartProto(element.getPackageFqName(), members); - extension.serializeJvmPackage(builder, packagePartType); - ProtoBuf.Package packageProto = builder.build(); + Pair serializedPart = serializePackagePartMembers(this, packagePartType); WriteAnnotationUtilKt.writeKotlinMetadata(v, state, KotlinClassHeader.Kind.FILE_FACADE, 0, av -> { - writeAnnotationData(av, serializer, packageProto); + writeAnnotationData(av, serializedPart.getFirst(), serializedPart.getSecond()); return Unit.INSTANCE; }); } + @NotNull + protected static Pair serializePackagePartMembers( + @NotNull MemberCodegen codegen, + @NotNull Type packagePartType + ) { + BindingContext bindingContext = codegen.bindingContext; + List members = CollectionsKt.mapNotNull(CodegenUtil.getActualDeclarations(codegen.element), declaration -> { + if (declaration instanceof KtNamedFunction) { + return bindingContext.get(BindingContext.FUNCTION, declaration); + } + else if (declaration instanceof KtProperty) { + return bindingContext.get(BindingContext.VARIABLE, declaration); + } + else if (declaration instanceof KtTypeAlias) { + return bindingContext.get(BindingContext.TYPE_ALIAS, declaration); + } + + return null; + }); + + JvmSerializerExtension extension = new JvmSerializerExtension(codegen.v.getSerializationBindings(), codegen.state); + DescriptorSerializer serializer = DescriptorSerializer.createTopLevel(extension); + ProtoBuf.Package.Builder builder = serializer.packagePartProto(codegen.element.getPackageFqName(), members); + extension.serializeJvmPackage(builder, packagePartType); + + return new Pair<>(serializer, builder.build()); + } + @Override protected void generateSyntheticPartsAfterBody() { generateSyntheticAccessors(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java index cf8f4a5a6da..7fbb9ed385c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java @@ -179,6 +179,19 @@ public abstract class StackValue { return type == Type.VOID_TYPE ? none() : new OnStack(type); } + @NotNull + public static StackValue integerConstant(int value, @NotNull Type type) { + if (type == Type.LONG_TYPE) { + return constant(Long.valueOf(value), type); + } + else if (type == Type.BYTE_TYPE || type == Type.SHORT_TYPE || type == Type.INT_TYPE) { + return constant(Integer.valueOf(value), type); + } + else { + throw new AssertionError("Unexpected integer type: " + type); + } + } + @NotNull public static StackValue constant(@Nullable Object value, @NotNull Type type) { if (type == Type.BOOLEAN_TYPE) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/SuspendFunctionGenerationStrategy.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/SuspendFunctionGenerationStrategy.kt index 83c5786ac46..6cad1404b95 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/SuspendFunctionGenerationStrategy.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/SuspendFunctionGenerationStrategy.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.codegen.state.GenerationState import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.psi.KtFunction +import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature import org.jetbrains.kotlin.utils.addToStdlib.safeAs @@ -70,6 +71,6 @@ class SuspendFunctionGenerationStrategy( override fun doGenerateBody(codegen: ExpressionCodegen, signature: JvmMethodSignature) { this.codegen = codegen - codegen.returnExpression(declaration.bodyExpression) + codegen.returnExpression(declaration.bodyExpression ?: error("Function has no body: " + declaration.getElementTextWithContext())) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/processUninitializedStores.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/processUninitializedStores.kt index 5e5983dc629..5e3c9641ab7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/processUninitializedStores.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/processUninitializedStores.kt @@ -16,10 +16,8 @@ package org.jetbrains.kotlin.codegen.coroutines -import org.jetbrains.kotlin.codegen.optimization.common.CustomFramesMethodAnalyzer -import org.jetbrains.kotlin.codegen.optimization.common.OptimizationBasicInterpreter -import org.jetbrains.kotlin.codegen.optimization.common.StrictBasicValue -import org.jetbrains.kotlin.codegen.optimization.common.insnListOf +import org.jetbrains.kotlin.codegen.optimization.common.* +import org.jetbrains.kotlin.codegen.optimization.fixStack.peek import org.jetbrains.org.objectweb.asm.Opcodes import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.tree.* @@ -71,124 +69,161 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter * - restore constructor arguments */ internal fun processUninitializedStores(methodNode: MethodNode) { - val interpreter = UninitializedNewValueMarkerInterpreter() - val frames = CustomFramesMethodAnalyzer("fake", methodNode, interpreter, ::UninitializedNewValueFrame).analyze() - - for ((index, insn) in methodNode.instructions.toArray().withIndex()) { - val frame = frames[index] ?: continue - val uninitializedValue = frame.getUninitializedValueForConstructorCall(insn) ?: continue - - val copyUsages: Set = interpreter.uninitializedValuesToCopyUsages[uninitializedValue.newInsn]!! - assert(copyUsages.size > 0) { "At least DUP copy operation expected" } - - // Value generated by NEW wasn't store to local/field (only DUPed) - if (copyUsages.size == 1) continue - - (copyUsages + uninitializedValue.newInsn).forEach { - methodNode.instructions.remove(it) - } - - val indexOfConstructorArgumentFromTopOfStack = Type.getArgumentTypes((insn as MethodInsnNode).desc).size - val storedTypes = arrayListOf() - var nextVarIndex = methodNode.maxLocals - - for (i in 0 until indexOfConstructorArgumentFromTopOfStack) { - val value = frame.getStack(frame.stackSize - 1 - i) - val type = value.type - methodNode.instructions.insertBefore(insn, VarInsnNode(type.getOpcode(Opcodes.ISTORE), nextVarIndex)) - nextVarIndex += type.size - storedTypes.add(type) - } - methodNode.maxLocals = Math.max(methodNode.maxLocals, nextVarIndex) - - methodNode.instructions.insertBefore(insn, insnListOf( - TypeInsnNode(Opcodes.NEW, uninitializedValue.newInsn.desc), - InsnNode(Opcodes.DUP) - )) - - for (type in storedTypes.reversed()) { - nextVarIndex -= type.size - methodNode.instructions.insertBefore(insn, VarInsnNode(type.getOpcode(Opcodes.ILOAD), nextVarIndex)) - } - } + UninitializedStoresProcessor(methodNode, forCoroutines = true).run() } -private class UninitializedNewValue( - val newInsn: TypeInsnNode, val internalName: String -) : StrictBasicValue(Type.getObjectType(internalName)) { - override fun toString() = "UninitializedNewValue(internalName='$internalName')" -} +class UninitializedStoresProcessor(private val methodNode: MethodNode, private val forCoroutines: Boolean) { + private val isInSpecialMethod = methodNode.name == "" || methodNode.name == "" -private class UninitializedNewValueFrame(nLocals: Int, nStack: Int) : Frame(nLocals, nStack) { - override fun execute(insn: AbstractInsnNode, interpreter: Interpreter?) { - val replaceTopValueWithInitialized = getUninitializedValueForConstructorCall(insn) != null + fun run() { + val interpreter = UninitializedNewValueMarkerInterpreter() - super.execute(insn, interpreter) + val frames = CustomFramesMethodAnalyzer( + "fake", methodNode, interpreter, + this::UninitializedNewValueFrame + ).analyze() - if (replaceTopValueWithInitialized) { - // Drop top value - val value = pop() as UninitializedNewValue + for ((index, insn) in methodNode.instructions.toArray().withIndex()) { + val frame = frames[index] ?: continue + val uninitializedValue = frame.getUninitializedValueForConstructorCall(insn) ?: continue - // uninitialized value become initialized after call - push(StrictBasicValue(value.type)) + val newInsn = uninitializedValue.newInsn + val copyUsages: Set = interpreter.uninitializedValuesToCopyUsages[newInsn]!! + assert(copyUsages.isNotEmpty()) { "At least DUP copy operation expected" } + + // Value generated by NEW wasn't store to local/field (only DUPed) + if (copyUsages.size == 1) continue + + methodNode.instructions.run { + removeAll(copyUsages) + if (forCoroutines) { + remove(newInsn) + } + else { + // Replace 'NEW C' instruction with "manual" initialization of class 'C': + // LDC [typeName for C] + // INVOKESTATIC java/lang/Class.forName (Ljava/lang/String;)Ljava/lang/Class; + // POP + val typeNameForClass = newInsn.desc.replace('/', '.') + insertBefore(newInsn, LdcInsnNode(typeNameForClass)) + insertBefore( + newInsn, + MethodInsnNode( + Opcodes.INVOKESTATIC, + "java/lang/Class", "forName", "(Ljava/lang/String;)Ljava/lang/Class;", + false + ) + ) + set(newInsn, InsnNode(Opcodes.POP)) + } + } + + val indexOfConstructorArgumentFromTopOfStack = Type.getArgumentTypes((insn as MethodInsnNode).desc).size + val storedTypes = arrayListOf() + var nextVarIndex = methodNode.maxLocals + + for (i in 0 until indexOfConstructorArgumentFromTopOfStack) { + val value = frame.getStack(frame.stackSize - 1 - i) + val type = value.type + methodNode.instructions.insertBefore(insn, VarInsnNode(type.getOpcode(Opcodes.ISTORE), nextVarIndex)) + nextVarIndex += type.size + storedTypes.add(type) + } + methodNode.maxLocals = Math.max(methodNode.maxLocals, nextVarIndex) + + methodNode.instructions.insertBefore(insn, insnListOf( + TypeInsnNode(Opcodes.NEW, newInsn.desc), + InsnNode(Opcodes.DUP) + )) + + for (type in storedTypes.reversed()) { + nextVarIndex -= type.size + methodNode.instructions.insertBefore(insn, VarInsnNode(type.getOpcode(Opcodes.ILOAD), nextVarIndex)) + } } } -} -/** - * @return value generated by NEW that used as 0-th argument of constructor call or null if current instruction is not constructor call - */ -private fun Frame.getUninitializedValueForConstructorCall( - insn: AbstractInsnNode -): UninitializedNewValue? { - if (!insn.isConstructorCall()) return null + private inner class UninitializedNewValueFrame(nLocals: Int, nStack: Int) : Frame(nLocals, nStack) { + override fun execute(insn: AbstractInsnNode, interpreter: Interpreter?) { + val replaceTopValueWithInitialized = getUninitializedValueForConstructorCall(insn) != null - assert(insn.opcode == Opcodes.INVOKESPECIAL) { "Expected opcode Opcodes.INVOKESPECIAL for , but ${insn.opcode} found" } - val paramsCountIncludingReceiver = Type.getArgumentTypes((insn as MethodInsnNode).desc).size + 1 - val newValue = getStack(stackSize - (paramsCountIncludingReceiver + 1)) as? UninitializedNewValue ?: error("Expected value generated with NEW") + super.execute(insn, interpreter) - assert(getStack(stackSize - paramsCountIncludingReceiver) is UninitializedNewValue) { - "Next value after NEW should be one generated by DUP" + if (replaceTopValueWithInitialized) { + // Drop top value + val value = pop() as UninitializedNewValue + + // uninitialized value become initialized after call + push(StrictBasicValue(value.type)) + } + } } - return newValue -} + /** + * @return value generated by NEW that used as 0-th argument of constructor call or null if current instruction is not constructor call + */ + private fun Frame.getUninitializedValueForConstructorCall(insn: AbstractInsnNode): UninitializedNewValue? { + if (!insn.isConstructorCall()) return null -private fun AbstractInsnNode.isConstructorCall() = this is MethodInsnNode && this.name == "" + assert(insn.opcode == Opcodes.INVOKESPECIAL) { "Expected opcode Opcodes.INVOKESPECIAL for , but ${insn.opcode} found" } + val paramsCountIncludingReceiver = Type.getArgumentTypes((insn as MethodInsnNode).desc).size + 1 + val newValue = peek(paramsCountIncludingReceiver) as? UninitializedNewValue ?: + if (isInSpecialMethod) + return null + else + error("Expected value generated with NEW") -private class UninitializedNewValueMarkerInterpreter : OptimizationBasicInterpreter() { - val uninitializedValuesToCopyUsages = hashMapOf>() - override fun newOperation(insn: AbstractInsnNode): BasicValue? { - if (insn.opcode == Opcodes.NEW) { - uninitializedValuesToCopyUsages.getOrPut(insn) { mutableSetOf() } - return UninitializedNewValue(insn as TypeInsnNode, insn.desc) + assert(peek(paramsCountIncludingReceiver - 1) is UninitializedNewValue) { + "Next value after NEW should be one generated by DUP" } - return super.newOperation(insn) + + return newValue } - override fun copyOperation(insn: AbstractInsnNode, value: BasicValue?): BasicValue? { - if (value is UninitializedNewValue) { - uninitializedValuesToCopyUsages[value.newInsn]!!.add(insn) - return value - } - return super.copyOperation(insn, value) + private class UninitializedNewValue( + val newInsn: TypeInsnNode, + val internalName: String + ) : StrictBasicValue(Type.getObjectType(internalName)) { + override fun toString() = "UninitializedNewValue(internalName='$internalName')" } - override fun merge(v: BasicValue, w: BasicValue): BasicValue { - if (v === w) return v - if (v === StrictBasicValue.UNINITIALIZED_VALUE || w === StrictBasicValue.UNINITIALIZED_VALUE) { - return StrictBasicValue.UNINITIALIZED_VALUE + + private fun AbstractInsnNode.isConstructorCall() = this is MethodInsnNode && this.name == "" + + private class UninitializedNewValueMarkerInterpreter : OptimizationBasicInterpreter() { + val uninitializedValuesToCopyUsages = hashMapOf>() + override fun newOperation(insn: AbstractInsnNode): BasicValue? { + if (insn.opcode == Opcodes.NEW) { + uninitializedValuesToCopyUsages.getOrPut(insn) { mutableSetOf() } + return UninitializedNewValue(insn as TypeInsnNode, insn.desc) + } + return super.newOperation(insn) } - if (v is UninitializedNewValue || w is UninitializedNewValue) { - if ((v as? UninitializedNewValue)?.newInsn !== (w as? UninitializedNewValue)?.newInsn) { - // Merge of two different ANEW result is possible, but such values should not be used further + override fun copyOperation(insn: AbstractInsnNode, value: BasicValue?): BasicValue? { + if (value is UninitializedNewValue) { + uninitializedValuesToCopyUsages[value.newInsn]!!.add(insn) + return value + } + return super.copyOperation(insn, value) + } + + override fun merge(v: BasicValue, w: BasicValue): BasicValue { + if (v === w) return v + if (v === StrictBasicValue.UNINITIALIZED_VALUE || w === StrictBasicValue.UNINITIALIZED_VALUE) { return StrictBasicValue.UNINITIALIZED_VALUE } - return v - } + if (v is UninitializedNewValue || w is UninitializedNewValue) { + if ((v as? UninitializedNewValue)?.newInsn !== (w as? UninitializedNewValue)?.newInsn) { + // Merge of two different ANEW result is possible, but such values should not be used further + return StrictBasicValue.UNINITIALIZED_VALUE + } - return super.merge(v, w) + return v + } + + return super.merge(v, w) + } } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/MandatoryMethodTransforker.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/FixStackWithLabelNormalizationMethodTransformer.kt similarity index 100% rename from compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/MandatoryMethodTransforker.kt rename to compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/FixStackWithLabelNormalizationMethodTransformer.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationClassBuilderFactory.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationClassBuilderFactory.java index 3a8223e869e..812944c12a7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationClassBuilderFactory.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationClassBuilderFactory.java @@ -17,9 +17,7 @@ package org.jetbrains.kotlin.codegen.optimization; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.codegen.ClassBuilder; import org.jetbrains.kotlin.codegen.ClassBuilderFactory; -import org.jetbrains.kotlin.codegen.ClassBuilderMode; import org.jetbrains.kotlin.codegen.DelegatingClassBuilderFactory; import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin; diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationMethodVisitor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationMethodVisitor.kt index 33c62a48c77..04663015d31 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationMethodVisitor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationMethodVisitor.kt @@ -17,9 +17,9 @@ package org.jetbrains.kotlin.codegen.optimization import org.jetbrains.kotlin.codegen.TransformationMethodVisitor -import org.jetbrains.kotlin.codegen.optimization.boxing.StackPeepholeOptimizationsTransformer -import org.jetbrains.kotlin.codegen.optimization.boxing.RedundantBoxingMethodTransformer import org.jetbrains.kotlin.codegen.optimization.boxing.PopBackwardPropagationTransformer +import org.jetbrains.kotlin.codegen.optimization.boxing.RedundantBoxingMethodTransformer +import org.jetbrains.kotlin.codegen.optimization.boxing.StackPeepholeOptimizationsTransformer import org.jetbrains.kotlin.codegen.optimization.common.prepareForEmitting import org.jetbrains.kotlin.codegen.optimization.nullCheck.RedundantNullCheckMethodTransformer import org.jetbrains.kotlin.codegen.optimization.transformer.CompositeMethodTransformer @@ -35,11 +35,10 @@ class OptimizationMethodVisitor( signature: String?, exceptions: Array? ) : TransformationMethodVisitor(delegate, access, name, desc, signature, exceptions) { - override fun performTransformations(methodNode: MethodNode) { - MANDATORY_METHOD_TRANSFORMER.transform("fake", methodNode) + normalizationMethodTransformer.transform("fake", methodNode) if (canBeOptimized(methodNode) && !disableOptimization) { - OPTIMIZATION_TRANSFORMER.transform("fake", methodNode) + optimizationTransformer.transform("fake", methodNode) } methodNode.prepareForEmitting() } @@ -47,12 +46,13 @@ class OptimizationMethodVisitor( companion object { private val MEMORY_LIMIT_BY_METHOD_MB = 50 - private val MANDATORY_METHOD_TRANSFORMER = CompositeMethodTransformer( + val normalizationMethodTransformer = CompositeMethodTransformer( FixStackWithLabelNormalizationMethodTransformer(), + UninitializedStoresMethodTransformer(), MethodVerifier("AFTER mandatory stack transformations") ) - private val OPTIMIZATION_TRANSFORMER = CompositeMethodTransformer( + val optimizationTransformer = CompositeMethodTransformer( CapturedVarsOptimizationMethodTransformer(), RedundantNullCheckMethodTransformer(), RedundantCheckCastEliminationMethodTransformer(), diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/UninitializedStoresMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/UninitializedStoresMethodTransformer.kt new file mode 100644 index 00000000000..aab689820fa --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/UninitializedStoresMethodTransformer.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen.optimization + +import org.jetbrains.kotlin.codegen.coroutines.UninitializedStoresProcessor +import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer +import org.jetbrains.org.objectweb.asm.tree.MethodNode + +class UninitializedStoresMethodTransformer : MethodTransformer() { + override fun transform(internalClassName: String, methodNode: MethodNode) { + UninitializedStoresProcessor(methodNode, forCoroutines = false).run() + } +} \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt index 77fb229f4d8..adb8fe84bcb 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt @@ -214,3 +214,6 @@ internal inline fun AbstractInsnNode.isInsn(opcod internal inline fun AbstractInsnNode.takeInsnIf(opcode: Int, condition: T.() -> Boolean): T? = takeIf { it.opcode == opcode }?.safeAs()?.takeIf { it.condition() } +fun InsnList.removeAll(nodes: Collection) { + for (node in nodes) remove(node) +} \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/transformer/CompositeMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/transformer/CompositeMethodTransformer.kt index 5726321e506..e2e40b47b59 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/transformer/CompositeMethodTransformer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/transformer/CompositeMethodTransformer.kt @@ -18,8 +18,15 @@ package org.jetbrains.kotlin.codegen.optimization.transformer import org.jetbrains.org.objectweb.asm.tree.MethodNode -open class CompositeMethodTransformer(private vararg val transformers: MethodTransformer) : MethodTransformer() { +open class CompositeMethodTransformer(private val transformers: List) : MethodTransformer() { + constructor(vararg transformers: MethodTransformer?) : this(transformers.filterNotNull()) + override fun transform(internalClassName: String, methodNode: MethodNode) { transformers.forEach { it.transform(internalClassName, methodNode) } } + + companion object { + inline fun build(builder: MutableList.() -> Unit) = + CompositeMethodTransformer(ArrayList().apply { builder() }) + } } \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/range/forLoop/ForInUntilConstantRangeLoopGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/range/forLoop/ForInUntilConstantRangeLoopGenerator.kt index 37d870157bb..23872324fee 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/range/forLoop/ForInUntilConstantRangeLoopGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/range/forLoop/ForInUntilConstantRangeLoopGenerator.kt @@ -18,10 +18,8 @@ package org.jetbrains.kotlin.codegen.range.forLoop import org.jetbrains.kotlin.codegen.ExpressionCodegen import org.jetbrains.kotlin.codegen.StackValue -import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtForExpression import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall -import org.jetbrains.kotlin.resolve.constants.* import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue class ForInUntilConstantRangeLoopGenerator( @@ -36,5 +34,5 @@ class ForInUntilConstantRangeLoopGenerator( codegen.generateReceiverValue(from, false) override fun generateTo(): StackValue = - StackValue.constant(untilValue, asmElementType) + StackValue.integerConstant(untilValue, asmElementType) } \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt index 6a9269e3275..9da8888b465 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt @@ -179,7 +179,6 @@ class GenerationState @JvmOverloads constructor( val generateParametersMetadata: Boolean = configuration.getBoolean(JVMConfigurationKeys.PARAMETERS_METADATA) - val shouldInlineConstVals = languageVersionSettings.supportsFeature(LanguageFeature.InlineConstVals) init { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java index 9f941e06e52..a02a16fb7b5 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java @@ -831,11 +831,11 @@ public class KotlinTypeMapper { JvmCodegenUtil.isJvm8InterfaceWithDefaults(ownerForDefault, isJvm8Target, isJvm8TargetWithDefaults); } - public static boolean isAccessor(@NotNull CallableMemberDescriptor descriptor) { + public static boolean isAccessor(@Nullable CallableMemberDescriptor descriptor) { return descriptor instanceof AccessorForCallableDescriptor; } - public static boolean isStaticAccessor(@NotNull CallableMemberDescriptor descriptor) { + public static boolean isStaticAccessor(@Nullable CallableMemberDescriptor descriptor) { if (descriptor instanceof AccessorForConstructorDescriptor) return false; return isAccessor(descriptor); } diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index 590f0f65671..668cf867fa6 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -32,7 +32,8 @@ val testDistProjects = listOf( ":kotlin-daemon-client", ":kotlin-preloader", ":plugins:android-extensions-compiler", - ":kotlin-ant") + ":kotlin-ant", + ":kotlin-annotations-jvm") dependencies { depDistProjects.forEach { @@ -82,36 +83,85 @@ projectTest { evaluationDependsOn(":compiler:tests-common-jvm6") -fun Project.codegenTest(taskName: String, body: Test.() -> Unit): Test = projectTest(taskName) { +fun Project.codegenTest(taskName: String, jdk: String, body: Test.() -> Unit): Test = projectTest(taskName) { dependsOn(*testDistProjects.map { "$it:dist" }.toTypedArray()) workingDir = rootDir - environment("TEST_SERVER_CLASSES_DIRS", project(":compiler:tests-common-jvm6").the().sourceSets.getByName("main").output.classesDirs.asPath) - filter.includeTestsMatching("org.jetbrains.kotlin.codegen.CodegenJdkCommonTestSuite*") + + filter.includeTestsMatching("org.jetbrains.kotlin.codegen.BlackBoxCodegenTestGenerated*") + filter.includeTestsMatching("org.jetbrains.kotlin.codegen.BlackBoxInlineCodegenTestGenerated*") + filter.includeTestsMatching("org.jetbrains.kotlin.codegen.CompileKotlinAgainstInlineKotlinTestGenerated*") + filter.includeTestsMatching("org.jetbrains.kotlin.codegen.CompileKotlinAgainstKotlinTestGenerated*") + filter.includeTestsMatching("org.jetbrains.kotlin.codegen.BlackBoxAgainstJavaCodegenTestGenerated*") + + if (jdk == "JDK_9") { + jvmArgs = listOf("--add-opens", "java.desktop/javax.swing=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED") + } body() + doFirst { + val jdkPath = project.property(jdk) ?: error("$jdk is not optional to run this test") + executable = "$jdkPath/bin/java" + println("Running test with $executable") + } +}.also { + task(taskName.replace(Regex("-[a-z]"), { it.value.takeLast(1).toUpperCase() })) { + dependsOn(it) + group = "verification" + } } -codegenTest("codegen-target6-jvm6-test") { +codegenTest("codegen-target6-jvm6-test", "JDK_18") { + dependsOn(":compiler:tests-common-jvm6:build") + + //TODO make port flexible + val port = "5100" + var jdkProcess: Process? = null + + doFirst { + logger.info("Configuring JDK 6 server...") + val jdkPath = project.property("JDK_16") ?: error("JDK_16 is not optional to run this test") + val executable = "$jdkPath/bin/java" + val main = "org.jetbrains.kotlin.test.clientserver.TestProcessServer" + + val classpath = getSourceSetsFrom(":compiler:tests-common-jvm6")["main"].output.asPath + ":" + + getSourceSetsFrom(":kotlin-stdlib")["main"].output.asPath + ":" + + getSourceSetsFrom(":kotlin-stdlib")["builtins"].output.asPath + ":" + + getSourceSetsFrom(":kotlin-test:kotlin-test-jvm")["main"].output.asPath + + logger.debug("Server classpath: $classpath") + + val builder = ProcessBuilder(executable, "-cp", classpath, main, port) + builder.directory(rootDir) + + builder.inheritIO() + builder.redirectErrorStream(true) + + logger.info("Starting JDK 6 server $executable") + jdkProcess = builder.start() + + } systemProperty("kotlin.test.default.jvm.target", "1.6") systemProperty("kotlin.test.java.compilation.target", "1.6") - systemProperty("kotlin.test.box.in.separate.process.port", "5100") + systemProperty("kotlin.test.box.in.separate.process.port", port) + + doLast { + logger.info("Stopping JDK 6 server...") + jdkProcess?.destroy() + } } -codegenTest("codegen-target6-jvm9-test") { +codegenTest("codegen-target6-jvm9-test", "JDK_9") { systemProperty("kotlin.test.default.jvm.target", "1.6") - jvmArgs = listOf("--add-opens", "java.desktop/javax.swing=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED") } -codegenTest("codegen-target8-jvm8-test") { +codegenTest("codegen-target8-jvm8-test", "JDK_18") { systemProperty("kotlin.test.default.jvm.target", "1.8") } -codegenTest("codegen-target8-jvm9-test") { +codegenTest("codegen-target8-jvm9-test", "JDK_9") { systemProperty("kotlin.test.default.jvm.target", "1.8") - jvmArgs = listOf("--add-opens", "java.desktop/javax.swing=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED") } -codegenTest("codegen-target9-jvm9-test") { +codegenTest("codegen-target9-jvm9-test", "JDK_9") { systemProperty("kotlin.test.default.jvm.target", "1.8") systemProperty("kotlin.test.substitute.bytecode.1.8.to.1.9", "true") - jvmArgs = listOf("--add-opens", "java.desktop/javax.swing=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED") } diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt index b6d1acacbef..a3a61b0f608 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt @@ -48,11 +48,12 @@ class K2JSCompilerArguments : CommonCompilerArguments() { var sourceMapPrefix: String? by FreezableVar(null) @Argument( - value = "-source-map-source-roots", + value = "-source-map-base-dirs", + deprecatedName = "-source-map-source-roots", valueDescription = "", description = "Base directories which are used to calculate relative paths to source files in source map" ) - var sourceMapSourceRoots: String? by FreezableVar(null) + var sourceMapBaseDirs: String? by FreezableVar(null) @GradleOption(DefaultValues.JsSourceMapContentModes::class) @Argument( diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index e5cdd88c0dc..4a291c984ce 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.config.AnalysisFlag import org.jetbrains.kotlin.config.JvmTarget import org.jetbrains.kotlin.utils.Jsr305State +import org.jetbrains.kotlin.utils.ReportLevel class K2JVMCompilerArguments : CommonCompilerArguments() { companion object { @@ -165,10 +166,15 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { @Argument( value = "-Xjsr305", deprecatedName = "-Xjsr305-annotations", - valueDescription = "{ignore|strict|warn}", - description = "Specify global behavior for JSR-305 nullability annotations: ignore, treat as other supported nullability annotations, or report a warning" + valueDescription = "{ignore|strict|warn}" + + "|under-migration:{ignore-strict-warn}" + + "|@:{ignore|strict|warn}", + description = "Specify behaviors for JSR-305 nullability annotations for: " + + "global, annotated with @UnderMigration or custom annotation " + + "with specific value: ignore, treat as other supported nullability annotations, or report a warning. " + + "Note that strict value is experimental yet" ) - var jsr305: String? by FreezableVar(Jsr305State.DEFAULT.description) + var jsr305: Array? by FreezableVar(null) @Argument( value = "-Xno-exception-on-explicit-equals-for-boxed-null", @@ -181,20 +187,81 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { override fun configureAnalysisFlags(collector: MessageCollector): MutableMap, Any> { val result = super.configureAnalysisFlags(collector) + result[AnalysisFlag.jsr305] = parseJsr305(collector) + return result + } - if (jsr305 == "enable") { - collector.report( - CompilerMessageSeverity.STRONG_WARNING, - "Option 'enable' for -Xjsr305 flag is deprecated. Please use 'strict' instead" - ) - result.put(AnalysisFlag.jsr305, Jsr305State.STRICT) + fun parseJsr305(collector: MessageCollector): Jsr305State { + var global: ReportLevel? = null + var migration: ReportLevel? = null + val userDefined = mutableMapOf() + + fun parseJsr305UnderMigration(collector: MessageCollector, item: String): ReportLevel? { + val rawState = item.split(":").takeIf { it.size == 2 }?.get(1) + return ReportLevel.findByDescription(rawState) ?: reportUnrecognizedJsr305(collector, item).let { null } } - else { - Jsr305State.findByDescription(jsr305)?.let { - result.put(AnalysisFlag.jsr305, it) + + jsr305?.forEach { item -> + when { + item.startsWith("@") -> { + val (name, state) = parseJsr305UserDefined(collector, item) ?: return@forEach + val current = userDefined[name] + if (current != null) { + reportDuplicateJsr305(collector, "@$name:${current.description}", item) + return@forEach + } + userDefined[name] = state + } + item.startsWith("under-migration") -> { + if (migration != null) { + reportDuplicateJsr305(collector, "under-migration:${migration?.description}", item) + return@forEach + } + + migration = parseJsr305UnderMigration(collector, item) + } + item == "enable" -> { + collector.report( + CompilerMessageSeverity.STRONG_WARNING, + "Option 'enable' for -Xjsr305 flag is deprecated. Please use 'strict' instead" + ) + if (global != null) return@forEach + + global = ReportLevel.STRICT + } + else -> { + if (global != null) { + reportDuplicateJsr305(collector, global!!.description, item) + return@forEach + } + global = ReportLevel.findByDescription(item) + } } } - return result + val state = Jsr305State(global ?: ReportLevel.WARN, migration, userDefined) + return if (state == Jsr305State.DISABLED) Jsr305State.DISABLED else state + } + + private fun reportUnrecognizedJsr305(collector: MessageCollector, item: String) { + collector.report(CompilerMessageSeverity.ERROR, "Unrecognized -Xjsr305 value: $item") + } + + private fun reportDuplicateJsr305(collector: MessageCollector, first: String, second: String) { + collector.report(CompilerMessageSeverity.ERROR, "Conflict duplicating -Xjsr305 value: $first, $second") + } + + private fun parseJsr305UserDefined(collector: MessageCollector, item: String): Pair? { + val (name, rawState) = item.substring(1).split(":").takeIf { it.size == 2 } ?: run { + reportUnrecognizedJsr305(collector, item) + return null + } + + val state = ReportLevel.findByDescription(rawState) ?: run { + reportUnrecognizedJsr305(collector, item) + return null + } + + return name to state } } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java index 1d2f6786a7d..f6afab2fbc8 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java @@ -175,8 +175,9 @@ public abstract class CLICompiler extends CLI configuration.put(CLIConfigurationKeys.IS_API_VERSION_EXPLICIT, true); } + MessageCollector collector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY); if (apiVersion.compareTo(languageVersion) > 0) { - configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report( + collector.report( ERROR, "-api-version (" + apiVersion.getVersionString() + ") cannot be greater than " + "-language-version (" + languageVersion.getVersionString() + ")", @@ -185,7 +186,7 @@ public abstract class CLICompiler extends CLI } if (!languageVersion.isStable()) { - configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report( + collector.report( STRONG_WARNING, "Language version " + languageVersion.getVersionString() + " is experimental, there are " + "no backwards compatibility guarantees for new language and library features", @@ -206,7 +207,7 @@ public abstract class CLICompiler extends CLI CommonConfigurationKeysKt.setLanguageVersionSettings(configuration, new LanguageVersionSettingsImpl( languageVersion, ApiVersion.createByLanguageVersion(apiVersion), - arguments.configureAnalysisFlags(configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)), + arguments.configureAnalysisFlags(collector), extraLanguageFeatures )); } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java b/compiler/cli/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java index 04926cb3d11..24b6088880d 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java @@ -357,8 +357,8 @@ public class K2JSCompiler extends CLICompiler { configuration.put(JSConfigurationKeys.SOURCE_MAP_PREFIX, arguments.getSourceMapPrefix()); } - String sourceMapSourceRoots = arguments.getSourceMapSourceRoots() != null ? - arguments.getSourceMapSourceRoots() : + String sourceMapSourceRoots = arguments.getSourceMapBaseDirs() != null ? + arguments.getSourceMapBaseDirs() : calculateSourceMapSourceRoot(messageCollector, arguments); List sourceMapSourceRootList = StringUtil.split(sourceMapSourceRoots, File.pathSeparator); configuration.put(JSConfigurationKeys.SOURCE_MAP_SOURCE_ROOTS, sourceMapSourceRootList); @@ -367,7 +367,7 @@ public class K2JSCompiler extends CLICompiler { if (arguments.getSourceMapPrefix() != null) { messageCollector.report(WARNING, "source-map-prefix argument has no effect without source map", null); } - if (arguments.getSourceMapSourceRoots() != null) { + if (arguments.getSourceMapBaseDirs() != null) { messageCollector.report(WARNING, "source-map-source-root argument has no effect without source map", null); } } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/ClasspathRootsResolver.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/ClasspathRootsResolver.kt index 46cd58d5360..95c66a1b292 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/ClasspathRootsResolver.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/ClasspathRootsResolver.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.isValidJavaFqName import org.jetbrains.kotlin.resolve.jvm.modules.JavaModule import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleInfo -import java.io.File +import org.jetbrains.kotlin.resolve.jvm.modules.KOTLIN_STDLIB_MODULE_NAME import java.io.IOException import java.util.jar.Attributes import java.util.jar.Manifest @@ -51,55 +51,82 @@ class ClasspathRootsResolver( private val additionalModules: List, private val contentRootToVirtualFile: (JvmContentRoot) -> VirtualFile?, private val javaModuleFinder: CliJavaModuleFinder, - private val requireStdlibModule: Boolean + private val requireStdlibModule: Boolean, + private val outputDirectory: VirtualFile? ) { val javaModuleGraph = JavaModuleGraph(javaModuleFinder) data class RootsAndModules(val roots: List, val modules: List) - fun convertClasspathRoots(contentRoots: List): RootsAndModules { - val result = mutableListOf() + private data class RootWithPrefix(val root: VirtualFile, val packagePrefix: String?) - val modules = ArrayList() + fun convertClasspathRoots(contentRoots: List): RootsAndModules { + val javaSourceRoots = mutableListOf() + val jvmClasspathRoots = mutableListOf() + val jvmModulePathRoots = mutableListOf() for (contentRoot in contentRoots) { if (contentRoot !is JvmContentRoot) continue val root = contentRootToVirtualFile(contentRoot) ?: continue - when (contentRoot) { - is JavaSourceRoot -> { - val modularRoot = modularSourceRoot(root) - if (modularRoot != null) { - modules += modularRoot - } - else { - result += JavaRoot(root, JavaRoot.RootType.SOURCE, contentRoot.packagePrefix?.let { prefix -> - if (isValidJavaFqName(prefix)) FqName(prefix) - else null.also { - report(STRONG_WARNING, "Invalid package prefix name is ignored: $prefix") - } - }) - } - } - is JvmClasspathRoot -> { - result += JavaRoot(root, JavaRoot.RootType.BINARY) - } - is JvmModulePathRoot -> { - val module = modularBinaryRoot(root, contentRoot.file) - if (module != null) { - modules += module - } - } + is JavaSourceRoot -> javaSourceRoots += RootWithPrefix(root, contentRoot.packagePrefix) + is JvmClasspathRoot -> jvmClasspathRoots += root + is JvmModulePathRoot -> jvmModulePathRoots += root else -> error("Unknown root type: $contentRoot") } } + return computeRoots(javaSourceRoots, jvmClasspathRoots, jvmModulePathRoots) + } + + private fun computeRoots( + javaSourceRoots: List, + jvmClasspathRoots: List, + jvmModulePathRoots: List + ): RootsAndModules { + val result = mutableListOf() + val modules = mutableListOf() + + val hasOutputDirectoryInClasspath = outputDirectory in jvmClasspathRoots || outputDirectory in jvmModulePathRoots + + for ((root, packagePrefix) in javaSourceRoots) { + val modularRoot = modularSourceRoot(root, hasOutputDirectoryInClasspath) + if (modularRoot != null) { + modules += modularRoot + } + else { + result += JavaRoot(root, JavaRoot.RootType.SOURCE, packagePrefix?.let { prefix -> + if (isValidJavaFqName(prefix)) FqName(prefix) + else null.also { + report(STRONG_WARNING, "Invalid package prefix name is ignored: $prefix") + } + }) + } + } + + for (root in jvmClasspathRoots) { + result += JavaRoot(root, JavaRoot.RootType.BINARY) + } + + val outputDirectoryAddedAsPartOfModule = modules.any { module -> module.moduleRoots.any { it.file == outputDirectory } } + + for (root in jvmModulePathRoots) { + // Do not add output directory as a separate module if we're compiling an explicit named module. + // It's going to be included as a root of our module in modularSourceRoot. + if (outputDirectoryAddedAsPartOfModule && root == outputDirectory) continue + + val module = modularBinaryRoot(root) + if (module != null) { + modules += module + } + } + addModularRoots(modules, result) return RootsAndModules(result, modules) } - private fun modularSourceRoot(root: VirtualFile): JavaModule.Explicit? { + private fun findSourceModuleInfo(root: VirtualFile): Pair? { val moduleInfoFile = when { root.isDirectory -> root.findChild(PsiJavaModule.MODULE_INFO_FILE) @@ -109,10 +136,21 @@ class ClasspathRootsResolver( val psiFile = psiManager.findFile(moduleInfoFile) ?: return null val psiJavaModule = psiFile.children.singleOrNull { it is PsiJavaModule } as? PsiJavaModule ?: return null - return JavaModule.Explicit(JavaModuleInfo.create(psiJavaModule), root, moduleInfoFile, isBinary = false) + + return moduleInfoFile to psiJavaModule } - private fun modularBinaryRoot(root: VirtualFile, originalFile: File): JavaModule? { + private fun modularSourceRoot(root: VirtualFile, hasOutputDirectoryInClasspath: Boolean): JavaModule.Explicit? { + val (moduleInfoFile, psiJavaModule) = findSourceModuleInfo(root) ?: return null + val sourceRoot = JavaModule.Root(root, isBinary = false) + val roots = + if (hasOutputDirectoryInClasspath) + listOf(sourceRoot, JavaModule.Root(outputDirectory!!, isBinary = true)) + else listOf(sourceRoot) + return JavaModule.Explicit(JavaModuleInfo.create(psiJavaModule), roots, moduleInfoFile) + } + + private fun modularBinaryRoot(root: VirtualFile): JavaModule? { val isJar = root.fileSystem.protocol == StandardFileSystems.JAR_PROTOCOL val manifest: Attributes? by lazy(NONE) { readManifestAttributes(root) } @@ -124,22 +162,25 @@ class ClasspathRootsResolver( if (moduleInfoFile != null) { val moduleInfo = JavaModuleInfo.read(moduleInfoFile) ?: return null - return JavaModule.Explicit(moduleInfo, root, moduleInfoFile, isBinary = true) + return JavaModule.Explicit(moduleInfo, listOf(JavaModule.Root(root, isBinary = true)), moduleInfoFile) } // Only .jar files can be automatic modules if (isJar) { + val moduleRoot = listOf(JavaModule.Root(root, isBinary = true)) + val automaticModuleName = manifest?.getValue(AUTOMATIC_MODULE_NAME) if (automaticModuleName != null) { - return JavaModule.Automatic(automaticModuleName, root) + return JavaModule.Automatic(automaticModuleName, moduleRoot) } + val originalFile = VfsUtilCore.virtualToIoFile(root) val moduleName = LightJavaModule.moduleName(originalFile.nameWithoutExtension) if (moduleName.isEmpty()) { report(ERROR, "Cannot infer automatic module name for the file", VfsUtilCore.getVirtualFileForJar(root) ?: root) return null } - return JavaModule.Automatic(moduleName, root) + return JavaModule.Automatic(moduleName, moduleRoot) } return null @@ -156,7 +197,9 @@ class ClasspathRootsResolver( } private fun addModularRoots(modules: List, result: MutableList) { - val sourceModules = modules.filterIsInstance().filterNot(JavaModule::isBinary) + // In current implementation, at most one source module is supported. This can be relaxed in the future if we support another + // compilation mode, similar to java's --module-source-path + val sourceModules = modules.filterIsInstance().filter(JavaModule::isSourceModule) if (sourceModules.size > 1) { for (module in sourceModules) { report(ERROR, "Too many source module declarations found", module.moduleInfoFile) @@ -169,11 +212,15 @@ class ClasspathRootsResolver( if (existing == null) { javaModuleFinder.addUserModule(module) } - else if (module.moduleRoot != existing.moduleRoot) { - val jar = VfsUtilCore.getVirtualFileForJar(module.moduleRoot) ?: module.moduleRoot - val existingPath = (VfsUtilCore.getVirtualFileForJar(existing.moduleRoot) ?: existing.moduleRoot).path + else if (module.moduleRoots != existing.moduleRoots) { + fun JavaModule.getRootFile() = + moduleRoots.firstOrNull()?.file?.let { VfsUtilCore.getVirtualFileForJar(it) ?: it } + + val thisFile = module.getRootFile() + val existingFile = existing.getRootFile() + val atExistingPath = if (existingFile == null) "" else " at: ${existingFile.path}" report(STRONG_WARNING, "The root is ignored because a module with the same name '${module.name}' " + - "has been found earlier on the module path at: $existingPath", jar) + "has been found earlier on the module path$atExistingPath", thisFile) } } @@ -212,18 +259,17 @@ class ClasspathRootsResolver( report(ERROR, "Module $moduleName cannot be found in the module graph") } else { - result.add(JavaRoot( - module.moduleRoot, - if (module.isBinary) JavaRoot.RootType.BINARY else JavaRoot.RootType.SOURCE - )) + for ((root, isBinary) in module.moduleRoots) { + result.add(JavaRoot(root, if (isBinary) JavaRoot.RootType.BINARY else JavaRoot.RootType.SOURCE)) + } } } - if (requireStdlibModule && sourceModule != null && "kotlin.stdlib" !in allDependencies) { + if (requireStdlibModule && sourceModule != null && KOTLIN_STDLIB_MODULE_NAME !in allDependencies) { report( ERROR, "The Kotlin standard library is not found in the module graph. " + - "Please ensure you have the 'requires kotlin.stdlib' clause in your module definition", + "Please ensure you have the 'requires $KOTLIN_STDLIB_MODULE_NAME' clause in your module definition", sourceModule.moduleInfoFile ) } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt index 6347f6a22f9..5630aac8486 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt @@ -204,13 +204,19 @@ class KotlinCoreEnvironment private constructor( val javaModuleFinder = CliJavaModuleFinder(jdkHome?.path?.let { path -> jrtFileSystem?.findFileByPath(path + URLUtil.JAR_SEPARATOR) }) + + val outputDirectory = + configuration.get(JVMConfigurationKeys.MODULES)?.singleOrNull()?.getOutputDirectory() + ?: configuration.get(JVMConfigurationKeys.OUTPUT_DIRECTORY)?.absolutePath + classpathRootsResolver = ClasspathRootsResolver( PsiManager.getInstance(project), messageCollector, configuration.getList(JVMConfigurationKeys.ADDITIONAL_JAVA_MODULES), this::contentRootToVirtualFile, javaModuleFinder, - !configuration.getBoolean(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE) + !configuration.getBoolean(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE), + outputDirectory?.let(this::findLocalFile) ) val (initialRoots, javaModules) = @@ -331,7 +337,8 @@ class KotlinCoreEnvironment private constructor( } } - internal fun findLocalFile(path: String) = applicationEnvironment.localFileSystem.findFileByPath(path) + internal fun findLocalFile(path: String): VirtualFile? = + applicationEnvironment.localFileSystem.findFileByPath(path) private fun findLocalFile(root: JvmContentRoot): VirtualFile? { return findLocalFile(root.file.absolutePath).also { diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/modules/CliJavaModuleFinder.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/modules/CliJavaModuleFinder.kt index 87e9eda494e..5abe6b073c1 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/modules/CliJavaModuleFinder.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/modules/CliJavaModuleFinder.kt @@ -42,6 +42,6 @@ class CliJavaModuleFinder(jrtFileSystemRoot: VirtualFile?) : JavaModuleFinder { private fun findSystemModule(moduleRoot: VirtualFile): JavaModule.Explicit? { val file = moduleRoot.findChild(PsiJavaModule.MODULE_INFO_CLS_FILE) ?: return null val moduleInfo = JavaModuleInfo.read(file) ?: return null - return JavaModule.Explicit(moduleInfo, moduleRoot, file, isBinary = true) + return JavaModule.Explicit(moduleInfo, listOf(JavaModule.Root(moduleRoot, isBinary = true)), file) } } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/modules/CliJavaModuleResolver.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/modules/CliJavaModuleResolver.kt index a7e15343179..24fab9f872e 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/modules/CliJavaModuleResolver.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/modules/CliJavaModuleResolver.kt @@ -32,12 +32,12 @@ class CliJavaModuleResolver( private val systemModules: List ) : JavaModuleResolver { init { - assert(userModules.count { !it.isBinary } <= 1) { + assert(userModules.count(JavaModule::isSourceModule) <= 1) { "Modules computed by ClasspathRootsResolver cannot have more than one source module: $userModules" } } - private val sourceModule: JavaModule? = userModules.firstOrNull { !it.isBinary } + private val sourceModule: JavaModule? = userModules.firstOrNull(JavaModule::isSourceModule) private fun findJavaModule(file: VirtualFile): JavaModule? { if (file.fileSystem.protocol == StandardFileSystems.JRT_PROTOCOL) { @@ -46,13 +46,13 @@ class CliJavaModuleResolver( return when (file.fileType) { KotlinFileType.INSTANCE, JavaFileType.INSTANCE -> sourceModule - JavaClassFileType.INSTANCE -> userModules.firstOrNull { module -> module.isBinary && file in module } + JavaClassFileType.INSTANCE -> userModules.firstOrNull { module -> file in module } else -> null } } private operator fun JavaModule.contains(file: VirtualFile): Boolean = - VfsUtilCore.isAncestor(moduleRoot, file, false) + moduleRoots.any { (root, isBinary) -> isBinary && VfsUtilCore.isAncestor(root, file, false) } override fun checkAccessibility( fileFromOurModule: VirtualFile?, referencedFile: VirtualFile, referencedPackage: FqName? diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/DelegatePackageMemberDeclarationProvider.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/DelegatePackageMemberDeclarationProvider.kt index a32b50bb5e6..623a52937a3 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/DelegatePackageMemberDeclarationProvider.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/DelegatePackageMemberDeclarationProvider.kt @@ -41,4 +41,6 @@ open class DelegatePackageMemberDeclarationProvider(var delegate: PackageMemberD override fun getClassOrObjectDeclarations(name: Name) = delegate.getClassOrObjectDeclarations(name) override fun getTypeAliasDeclarations(name: Name) = delegate.getTypeAliasDeclarations(name) + + override fun getDeclarationNames() = delegate.getDeclarationNames() } diff --git a/compiler/daemon/daemon-common/src/org/jetbrains/kotlin/daemon/common/CompilationOptions.kt b/compiler/daemon/daemon-common/src/org/jetbrains/kotlin/daemon/common/CompilationOptions.kt index 3ebd25bc0b5..373cb9569dd 100644 --- a/compiler/daemon/daemon-common/src/org/jetbrains/kotlin/daemon/common/CompilationOptions.kt +++ b/compiler/daemon/daemon-common/src/org/jetbrains/kotlin/daemon/common/CompilationOptions.kt @@ -48,7 +48,9 @@ class IncrementalCompilationOptions( /** @See [ReportSeverity] */ reportSeverity: Int, /** @See [CompilationResultCategory]] */ - requestedCompilationResults: Array + requestedCompilationResults: Array, + val resultDifferenceFile: File? = null, + val friendDifferenceFile: File? = null ) : CompilationOptions(compilerMode, targetPlatform, reportCategories, reportSeverity, requestedCompilationResults) { companion object { const val serialVersionUID: Long = 0 diff --git a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt index f95b8bf708d..578f6fc84e3 100644 --- a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt +++ b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt @@ -507,9 +507,12 @@ class CompileServiceImpl( workingDir, enabled = true) - return IncrementalJvmCompilerRunner(workingDir, javaSourceRoots, versions, reporter, annotationFileUpdater, - artifactChanges, changesRegistry) - .compile(allKotlinFiles, k2jvmArgs, compilerMessageCollector, { changedFiles }) + val compiler = IncrementalJvmCompilerRunner(workingDir, javaSourceRoots, versions, + reporter, annotationFileUpdater, + artifactChanges, changesRegistry, + buildHistoryFile = incrementalCompilationOptions.resultDifferenceFile, + friendBuildHistoryFile = incrementalCompilationOptions.friendDifferenceFile) + return compiler.compile(allKotlinFiles, k2jvmArgs, compilerMessageCollector, { changedFiles }) } override fun leaseReplSession( diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Annotations.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Annotations.kt index 10e21f38a3f..e35f34d070c 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Annotations.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Annotations.kt @@ -22,9 +22,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addToStdlib.safeAs -import org.jetbrains.org.objectweb.asm.AnnotationVisitor -import org.jetbrains.org.objectweb.asm.MethodVisitor -import org.jetbrains.org.objectweb.asm.Type +import org.jetbrains.org.objectweb.asm.* import java.lang.reflect.Array internal class AnnotationsCollectorMethodVisitor( @@ -55,6 +53,27 @@ internal class AnnotationsCollectorMethodVisitor( return BinaryJavaAnnotation.addAnnotation(annotations, desc, context, signatureParser) } + + override fun visitTypeAnnotation(typeRef: Int, typePath: TypePath?, desc: String, visible: Boolean): AnnotationVisitor? { + // TODO: support annotations on type arguments + if (typePath != null) return null + + val typeReference = TypeReference(typeRef) + + return when (typeReference.sort) { + TypeReference.METHOD_RETURN -> member.safeAs()?.returnType?.let { + BinaryJavaAnnotation.addTypeAnnotation(it, desc, context, signatureParser) + } + + TypeReference.METHOD_FORMAL_PARAMETER -> + BinaryJavaAnnotation.addTypeAnnotation( + member.valueParameters[typeReference.formalParameterIndex].type, + desc, context, signatureParser + ) + + else -> null + } + } } class BinaryJavaAnnotation private constructor( @@ -87,6 +106,20 @@ class BinaryJavaAnnotation private constructor( return annotationVisitor } + + fun addTypeAnnotation( + type: JavaType, + desc: String, + context: ClassifierResolutionContext, + signatureParser: BinaryClassSignatureParser + ): AnnotationVisitor? { + type as? PlainJavaClassifierType ?: return null + + val (javaAnnotation, annotationVisitor) = createAnnotationAndVisitor(desc, context, signatureParser) + type.addAnnotation(javaAnnotation) + + return annotationVisitor + } } private val classifierResolutionResult by lazy(LazyThreadSafetyMode.NONE) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt index e5335c657f9..2dbcc1bb1bd 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt @@ -162,6 +162,12 @@ class BinaryJavaClass( object : FieldVisitor(ASM_API_VERSION_FOR_CLASS_READING) { override fun visitAnnotation(desc: String, visible: Boolean) = BinaryJavaAnnotation.addAnnotation(this@run.annotations, desc, context, signatureParser) + + override fun visitTypeAnnotation(typeRef: Int, typePath: TypePath?, desc: String, visible: Boolean) = + if (typePath == null) + BinaryJavaAnnotation.addTypeAnnotation(type, desc, context, signatureParser) + else + null } } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Types.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Types.kt index 609011c2b17..47542d57c07 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Types.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Types.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.load.java.structure.impl.classFiles +import com.intellij.util.containers.ContainerUtil import org.jetbrains.kotlin.builtins.PrimitiveType import org.jetbrains.kotlin.load.java.structure.* import org.jetbrains.kotlin.name.FqName @@ -39,9 +40,18 @@ internal class PlainJavaClassifierType( get() = typeArguments.isEmpty() && classifierResolverResult.classifier?.safeAs()?.typeParameters?.isNotEmpty() == true - // TODO: support type annotations - override val annotations get() = emptyList() - override fun findAnnotation(fqName: FqName) = null + private var _annotations = emptyList() + override val annotations get() = _annotations + + override fun findAnnotation(fqName: FqName) = annotations.find { it.classId?.asSingleFqName() == fqName } + + internal fun addAnnotation(annotation: JavaAnnotation) { + if (_annotations.isEmpty()) { + _annotations = ContainerUtil.newSmartList() + } + + (_annotations as MutableList).add(annotation) + } override val isDeprecatedInJavaDoc get() = false diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/modules/JavaModule.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/modules/JavaModule.kt index 3d183abb2aa..50b6a23efa8 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/modules/JavaModule.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/modules/JavaModule.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.resolve.jvm.modules +import com.intellij.ide.highlighter.JavaFileType import com.intellij.openapi.vfs.VirtualFile import org.jetbrains.kotlin.name.FqName @@ -28,11 +29,11 @@ interface JavaModule { val name: String /** - * A directory or the root of a .jar file on the module path. Can also be the path to the `module-info.java` file if that path - * was passed as an explicit argument to the compiler. - * In case of an explicit module, module-info.class file can be found in its children. + * A non-empty list of directories or roots of .jar files on the module path. Can also contain the path to the `module-info.java` file + * if that path was passed as an explicit argument to the compiler. + * In case of an explicit module, module-info.class or module-info.java file must exist in at least one of these roots (the first wins). */ - val moduleRoot: VirtualFile + val moduleRoots: List /** * A module-info.class or module-info.java file where this module was loaded from. @@ -40,10 +41,11 @@ interface JavaModule { val moduleInfoFile: VirtualFile? /** - * `true` if this module is either an automatic module on the module path, or an explicit module loaded from module-info.class. - * `false` if this module is an explicit module loaded from module-info.java. + * `true` if this module is an explicit module loaded from module-info.java, `false` otherwise. This usually corresponds to the module + * currently being compiled. + * Note that in case of partial/incremental compilation, the source module may contain both binary roots and non-binary roots. */ - val isBinary: Boolean + val isSourceModule: Boolean /** * `true` if this module exports the package with the given FQ name to all dependent modules. @@ -64,10 +66,12 @@ interface JavaModule { */ fun exportsTo(packageFqName: FqName, moduleName: String): Boolean - class Automatic(override val name: String, override val moduleRoot: VirtualFile) : JavaModule { + data class Root(val file: VirtualFile, val isBinary: Boolean) + + class Automatic(override val name: String, override val moduleRoots: List) : JavaModule { override val moduleInfoFile: VirtualFile? get() = null - override val isBinary: Boolean get() = true + override val isSourceModule: Boolean get() = false override fun exports(packageFqName: FqName): Boolean = true @@ -78,13 +82,15 @@ interface JavaModule { class Explicit( val moduleInfo: JavaModuleInfo, - override val moduleRoot: VirtualFile, - override val moduleInfoFile: VirtualFile, - override val isBinary: Boolean + override val moduleRoots: List, + override val moduleInfoFile: VirtualFile ) : JavaModule { override val name: String get() = moduleInfo.moduleName + override val isSourceModule: Boolean + get() = moduleInfoFile.fileType == JavaFileType.INSTANCE + override fun exports(packageFqName: FqName): Boolean { return moduleInfo.exports.any { (fqName, toModules) -> fqName == packageFqName && toModules.isEmpty() @@ -100,3 +106,5 @@ interface JavaModule { override fun toString(): String = name } } + +const val KOTLIN_STDLIB_MODULE_NAME = "kotlin.stdlib" \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalyzerFacade.kt b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalyzerFacade.kt index c3c58e723a9..59de04c2c84 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalyzerFacade.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/AnalyzerFacade.kt @@ -118,7 +118,6 @@ class ResolverForProjectImpl( moduleDescriptor.setDependencies(LazyModuleDependencies( projectContext.storageManager, module, - modulePlatforms, firstDependency, this)) @@ -270,7 +269,6 @@ abstract class AnalyzerFacade { class LazyModuleDependencies( storageManager: StorageManager, private val module: M, - modulePlatforms: (M) -> MultiTargetPlatform?, firstDependency: M? = null, private val resolverForProject: ResolverForProjectImpl ) : ModuleDependencies { @@ -292,14 +290,6 @@ class LazyModuleDependencies( }.toList() } - private val implementingModules = storageManager.createLazyValue { - if (modulePlatforms(module) != MultiTargetPlatform.Common) emptySet() - else resolverForProject.modules - .filterTo(mutableSetOf()) { - modulePlatforms(it) != MultiTargetPlatform.Common && module in it.dependencies() - } - } - override val allDependencies: List get() = dependencies() override val modulesWhoseInternalsAreVisible: Set @@ -308,8 +298,6 @@ class LazyModuleDependencies( resolverForProject.descriptorForModule(it as M) } - override val allImplementingModules: Set - get() = implementingModules().mapTo(mutableSetOf()) { resolverForProject.descriptorForModule(it) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInfo.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInfo.kt index b894cf2dfb8..7e129c3e3a4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInfo.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInfo.kt @@ -22,10 +22,10 @@ import org.jetbrains.kotlin.descriptors.VariableDescriptor typealias ImmutableMap = javaslang.collection.Map typealias ImmutableHashMap = javaslang.collection.HashMap -abstract class ControlFlowInfo, D> +abstract class ControlFlowInfo, D : Any> internal constructor( protected val map: ImmutableMap = ImmutableHashMap.empty() -) : ImmutableMap by map { +) : ImmutableMap by map, ReadOnlyControlFlowInfo { abstract protected fun copy(newMap: ImmutableMap): S override fun put(key: VariableDescriptor, value: D): S = put(key, value, this[key].getOrElse(null as D?)) @@ -41,6 +41,9 @@ internal constructor( return copy(map.put(key, value)) } + override fun getOrNull(variableDescriptor: VariableDescriptor): D? = this[variableDescriptor].getOrElse(null as D?) + override fun asMap() = this + fun retainAll(predicate: (VariableDescriptor) -> Boolean): S = copy(map.removeAll(map.keySet().filterNot(predicate))) override fun equals(other: Any?) = map == (other as? ControlFlowInfo<*, *>)?.map @@ -53,16 +56,26 @@ internal constructor( operator fun Tuple2.component1(): T = _1() operator fun Tuple2<*, T>.component2(): T = _2() -fun ImmutableMap.getOrNull(k: K): V? = this[k].getOrElse(null as V?) +interface ReadOnlyControlFlowInfo { + fun getOrNull(variableDescriptor: VariableDescriptor): D? + // Only used in tests + fun asMap(): ImmutableMap +} + +interface ReadOnlyInitControlFlowInfo : ReadOnlyControlFlowInfo { + fun checkDefiniteInitializationInWhen(merge: ReadOnlyInitControlFlowInfo): Boolean +} + +typealias ReadOnlyUseControlFlowInfo = ReadOnlyControlFlowInfo class InitControlFlowInfo(map: ImmutableMap = ImmutableHashMap.empty()) : - ControlFlowInfo(map) { + ControlFlowInfo(map), ReadOnlyInitControlFlowInfo { override fun copy(newMap: ImmutableMap) = InitControlFlowInfo(newMap) // this = output of EXHAUSTIVE_WHEN_ELSE instruction // merge = input of MergeInstruction // returns true if definite initialization in when happens here - fun checkDefiniteInitializationInWhen(merge: InitControlFlowInfo): Boolean { + override fun checkDefiniteInitializationInWhen(merge: ReadOnlyInitControlFlowInfo): Boolean { for ((key, value) in iterator()) { if (value.initState == InitState.INITIALIZED_EXHAUSTIVELY && merge.getOrNull(key)?.initState == InitState.INITIALIZED) { @@ -74,7 +87,7 @@ class InitControlFlowInfo(map: ImmutableMap = ImmutableHashMap.empty()) : - ControlFlowInfo(map) { + ControlFlowInfo(map), ReadOnlyUseControlFlowInfo { override fun copy(newMap: ImmutableMap) = UseControlFlowInfo(newMap) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt index 43c0516c842..94af80a4eb0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt @@ -274,8 +274,8 @@ class ControlFlowInformationProvider private constructor( pseudocode.traverse(TraversalOrder.FORWARD, initializers) { instruction: Instruction, - enterData: ImmutableMap, - exitData: ImmutableMap -> + enterData: ReadOnlyInitControlFlowInfo, + exitData: ReadOnlyInitControlFlowInfo -> val ctxt = VariableInitContext(instruction, reportedDiagnosticMap, enterData, exitData, blockScopeVariableInfo) if (ctxt.variableDescriptor == null) return@traverse @@ -486,18 +486,21 @@ class ControlFlowInformationProvider private constructor( } private fun checkAssignmentBeforeDeclaration(ctxt: VariableInitContext, expression: KtExpression) = - if (ctxt.enterInitState?.isDeclared == true - || ctxt.exitInitState?.isDeclared == true - || ctxt.enterInitState?.mayBeInitialized() == true - || ctxt.exitInitState?.mayBeInitialized() != true) { - false - } - else { + if (ctxt.isInitializationBeforeDeclaration()) { if (ctxt.variableDescriptor != null) { report(Errors.INITIALIZATION_BEFORE_DECLARATION.on(expression, ctxt.variableDescriptor), ctxt) } true } + else { + false + } + + private fun VariableInitContext.isInitializationBeforeDeclaration(): Boolean = + // is not declared + enterInitState?.isDeclared != true && exitInitState?.isDeclared != true && + // wasn't initialized before current instruction + enterInitState?.mayBeInitialized() != true private fun checkInitializationForCustomSetter(ctxt: VariableInitContext, expression: KtExpression): Boolean { val variableDescriptor = ctxt.variableDescriptor @@ -532,7 +535,7 @@ class ControlFlowInformationProvider private constructor( private fun recordInitializedVariables( pseudocode: Pseudocode, - initializersMap: Map> + initializersMap: Map> ) { val initializers = initializersMap[pseudocode.exitInstruction] ?: return val declaredVariables = pseudocodeVariablesData.getDeclaredVariables(pseudocode, false) @@ -554,8 +557,8 @@ class ControlFlowInformationProvider private constructor( val usedValueExpressions = hashSetOf() pseudocode.traverse(TraversalOrder.BACKWARD, variableStatusData) { instruction: Instruction, - enterData: ImmutableMap, - _: ImmutableMap -> + enterData: ReadOnlyUseControlFlowInfo, + _: ReadOnlyUseControlFlowInfo -> val ctxt = VariableUseContext(instruction, reportedDiagnosticMap) val declaredVariables = pseudocodeVariablesData.getDeclaredVariables(instruction.owner, false) @@ -1030,8 +1033,8 @@ class ControlFlowInformationProvider private constructor( private inner class VariableInitContext( instruction: Instruction, map: MutableMap>, - `in`: ImmutableMap, - out: ImmutableMap, + `in`: ReadOnlyInitControlFlowInfo, + out: ReadOnlyInitControlFlowInfo, blockScopeVariableInfo: BlockScopeVariableInfo ) : VariableContext(instruction, map) { internal val enterInitState = initialize(variableDescriptor, blockScopeVariableInfo, `in`) @@ -1040,7 +1043,7 @@ class ControlFlowInformationProvider private constructor( private fun initialize( variableDescriptor: VariableDescriptor?, blockScopeVariableInfo: BlockScopeVariableInfo, - map: ImmutableMap + map: ReadOnlyInitControlFlowInfo ): VariableControlFlowState? { val state = map.getOrNull(variableDescriptor ?: return null) if (state != null) return state diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeVariablesData.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeVariablesData.kt index 03765764cfa..50c804c5f09 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeVariablesData.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/PseudocodeVariablesData.kt @@ -26,67 +26,128 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.WriteValueInstructi import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.VariableDeclarationInstruction import org.jetbrains.kotlin.cfg.pseudocodeTraverser.Edges import org.jetbrains.kotlin.cfg.pseudocodeTraverser.TraversalOrder +import org.jetbrains.kotlin.cfg.pseudocodeTraverser.traverse +import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.VariableDescriptor -import org.jetbrains.kotlin.psi.KtProperty +import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.BindingContextUtils.variableDescriptorForDeclaration -import java.util.* +import org.jetbrains.kotlin.utils.addToStdlib.safeAs + +private typealias ImmutableSet = javaslang.collection.Set +private typealias ImmutableHashSet = javaslang.collection.HashSet class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingContext: BindingContext) { + private val containsDoWhile = pseudocode.rootPseudocode.containsDoWhile private val pseudocodeVariableDataCollector = PseudocodeVariableDataCollector(bindingContext, pseudocode) - private val declaredVariablesForDeclaration = hashMapOf>() + private class VariablesForDeclaration( + val valsWithTrivialInitializer: Set, + val nonTrivialVariables: Set + ) { + val allVars = + if (nonTrivialVariables.isEmpty()) + valsWithTrivialInitializer + else + LinkedHashSet(valsWithTrivialInitializer).also { it.addAll(nonTrivialVariables) } + } - val variableInitializers: Map> by lazy { + private val declaredVariablesForDeclaration = hashMapOf() + private val rootVariables by lazy(LazyThreadSafetyMode.NONE) { + getAllDeclaredVariables(pseudocode, includeInsideLocalDeclarations = true) + } + + val variableInitializers: Map> by lazy { computeVariableInitializers() } val blockScopeVariableInfo: BlockScopeVariableInfo get() = pseudocodeVariableDataCollector.blockScopeVariableInfo - fun getDeclaredVariables(pseudocode: Pseudocode, includeInsideLocalDeclarations: Boolean): Set { + fun getDeclaredVariables(pseudocode: Pseudocode, includeInsideLocalDeclarations: Boolean): Set = + getAllDeclaredVariables(pseudocode, includeInsideLocalDeclarations).allVars + + fun isVariableWithTrivialInitializer(variableDescriptor: VariableDescriptor) = + variableDescriptor in rootVariables.valsWithTrivialInitializer + + private fun getAllDeclaredVariables(pseudocode: Pseudocode, includeInsideLocalDeclarations: Boolean): VariablesForDeclaration { if (!includeInsideLocalDeclarations) { return getUpperLevelDeclaredVariables(pseudocode) } - val declaredVariables = linkedSetOf() - declaredVariables.addAll(getUpperLevelDeclaredVariables(pseudocode)) + val nonTrivialVariables = linkedSetOf() + val valsWithTrivialInitializer = linkedSetOf() + addVariablesFromPseudocode(pseudocode, nonTrivialVariables, valsWithTrivialInitializer) for (localFunctionDeclarationInstruction in pseudocode.localDeclarations) { val localPseudocode = localFunctionDeclarationInstruction.body - declaredVariables.addAll(getUpperLevelDeclaredVariables(localPseudocode)) + addVariablesFromPseudocode(localPseudocode, nonTrivialVariables, valsWithTrivialInitializer) } - return declaredVariables + return VariablesForDeclaration(valsWithTrivialInitializer, nonTrivialVariables) } - private fun getUpperLevelDeclaredVariables(pseudocode: Pseudocode): Set { - var declaredVariables = declaredVariablesForDeclaration[pseudocode] - if (declaredVariables == null) { - declaredVariables = computeDeclaredVariablesForPseudocode(pseudocode) - declaredVariablesForDeclaration.put(pseudocode, declaredVariables) + private fun addVariablesFromPseudocode( + pseudocode: Pseudocode, + nonTrivialVariables: MutableSet, + valsWithTrivialInitializer: MutableSet + ) { + getUpperLevelDeclaredVariables(pseudocode).let { + nonTrivialVariables.addAll(it.nonTrivialVariables) + valsWithTrivialInitializer.addAll(it.valsWithTrivialInitializer) } - return declaredVariables } - private fun computeDeclaredVariablesForPseudocode(pseudocode: Pseudocode): Set { - val declaredVariables = linkedSetOf() + private fun getUpperLevelDeclaredVariables(pseudocode: Pseudocode) = declaredVariablesForDeclaration.getOrPut(pseudocode) { + computeDeclaredVariablesForPseudocode(pseudocode) + } + + private fun computeDeclaredVariablesForPseudocode(pseudocode: Pseudocode): VariablesForDeclaration { + val valsWithTrivialInitializer = linkedSetOf() + val nonTrivialVariables = linkedSetOf() for (instruction in pseudocode.instructions) { if (instruction is VariableDeclarationInstruction) { val variableDeclarationElement = instruction.variableDeclarationElement - val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, variableDeclarationElement) - variableDescriptorForDeclaration(descriptor)?.let { - declaredVariables.add(it) + val descriptor = + variableDescriptorForDeclaration( + bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, variableDeclarationElement) + ) ?: continue + + if (!containsDoWhile && isValWithTrivialInitializer(variableDeclarationElement, descriptor)) { + valsWithTrivialInitializer.add(descriptor) + } + else { + nonTrivialVariables.add(descriptor) } } } - return Collections.unmodifiableSet(declaredVariables) + + return VariablesForDeclaration(valsWithTrivialInitializer, nonTrivialVariables) + } + + private fun isValWithTrivialInitializer(variableDeclarationElement: KtDeclaration, descriptor: VariableDescriptor) = + variableDeclarationElement is KtParameter || variableDeclarationElement is KtObjectDeclaration || + variableDeclarationElement.safeAs()?.isVariableWithTrivialInitializer(descriptor) == true + + private fun KtVariableDeclaration.isVariableWithTrivialInitializer(descriptor: VariableDescriptor): Boolean { + if (descriptor.isPropertyWithoutBackingField()) return true + if (isVar) return false + return initializer != null || safeAs()?.delegate != null || this is KtDestructuringDeclarationEntry + } + + private fun VariableDescriptor.isPropertyWithoutBackingField(): Boolean { + if (this !is PropertyDescriptor) return false + return bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, this) != true } // variable initializers - private fun computeVariableInitializers(): Map> { + private fun computeVariableInitializers(): Map> { val blockScopeVariableInfo = pseudocodeVariableDataCollector.blockScopeVariableInfo + val resultForValsWithTrivialInitializer = computeInitInfoForTrivialVals() + + if (rootVariables.nonTrivialVariables.isEmpty()) return resultForValsWithTrivialInitializer + return pseudocodeVariableDataCollector.collectData(TraversalOrder.FORWARD, InitControlFlowInfo()) { instruction: Instruction, incomingEdgesData: Collection -> @@ -94,6 +155,88 @@ class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingCon val exitInstructionData = addVariableInitStateFromCurrentInstructionIfAny( instruction, enterInstructionData, blockScopeVariableInfo) Edges(enterInstructionData, exitInstructionData) + }.mapValues { + (instruction, edges) -> + val trivialEdges = resultForValsWithTrivialInitializer[instruction]!! + Edges(trivialEdges.incoming.replaceDelegate(edges.incoming), trivialEdges.outgoing.replaceDelegate(edges.outgoing)) + } + } + + private fun computeInitInfoForTrivialVals(): Map> { + val result = hashMapOf>() + var declaredSet = ImmutableHashSet.empty() + var initSet = ImmutableHashSet.empty() + pseudocode.traverse(TraversalOrder.FORWARD) { instruction -> + val enterState = ReadOnlyInitControlFlowInfoImpl(declaredSet, initSet, null) + when (instruction) { + is VariableDeclarationInstruction -> + extractValWithTrivialInitializer(instruction)?.let { + variableDescriptor -> + declaredSet = declaredSet.add(variableDescriptor) + } + is WriteValueInstruction -> { + val variableDescriptor = extractValWithTrivialInitializer(instruction) + if (variableDescriptor != null && instruction.isTrivialInitializer()) { + initSet = initSet.add(variableDescriptor) + } + } + } + + val afterState = ReadOnlyInitControlFlowInfoImpl(declaredSet, initSet, null) + + result[instruction] = Edges(enterState, afterState) + } + return result + } + + private fun WriteValueInstruction.isTrivialInitializer() = + element is KtVariableDeclaration || element is KtParameter + + private inner class ReadOnlyInitControlFlowInfoImpl( + val declaredSet: ImmutableSet, + val initSet: ImmutableSet, + private val delegate: ReadOnlyInitControlFlowInfo? + ) : ReadOnlyInitControlFlowInfo { + override fun getOrNull(variableDescriptor: VariableDescriptor): VariableControlFlowState? { + if (variableDescriptor in declaredSet) { + return VariableControlFlowState.create(isInitialized = variableDescriptor in initSet, isDeclared = true) + } + return delegate?.getOrNull(variableDescriptor) + } + + override fun checkDefiniteInitializationInWhen(merge: ReadOnlyInitControlFlowInfo): Boolean = + delegate?.checkDefiniteInitializationInWhen(merge) ?: false + + fun replaceDelegate(newDelegate: ReadOnlyInitControlFlowInfo): ReadOnlyInitControlFlowInfo = + ReadOnlyInitControlFlowInfoImpl(declaredSet, initSet, newDelegate) + + override fun asMap(): ImmutableMap { + val initial = delegate?.asMap() ?: ImmutableHashMap.empty() + + return declaredSet.fold(initial) { + acc, variableDescriptor -> + acc.put(variableDescriptor, getOrNull(variableDescriptor)!!) + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as ReadOnlyInitControlFlowInfoImpl + + if (declaredSet != other.declaredSet) return false + if (initSet != other.initSet) return false + if (delegate != other.delegate) return false + + return true + } + + override fun hashCode(): Int { + var result = declaredSet.hashCode() + result = 31 * result + initSet.hashCode() + result = 31 * result + (delegate?.hashCode() ?: 0) + return result } } @@ -115,7 +258,10 @@ class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingCon if (instruction !is WriteValueInstruction && instruction !is VariableDeclarationInstruction) { return enterInstructionData } - val variable = PseudocodeUtil.extractVariableDescriptorIfAny(instruction, bindingContext) ?: return enterInstructionData + val variable = + PseudocodeUtil.extractVariableDescriptorIfAny(instruction, bindingContext) + ?.takeIf { it in rootVariables.nonTrivialVariables } + ?: return enterInstructionData var exitInstructionData = enterInstructionData if (instruction is WriteValueInstruction) { // if writing to already initialized object @@ -129,10 +275,10 @@ class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingCon } else { // instruction instanceof VariableDeclarationInstruction - var enterInitState: VariableControlFlowState? = enterInstructionData.getOrNull(variable) - if (enterInitState == null) { - enterInitState = getDefaultValueForInitializers(variable, instruction, blockScopeVariableInfo) - } + val enterInitState = + enterInstructionData.getOrNull(variable) + ?: getDefaultValueForInitializers(variable, instruction, blockScopeVariableInfo) + if (!enterInitState.mayBeInitialized() || !enterInitState.isDeclared) { val variableDeclarationInfo = VariableControlFlowState.create(enterInitState.initState, isDeclared = true) exitInstructionData = exitInstructionData.put(variable, variableDeclarationInfo, enterInitState) @@ -143,46 +289,128 @@ class PseudocodeVariablesData(val pseudocode: Pseudocode, private val bindingCon // variable use - val variableUseStatusData: Map> - get() = pseudocodeVariableDataCollector.collectData(TraversalOrder.BACKWARD, UseControlFlowInfo()) { - instruction: Instruction, incomingEdgesData: Collection -> + val variableUseStatusData: Map> + get() { + val resultForTrivialVals = computeUseInfoForTrivialVals() + if (rootVariables.nonTrivialVariables.isEmpty()) return resultForTrivialVals - val enterResult: UseControlFlowInfo = if (incomingEdgesData.size == 1) { - incomingEdgesData.single() - } - else { - incomingEdgesData.fold(UseControlFlowInfo()) { result, edgeData -> - edgeData.iterator().fold(result) { subResult, (variableDescriptor, variableUseState) -> - subResult.put(variableDescriptor, variableUseState.merge(subResult.getOrNull(variableDescriptor))) + return pseudocodeVariableDataCollector.collectData(TraversalOrder.BACKWARD, UseControlFlowInfo()) { instruction: Instruction, incomingEdgesData: Collection -> + + val enterResult: UseControlFlowInfo = if (incomingEdgesData.size == 1) { + incomingEdgesData.single() + } + else { + incomingEdgesData.fold(UseControlFlowInfo()) { result, edgeData -> + edgeData.iterator().fold(result) { subResult, (variableDescriptor, variableUseState) -> + subResult.put(variableDescriptor, variableUseState.merge(subResult.getOrNull(variableDescriptor))) + } } } - } - val variableDescriptor = PseudocodeUtil.extractVariableDescriptorFromReference(instruction, bindingContext) - if (variableDescriptor == null || instruction !is ReadValueInstruction && instruction !is WriteValueInstruction) { - Edges(enterResult, enterResult) - } - else { - val exitResult = - if (instruction is ReadValueInstruction) { - enterResult.put(variableDescriptor, VariableUseState.READ) - } - else { - var variableUseState: VariableUseState? = enterResult.getOrNull(variableDescriptor) - if (variableUseState == null) { - variableUseState = VariableUseState.UNUSED - } - when (variableUseState) { - VariableUseState.UNUSED, VariableUseState.ONLY_WRITTEN_NEVER_READ -> - enterResult.put(variableDescriptor, VariableUseState.ONLY_WRITTEN_NEVER_READ) - VariableUseState.WRITTEN_AFTER_READ, VariableUseState.READ -> - enterResult.put(variableDescriptor, VariableUseState.WRITTEN_AFTER_READ) - } - } - Edges(enterResult, exitResult) + val variableDescriptor = + PseudocodeUtil.extractVariableDescriptorFromReference(instruction, bindingContext) + ?.takeIf { it in rootVariables.nonTrivialVariables } + if (variableDescriptor == null || instruction !is ReadValueInstruction && instruction !is WriteValueInstruction) { + Edges(enterResult, enterResult) + } + else { + val exitResult = + if (instruction is ReadValueInstruction) { + enterResult.put(variableDescriptor, VariableUseState.READ) + } + else { + var variableUseState: VariableUseState? = enterResult.getOrNull(variableDescriptor) + if (variableUseState == null) { + variableUseState = VariableUseState.UNUSED + } + when (variableUseState) { + VariableUseState.UNUSED, VariableUseState.ONLY_WRITTEN_NEVER_READ -> + enterResult.put(variableDescriptor, VariableUseState.ONLY_WRITTEN_NEVER_READ) + VariableUseState.WRITTEN_AFTER_READ, VariableUseState.READ -> + enterResult.put(variableDescriptor, VariableUseState.WRITTEN_AFTER_READ) + } + } + Edges(enterResult, exitResult) + } + }.mapValues { + (instruction, edges) -> + val edgeForTrivialVals = resultForTrivialVals[instruction]!! + + Edges( + edgeForTrivialVals.incoming.replaceDelegate(edges.incoming), + edgeForTrivialVals.outgoing.replaceDelegate(edges.outgoing) + ) } } + private fun computeUseInfoForTrivialVals(): Map> { + val used = hashSetOf() + + pseudocode.traverse(TraversalOrder.FORWARD) { instruction -> + if (instruction is ReadValueInstruction) { + extractValWithTrivialInitializer(instruction)?.let { + used.add(it) + } + } + } + + val constantUseInfo = ReadOnlyUseControlFlowInfoImpl(used, null) + val constantEdges = Edges(constantUseInfo, constantUseInfo) + val result = hashMapOf>() + + pseudocode.traverse(TraversalOrder.FORWARD) { instruction -> + result[instruction] = constantEdges + } + return result + } + + private fun extractValWithTrivialInitializer(instruction: Instruction): VariableDescriptor? { + return PseudocodeUtil.extractVariableDescriptorIfAny(instruction, bindingContext)?.takeIf { + it in rootVariables.valsWithTrivialInitializer + } + } + + private inner class ReadOnlyUseControlFlowInfoImpl( + val used: Set, + val delegate: ReadOnlyUseControlFlowInfo? + ) : ReadOnlyUseControlFlowInfo { + override fun getOrNull(variableDescriptor: VariableDescriptor): VariableUseState? { + if (variableDescriptor in used) return VariableUseState.READ + return delegate?.getOrNull(variableDescriptor) + } + + fun replaceDelegate(newDelegate: ReadOnlyUseControlFlowInfo): ReadOnlyUseControlFlowInfo = + ReadOnlyUseControlFlowInfoImpl(used, newDelegate) + + override fun asMap(): ImmutableMap { + val initial = delegate?.asMap() ?: ImmutableHashMap.empty() + + return used.fold(initial) { + acc, variableDescriptor -> + acc.put(variableDescriptor, getOrNull(variableDescriptor)!!) + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as ReadOnlyUseControlFlowInfoImpl + + if (used != other.used) return false + if (delegate != other.delegate) return false + + return true + } + + override fun hashCode(): Int { + var result = used.hashCode() + result = 31 * result + (delegate?.hashCode() ?: 0) + return result + } + + } + companion object { @JvmStatic diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/ControlFlowInstructionsGenerator.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/ControlFlowInstructionsGenerator.kt index e86c81cc3a8..487edc5d865 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/ControlFlowInstructionsGenerator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/ControlFlowInstructionsGenerator.kt @@ -19,8 +19,8 @@ package org.jetbrains.kotlin.cfg.pseudocode import com.intellij.util.containers.Stack import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.cfg.* -import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction import org.jetbrains.kotlin.cfg.pseudocode.instructions.BlockScope +import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.* import org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps.* import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.* @@ -29,7 +29,6 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue - import java.util.* class ControlFlowInstructionsGenerator : ControlFlowBuilderAdapter() { @@ -113,6 +112,10 @@ class ControlFlowInstructionsGenerator : ControlFlowBuilderAdapter() { override fun createUnboundLabel(name: String): Label = pseudocode.createLabel("L" + labelCount++, name) override fun enterLoop(expression: KtLoopExpression): LoopInfo { + if (expression is KtDoWhileExpression) { + (pseudocode.rootPseudocode as PseudocodeImpl).containsDoWhile = true + } + val info = LoopInfo( expression, createUnboundLabel("loop entry point"), diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/Pseudocode.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/Pseudocode.kt index b387e2360d6..7ab4903baf6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/Pseudocode.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/Pseudocode.kt @@ -45,6 +45,9 @@ interface Pseudocode { val enterInstruction: SubroutineEnterInstruction + val containsDoWhile: Boolean + val rootPseudocode: Pseudocode + fun getElementValue(element: KtElement?): PseudoValue? fun getValueElements(value: PseudoValue?): List diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeImpl.kt index f3b53f2fde1..cb7972476cf 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeImpl.kt @@ -77,6 +77,9 @@ class PseudocodeImpl(override val correspondingElement: KtElement) : Pseudocode private var postPrecessed = false + override var containsDoWhile: Boolean = false + internal set + private fun getLocalDeclarations(pseudocode: Pseudocode): Set { val localDeclarations = linkedSetOf() for (instruction in (pseudocode as PseudocodeImpl).mutableInstructionList) { @@ -88,7 +91,7 @@ class PseudocodeImpl(override val correspondingElement: KtElement) : Pseudocode return localDeclarations } - val rootPseudocode: Pseudocode + override val rootPseudocode: Pseudocode get() { var parent = parent while (parent != null) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index a00a3080871..93fdebaa290 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -562,6 +562,9 @@ public interface Errors { DiagnosticFactory0> EXPECTED_ENUM_CONSTRUCTOR = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 EXPECTED_ENUM_ENTRY_WITH_BODY = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 EXPECTED_PROPERTY_INITIALIZER = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 EXPECTED_DELEGATED_PROPERTY = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 EXPECTED_LATEINIT_PROPERTY = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 SUPERTYPE_INITIALIZED_IN_EXPECTED_CLASS = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 ACTUAL_TYPE_ALIAS_NOT_TO_CLASS = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0 @@ -622,7 +625,8 @@ public interface Errors { DiagnosticFactory1 MISSING_RECEIVER = DiagnosticFactory1.create(ERROR); DiagnosticFactory0 NO_RECEIVER_ALLOWED = DiagnosticFactory0.create(ERROR); - DiagnosticFactory0 ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM = DiagnosticFactory0.create(WARNING); + DiagnosticFactory1 ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION = DiagnosticFactory1.create(WARNING); + DiagnosticFactory0 ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION = DiagnosticFactory0.create(WARNING); // Call resolution diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 8895bd3b90b..3b82f8970ca 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -270,13 +270,16 @@ public class DefaultErrorMessages { MAP.put(EXPECTED_ENUM_CONSTRUCTOR, "Expected enum class cannot have a constructor"); MAP.put(EXPECTED_ENUM_ENTRY_WITH_BODY, "Expected enum entry cannot have a body"); MAP.put(EXPECTED_PROPERTY_INITIALIZER, "Expected property cannot have an initializer"); + MAP.put(EXPECTED_DELEGATED_PROPERTY, "Expected property cannot be delegated"); + MAP.put(EXPECTED_LATEINIT_PROPERTY, "Expected property cannot be lateinit"); + MAP.put(SUPERTYPE_INITIALIZED_IN_EXPECTED_CLASS, "Expected classes cannot initialize supertypes"); MAP.put(ACTUAL_TYPE_ALIAS_NOT_TO_CLASS, "Right-hand side of actual type alias should be a class, not another type alias"); MAP.put(ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE, "Aliased class should not have type parameters with declaration-site variance"); MAP.put(ACTUAL_TYPE_ALIAS_WITH_USE_SITE_VARIANCE, "Right-hand side of actual type alias cannot contain use-site variance or star projections"); MAP.put(ACTUAL_TYPE_ALIAS_WITH_COMPLEX_SUBSTITUTION, "Type arguments in the right-hand side of actual type alias should be its type parameters in the same order, e.g. 'actual typealias Foo = Bar'"); - MAP.put(NO_ACTUAL_FOR_EXPECT, "Expected {0} has no actual in module{1}{2}", DECLARATION_NAME_WITH_KIND, + MAP.put(NO_ACTUAL_FOR_EXPECT, "Expected {0} has no actual declaration in module{1}{2}", DECLARATION_NAME_WITH_KIND, PLATFORM, PlatformIncompatibilityDiagnosticRenderer.TEXT); MAP.put(ACTUAL_WITHOUT_EXPECT, "Actual {0} has no corresponding expected declaration{1}", DECLARATION_NAME_WITH_KIND, PlatformIncompatibilityDiagnosticRenderer.TEXT); @@ -553,8 +556,8 @@ public class DefaultErrorMessages { MAP.put(MANY_CLASSES_IN_SUPERTYPE_LIST, "Only one class may appear in a supertype list"); MAP.put(SUPERTYPE_NOT_A_CLASS_OR_INTERFACE, "Only classes and interfaces may serve as supertypes"); MAP.put(SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE, "Extension function type is not allowed as supertypes"); - MAP.put(SUPERTYPE_IS_SUSPEND_FUNCTION_TYPE, "Suspend function type is not allowed as supertypes"); MAP.put(SUPERTYPE_INITIALIZED_IN_INTERFACE, "Interfaces cannot initialize supertypes"); + MAP.put(SUPERTYPE_IS_SUSPEND_FUNCTION_TYPE, "Suspend function type is not allowed as supertypes"); MAP.put(CLASS_IN_SUPERTYPE_FOR_ENUM, "Enum class cannot inherit from classes"); MAP.put(CONSTRUCTOR_IN_INTERFACE, "An interface may not have a constructor"); MAP.put(METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE, "An interface may not implement a method of 'Any'"); @@ -757,7 +760,8 @@ public class DefaultErrorMessages { MAP.put(NO_VALUE_FOR_PARAMETER, "No value passed for parameter ''{0}''", NAME); MAP.put(MISSING_RECEIVER, "A receiver of type {0} is required", RENDER_TYPE); MAP.put(NO_RECEIVER_ALLOWED, "No receiver can be passed to this function or property"); - MAP.put(ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM, "Assigning single elements to varargs in named form is deprecated"); + MAP.put(ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION, "Assigning single elements to varargs in named form is deprecated", TO_STRING); + MAP.put(ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION, "Assigning single elements to varargs in named form is deprecated"); MAP.put(CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS, "Cannot create an instance of an abstract class"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/PlatformIncompatibilityDiagnosticRenderer.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/PlatformIncompatibilityDiagnosticRenderer.kt index 3cf85f8c352..76f4f9fa43a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/PlatformIncompatibilityDiagnosticRenderer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/PlatformIncompatibilityDiagnosticRenderer.kt @@ -101,7 +101,7 @@ private fun StringBuilder.renderIncompatibilityInformation( if (incompatibility is Incompatible.ClassScopes) { append(indent) - append("No actuals are found for expected members listed below:") + append("No actual members are found for expected members listed below:") mode.newLine(this) renderIncompatibleClassScopes(incompatibility.unfulfilled, indent, context, mode) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtFile.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtFile.kt index bada78df856..d8c6271c43d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtFile.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtFile.kt @@ -76,8 +76,18 @@ open class KtFile(viewProvider: FileViewProvider, val isCompiled: Boolean) : return if (ast != null) ast.psi as KtPackageDirective else null } - val packageFqName: FqName + var packageFqName: FqName get() = stub?.getPackageFqName() ?: packageFqNameByTree + set(value) { + val packageDirective = packageDirective + if (packageDirective != null) { + packageDirective.fqName = value + } + else { + val newPackageDirective = KtPsiFactory(this).createPackageDirectiveIfNeeded(value) ?: return + addAfter(newPackageDirective, null) + } + } val packageFqNameByTree: FqName get() = packageDirectiveByTree?.fqName ?: FqName.ROOT diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtNamedDeclarationNotStubbed.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtNamedDeclarationNotStubbed.java index eeec6006d0e..78653833884 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtNamedDeclarationNotStubbed.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtNamedDeclarationNotStubbed.java @@ -64,7 +64,10 @@ abstract class KtNamedDeclarationNotStubbed extends KtDeclarationImpl implements @Override public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { - return getNameIdentifier().replace(KtPsiFactory(this).createNameIdentifier(name)); + PsiElement identifier = getNameIdentifier(); + if (identifier == null) throw new IncorrectOperationException(); + + return identifier.replace(KtPsiFactory(this).createNameIdentifier(name)); } @Override diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java index 3409f30fc41..d04a00447b5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java @@ -530,11 +530,19 @@ public class KtPsiUtil { return false; } - // '(x operator y)' case - if (innerExpression instanceof KtBinaryExpression && - innerOperation != KtTokens.ELVIS && - isKeepBinaryExpressionParenthesized((KtBinaryExpression) innerExpression)) { - return true; + if (innerExpression instanceof KtBinaryExpression) { + // '(x operator return [...]) operator ...' case + if (parentElement instanceof KtBinaryExpression) { + KtBinaryExpression innerBinary = (KtBinaryExpression) innerExpression; + if (innerBinary.getRight() instanceof KtReturnExpression) { + return true; + } + } + // '(x operator y)' case + if (innerOperation != KtTokens.ELVIS && + isKeepBinaryExpressionParenthesized((KtBinaryExpression) innerExpression)) { + return true; + } } int innerPriority = getPriority(innerExpression); @@ -846,7 +854,7 @@ public class KtPsiUtil { return (KtElement) current; } } - if (current instanceof KtDelegatedSuperTypeEntry) { + if (current instanceof KtDelegatedSuperTypeEntry || current instanceof KtSuperTypeCallEntry) { PsiElement grandParent = current.getParent().getParent(); if (grandParent instanceof KtClassOrObject && !(grandParent.getParent() instanceof KtObjectLiteralExpression)) { return (KtElement) grandParent; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt index ed8ac919e10..104e8a5e9a2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt @@ -460,7 +460,7 @@ fun KtExpression.getOutermostParenthesizerOrThis(): KtExpression { fun PsiElement.isFunctionalExpression(): Boolean = this is KtNamedFunction && nameIdentifier == null -private val BAD_NEIGHBOUR_FOR_SIMPLE_TEMPLATE_ENTRY_PATTERN = Regex("[a-zA-Z0-9_].*") +private val BAD_NEIGHBOUR_FOR_SIMPLE_TEMPLATE_ENTRY_PATTERN = Regex("([a-zA-Z0-9_]|[^\\p{ASCII}]).*") fun canPlaceAfterSimpleNameEntry(element: PsiElement?): Boolean { val entryText = element?.text ?: return true diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt index a567600436d..b1383c458dd 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt @@ -131,6 +131,7 @@ class SyntheticClassOrObjectDescriptor( override fun getDestructuringDeclarationsEntries(name: Name): Collection = emptyList() override fun getClassOrObjectDeclarations(name: Name): Collection = emptyList() override fun getTypeAliasDeclarations(name: Name): Collection = emptyList() + override fun getDeclarationNames() = emptySet() } internal inner class SyntheticDeclaration( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportScope.kt index 8caf263706a..35aa948ec9c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportScope.kt @@ -22,15 +22,17 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.scopes.BaseImportingScope import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter -import org.jetbrains.kotlin.resolve.scopes.ResolutionScope +import org.jetbrains.kotlin.resolve.scopes.MemberScope +import org.jetbrains.kotlin.resolve.scopes.computeAllNames import org.jetbrains.kotlin.utils.Printer +import org.jetbrains.kotlin.utils.addToStdlib.flatMapToNullable class AllUnderImportScope( descriptor: DeclarationDescriptor, excludedImportNames: Collection ) : BaseImportingScope(null) { - private val scopes: List = if (descriptor is ClassDescriptor) { + private val scopes: List = if (descriptor is ClassDescriptor) { listOf(descriptor.staticScope, descriptor.unsubstitutedInnerClassesScope) } else { @@ -49,6 +51,8 @@ class AllUnderImportScope( excludedImportNames.mapNotNull { if (it.parent() == fqName) it.shortName() else null }.toSet() } + override fun computeImportedNames(): Set? = scopes.flatMapToNullable(hashSetOf(), MemberScope::computeAllNames) + override fun getContributedDescriptors( kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean, @@ -82,6 +86,10 @@ class AllUnderImportScope( return scopes.flatMap { it.getContributedFunctions(name, location) } } + override fun recordLookup(name: Name, location: LookupLocation) { + scopes.forEach { it.recordLookup(name, location) } + } + override fun printStructure(p: Printer) { p.println(this::class.java.simpleName) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java index 302c2e8c239..93696ab7927 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java @@ -316,6 +316,9 @@ public class BodyResolver { if (descriptor.getKind() == ClassKind.INTERFACE) { trace.report(SUPERTYPE_INITIALIZED_IN_INTERFACE.on(elementToMark)); } + if (descriptor.isExpect()) { + trace.report(SUPERTYPE_INITIALIZED_IN_EXPECTED_CLASS.on(elementToMark)); + } KtTypeReference typeReference = call.getTypeReference(); if (typeReference == null) return; if (primaryConstructor == null) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt index afd2ee357c1..a4319ae886b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt @@ -646,6 +646,9 @@ class DeclarationsChecker( if (inInterface) { trace.report(DELEGATED_PROPERTY_IN_INTERFACE.on(delegate)) } + else if (isExpect) { + trace.report(EXPECTED_DELEGATED_PROPERTY.on(delegate)) + } } else { val isUninitialized = trace.bindingContext.get(BindingContext.IS_UNINITIALIZED, propertyDescriptor) ?: false @@ -667,9 +670,14 @@ class DeclarationsChecker( else if (noExplicitTypeOrGetterType(property)) { trace.report(PROPERTY_WITH_NO_TYPE_NO_INITIALIZER.on(property)) } - if (backingFieldRequired && !inInterface && propertyDescriptor.isLateInit && !isUninitialized && - trace[MUST_BE_LATEINIT, propertyDescriptor] != true) { - trace.report(UNNECESSARY_LATEINIT.on(property)) + + if (propertyDescriptor.isLateInit) { + if (propertyDescriptor.isExpect) { + trace.report(EXPECTED_LATEINIT_PROPERTY.on(property.modifierList?.getModifier(KtTokens.LATEINIT_KEYWORD) ?: property)) + } + if (backingFieldRequired && !inInterface && !isUninitialized && trace[MUST_BE_LATEINIT, propertyDescriptor] != true) { + trace.report(UNNECESSARY_LATEINIT.on(property)) + } } } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyExplicitImportScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyExplicitImportScope.kt index 49cc59a5544..e2f62db0519 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyExplicitImportScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyExplicitImportScope.kt @@ -101,6 +101,8 @@ class LazyExplicitImportScope( return descriptors } + override fun computeImportedNames() = setOf(aliasName) + override fun printStructure(p: Printer) { p.println(this::class.java.simpleName, ": ", aliasName) } @@ -148,4 +150,4 @@ class LazyExplicitImportScope( private fun Collection.choseOnlyVisibleOrAll() = filter { isVisible(it, packageFragmentForVisibilityCheck, position = QualifierPosition.IMPORT) }. takeIf { it.isNotEmpty() } ?: this -} \ No newline at end of file +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt index 639d0f03018..da56c794b89 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt @@ -86,9 +86,9 @@ object ModifierCheckerCore { CONST_KEYWORD to EnumSet.of(MEMBER_PROPERTY, TOP_LEVEL_PROPERTY), OPERATOR_KEYWORD to EnumSet.of(FUNCTION), INFIX_KEYWORD to EnumSet.of(FUNCTION), - HEADER_KEYWORD to EnumSet.of(TOP_LEVEL_FUNCTION, TOP_LEVEL_PROPERTY_WITHOUT_FIELD_OR_DELEGATE, CLASS_ONLY, OBJECT, INTERFACE, ENUM_CLASS, ANNOTATION_CLASS), + HEADER_KEYWORD to EnumSet.of(TOP_LEVEL_FUNCTION, TOP_LEVEL_PROPERTY, CLASS_ONLY, OBJECT, INTERFACE, ENUM_CLASS, ANNOTATION_CLASS), IMPL_KEYWORD to EnumSet.of(TOP_LEVEL_FUNCTION, MEMBER_FUNCTION, TOP_LEVEL_PROPERTY, MEMBER_PROPERTY, CONSTRUCTOR, CLASS_ONLY, OBJECT, INTERFACE, ENUM_CLASS, ANNOTATION_CLASS, TYPEALIAS), - EXPECT_KEYWORD to EnumSet.of(TOP_LEVEL_FUNCTION, TOP_LEVEL_PROPERTY_WITHOUT_FIELD_OR_DELEGATE, CLASS_ONLY, OBJECT, INTERFACE, ENUM_CLASS, ANNOTATION_CLASS), + EXPECT_KEYWORD to EnumSet.of(TOP_LEVEL_FUNCTION, TOP_LEVEL_PROPERTY, CLASS_ONLY, OBJECT, INTERFACE, ENUM_CLASS, ANNOTATION_CLASS), ACTUAL_KEYWORD to EnumSet.of(TOP_LEVEL_FUNCTION, MEMBER_FUNCTION, TOP_LEVEL_PROPERTY, MEMBER_PROPERTY, CONSTRUCTOR, CLASS_ONLY, OBJECT, INTERFACE, ENUM_CLASS, ANNOTATION_CLASS, TYPEALIAS) ) @@ -191,9 +191,6 @@ object ModifierCheckerCore { // (see the KEEP https://github.com/Kotlin/KEEP/blob/master/proposals/sealed-class-inheritance.md) result += incompatibilityRegister(SEALED_KEYWORD, INNER_KEYWORD) - // lateinit is incompatible with header / expect - result += incompatibilityRegister(LATEINIT_KEYWORD, HEADER_KEYWORD, EXPECT_KEYWORD) - // header / expect / impl / actual are all incompatible result += incompatibilityRegister(HEADER_KEYWORD, EXPECT_KEYWORD, IMPL_KEYWORD, ACTUAL_KEYWORD) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/AssigningNamedArgumentToVarargChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/AssigningNamedArgumentToVarargChecker.kt index a42dfdcd479..5c71ff19f1f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/AssigningNamedArgumentToVarargChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/AssigningNamedArgumentToVarargChecker.kt @@ -53,7 +53,7 @@ class AssigningNamedArgumentToVarargChecker : CallChecker { checkAssignmentOfSingleElementInAnnotation(argument, argumentExpression, context) } else { - checkAssignmentOfSingleElementInFunction(argument, argumentExpression, context) + checkAssignmentOfSingleElementInFunction(argument, argumentExpression, context, parameterDescriptor) } } @@ -64,21 +64,22 @@ class AssigningNamedArgumentToVarargChecker : CallChecker { ) { if (isArrayOrArrayLiteral(argument, context)) { if (argument.hasSpread()) { - context.trace.report(Errors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM.on(argumentExpression)) + context.trace.report(Errors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION.on(argumentExpression)) } } else { - context.trace.report(Errors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM.on(argumentExpression)) + context.trace.report(Errors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION.on(argumentExpression)) } } private fun checkAssignmentOfSingleElementInFunction( argument: ValueArgument, argumentExpression: KtExpression, - context: ResolutionContext<*> + context: ResolutionContext<*>, + parameterDescriptor: ValueParameterDescriptor ) { if (!argument.hasSpread()) { - context.trace.report(Errors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM.on(argumentExpression)) + context.trace.report(Errors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION.on(argumentExpression, parameterDescriptor.type)) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt index 70e096bcf32..7a5f1174eba 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt @@ -168,10 +168,10 @@ class NewResolutionOldInference( val processor = kind.createTowerProcessor(this, nameToResolve, tracing, scopeTower, detailedReceiver, context) if (context.collectAllCandidates) { - return allCandidatesResult(towerResolver.collectAllCandidates(scopeTower, processor)) + return allCandidatesResult(towerResolver.collectAllCandidates(scopeTower, processor, nameToResolve)) } - var candidates = towerResolver.runResolve(scopeTower, processor, useOrder = kind != ResolutionKind.CallableReference) + var candidates = towerResolver.runResolve(scopeTower, processor, useOrder = kind != ResolutionKind.CallableReference, name = nameToResolve) // Temporary hack to resolve 'rem' as 'mod' if the first is do not present val emptyOrInapplicableCandidates = candidates.isEmpty() || @@ -179,7 +179,7 @@ class NewResolutionOldInference( if (isBinaryRemOperator && shouldUseOperatorRem && emptyOrInapplicableCandidates) { val deprecatedName = OperatorConventions.REM_TO_MOD_OPERATION_NAMES[name] val processorForDeprecatedName = kind.createTowerProcessor(this, deprecatedName!!, tracing, scopeTower, detailedReceiver, context) - candidates = towerResolver.runResolve(scopeTower, processorForDeprecatedName, useOrder = kind != ResolutionKind.CallableReference) + candidates = towerResolver.runResolve(scopeTower, processorForDeprecatedName, useOrder = kind != ResolutionKind.CallableReference, name = deprecatedName) } if (candidates.isEmpty()) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt index 94c7c958e2e..35d78e8147a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,7 +131,9 @@ object ExpectedActualDeclarationChecker : DeclarationChecker { if (!hasExpectedModifier) { if (Compatible !in compatibility) return - if (checkExpected) { + // we suppress error, because annotation classes can only have one constructor and it's a 100% boilerplate + // to require every annotation constructor with additional parameters with default values be marked with the `actual` modifier + if (checkExpected && !descriptor.isAnnotationConstructor()) { diagnosticHolder.report(Errors.ACTUAL_MISSING.on(reportOn)) } } @@ -362,7 +364,9 @@ object ExpectedActualDeclarationChecker : DeclarationChecker { val aParams = a.valueParameters val bParams = b.valueParameters - if (aParams.size != bParams.size) return Incompatible.ParameterCount + if (!valueParametersCountCompatible(a, b, aParams, bParams)) { + return Incompatible.ParameterCount + } val aTypeParams = a.typeParameters val bTypeParams = b.typeParameters @@ -401,6 +405,23 @@ object ExpectedActualDeclarationChecker : DeclarationChecker { return Compatible } + private fun valueParametersCountCompatible( + a: CallableMemberDescriptor, + b: CallableMemberDescriptor, + aParams: List, + bParams: List + ): Boolean { + if (aParams.size == bParams.size) return true + + return if (a.isAnnotationConstructor() && b.isAnnotationConstructor()) + aParams.isEmpty() && bParams.all { it.declaresDefaultValue() } + else + false + } + + private fun MemberDescriptor.isAnnotationConstructor(): Boolean = + this is ConstructorDescriptor && DescriptorUtils.isAnnotationClass(this.constructedClass) + private fun areCompatibleTypes(a: KotlinType?, b: KotlinType?, platformModule: ModuleDescriptor): Boolean { if (a == null) return b == null if (b == null) return false diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeFactory.kt index 52ded343428..8900f6c419e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeFactory.kt @@ -27,10 +27,7 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtImportDirective import org.jetbrains.kotlin.psi.KtImportsFactory import org.jetbrains.kotlin.resolve.* -import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter -import org.jetbrains.kotlin.resolve.scopes.ImportingScope -import org.jetbrains.kotlin.resolve.scopes.LexicalScope -import org.jetbrains.kotlin.resolve.scopes.SubpackagesImportingScope +import org.jetbrains.kotlin.resolve.scopes.* import org.jetbrains.kotlin.resolve.source.KotlinSourceElement import org.jetbrains.kotlin.script.getScriptExternalDependencies import org.jetbrains.kotlin.storage.StorageManager @@ -68,6 +65,41 @@ class FileScopeFactory( return FilesScopesBuilder(file, existingImports, packageFragment, packageView).result } + private fun createDefaultImportResolvers(extraImports: Collection, aliasImportNames: Collection): Pair { + val tempTrace = TemporaryBindingTrace.create(bindingTrace, "Transient trace for default imports lazy resolve", false) + val allImplicitImports = defaultImports concat extraImports + + val defaultImportsFiltered = if (aliasImportNames.isEmpty()) { // optimization + allImplicitImports + } + else { + allImplicitImports.filter { it.isAllUnder || it.importedFqName !in aliasImportNames } + } + + val defaultExplicitImportResolver = createImportResolver(ExplicitImportsIndexed(defaultImportsFiltered), tempTrace, packageFragment = null, aliasImportNames = aliasImportNames) + val defaultAllUnderImportResolver = + createImportResolver(AllUnderImportsIndexed(defaultImportsFiltered), tempTrace, packageFragment = null, aliasImportNames = aliasImportNames, excludedImports = defaultImportProvider.excludedImports) + + return defaultExplicitImportResolver to defaultAllUnderImportResolver + } + + private val defaultImportResolvers by storageManager.createLazyValue { + createDefaultImportResolvers(emptyList(), emptyList()) + } + + private fun createImportResolver( + indexedImports: IndexedImports, + trace: BindingTrace, + aliasImportNames: Collection, + packageFragment: PackageFragmentDescriptor?, + excludedImports: List? = null + ) = LazyImportResolver( + storageManager, qualifiedExpressionResolver, moduleDescriptor, platformToKotlinClassMap, languageVersionSettings, + indexedImports, aliasImportNames concat excludedImports, trace, packageFragment, + deprecationResolver + ) + + private inner class FilesScopesBuilder( private val file: KtFile, private val existingImports: ImportingScope?, @@ -77,8 +109,8 @@ class FileScopeFactory( val imports = file.importDirectives val aliasImportNames = imports.mapNotNull { if (it.aliasName != null) it.importedFqName else null } - val explicitImportResolver = createImportResolver(ExplicitImportsIndexed(imports), bindingTrace) - val allUnderImportResolver = createImportResolver(AllUnderImportsIndexed(imports), bindingTrace) // TODO: should we count excludedImports here also? + val explicitImportResolver = createImportResolver(ExplicitImportsIndexed(imports), bindingTrace, aliasImportNames, packageFragment) + val allUnderImportResolver = createImportResolver(AllUnderImportsIndexed(imports), bindingTrace, aliasImportNames, packageFragment) // TODO: should we count excludedImports here also? val lazyImportingScope = object : ImportingScope by ImportingScope.Empty { // avoid constructing the scope before we query it @@ -107,33 +139,21 @@ class FileScopeFactory( val result = FileScopes(lexicalScope, lazyImportingScope, importResolver) - fun createImportResolver(indexedImports: IndexedImports, trace: BindingTrace, excludedImports: List? = null) = - LazyImportResolver( - storageManager, qualifiedExpressionResolver, moduleDescriptor, platformToKotlinClassMap, languageVersionSettings, - indexedImports, aliasImportNames concat excludedImports, trace, packageFragment, - deprecationResolver - ) - - - fun createImportingScope(): LazyImportScope { - val tempTrace = TemporaryBindingTrace.create(bindingTrace, "Transient trace for default imports lazy resolve", false) - + private fun createDefaultImportResolversForFile(): Pair { val extraImports = file.originalFile.virtualFile?.let { vFile -> val scriptExternalDependencies = getScriptExternalDependencies(vFile, file.project) ktImportsFactory.createImportDirectives(scriptExternalDependencies?.imports?.map { ImportPath.fromString(it) }.orEmpty()) + }.orEmpty() + + if (extraImports.isEmpty() && aliasImportNames.isEmpty()) { + return defaultImportResolvers } - val allImplicitImports = defaultImports concat extraImports + return createDefaultImportResolvers(extraImports, aliasImportNames) + } - val defaultImportsFiltered = if (aliasImportNames.isEmpty()) { // optimization - allImplicitImports - } - else { - allImplicitImports.filter { it.isAllUnder || it.importedFqName !in aliasImportNames } - } - - val defaultExplicitImportResolver = createImportResolver(ExplicitImportsIndexed(defaultImportsFiltered), tempTrace) - val defaultAllUnderImportResolver = createImportResolver(AllUnderImportsIndexed(defaultImportsFiltered), tempTrace, defaultImportProvider.excludedImports) + fun createImportingScope(): LazyImportScope { + val (defaultExplicitImportResolver, defaultAllUnderImportResolver) = createDefaultImportResolversForFile() val dummyContainerDescriptor = DummyContainerDescriptor(file, packageFragment) @@ -164,8 +184,6 @@ class FileScopeFactory( return LazyImportScope(scope, explicitImportResolver, LazyImportScope.FilteringKind.ALL, "Explicit imports in $debugName") } - private infix fun Collection.concat(other: Collection?) = - if (other == null || other.isEmpty()) this else this + other } private enum class FilteringKind { @@ -180,6 +198,7 @@ class FileScopeFactory( parentScope: ImportingScope ): ImportingScope { val scope = packageView.memberScope + val names by lazy(LazyThreadSafetyMode.PUBLICATION) { scope.computeAllNames () } val packageName = packageView.fqName val excludedNames = aliasImportNames.mapNotNull { if (it.parent() == packageName) it.shortName() else null } @@ -220,6 +239,10 @@ class FileScopeFactory( ).filter { it !is PackageViewDescriptor } // subpackages of the current package not accessible by the short name } + override fun computeImportedNames() = packageView.memberScope.computeAllNames() + + override fun definitelyDoesNotContainName(name: Name) = names?.let { name !in it } == true + override fun toString() = "Scope for current package (${filteringKind.name})" override fun printStructure(p: Printer) { @@ -252,3 +275,6 @@ class FileScopeFactory( } } } + +private infix fun Collection.concat(other: Collection?) = + if (other == null || other.isEmpty()) this else this + other diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.java deleted file mode 100644 index e8a0951552a..00000000000 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.resolve.lazy; - -import com.intellij.psi.PsiElement; -import com.intellij.psi.util.PsiTreeUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.context.GlobalContext; -import org.jetbrains.kotlin.descriptors.*; -import org.jetbrains.kotlin.incremental.KotlinLookupLocation; -import org.jetbrains.kotlin.incremental.components.LookupLocation; -import org.jetbrains.kotlin.incremental.components.NoLookupLocation; -import org.jetbrains.kotlin.name.FqName; -import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt; -import org.jetbrains.kotlin.renderer.DescriptorRenderer; -import org.jetbrains.kotlin.resolve.BindingContext; -import org.jetbrains.kotlin.resolve.BindingTrace; -import org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope; -import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageDescriptor; -import org.jetbrains.kotlin.resolve.scopes.MemberScope; -import org.jetbrains.kotlin.storage.LockBasedLazyResolveStorageManager; - -import javax.inject.Inject; -import java.util.List; - -public class LazyDeclarationResolver { - - @NotNull private final TopLevelDescriptorProvider topLevelDescriptorProvider; - @NotNull private final AbsentDescriptorHandler absentDescriptorHandler; - @NotNull private final BindingTrace trace; - - protected DeclarationScopeProvider scopeProvider; - - // component dependency cycle - @Inject - public void setDeclarationScopeProvider(@NotNull DeclarationScopeProviderImpl scopeProvider) { - this.scopeProvider = scopeProvider; - } - - @Deprecated - public LazyDeclarationResolver( - @NotNull GlobalContext globalContext, - @NotNull BindingTrace delegationTrace, - @NotNull TopLevelDescriptorProvider topLevelDescriptorProvider, - @NotNull AbsentDescriptorHandler absentDescriptorHandler - ) { - this.topLevelDescriptorProvider = topLevelDescriptorProvider; - this.absentDescriptorHandler = absentDescriptorHandler; - LockBasedLazyResolveStorageManager lockBasedLazyResolveStorageManager = - new LockBasedLazyResolveStorageManager(globalContext.getStorageManager()); - - this.trace = lockBasedLazyResolveStorageManager.createSafeTrace(delegationTrace); - } - - @NotNull - public ClassDescriptor getClassDescriptor(@NotNull KtClassOrObject classOrObject, @NotNull LookupLocation location) { - return findClassDescriptor(classOrObject, location); - } - - @NotNull - public ScriptDescriptor getScriptDescriptor(@NotNull KtScript script, @NotNull LookupLocation location) { - return (ScriptDescriptor) findClassDescriptor(script, location); - } - - @NotNull - private ClassDescriptor findClassDescriptor( - @NotNull KtNamedDeclaration classObjectOrScript, - @NotNull LookupLocation location - ) { - MemberScope scope = getMemberScopeDeclaredIn(classObjectOrScript, location); - - // Why not use the result here. Because it may be that there is a redeclaration: - // class A {} class A { fun foo(): A} - // and if we find the class by name only, we may b-not get the right one. - // This call is only needed to make sure the classes are written to trace - ClassifierDescriptor scopeDescriptor = scope.getContributedClassifier(classObjectOrScript.getNameAsSafeName(), location); - DeclarationDescriptor descriptor = getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, classObjectOrScript); - - if (descriptor == null) { - String providerInfoString = null; - if (scope instanceof AbstractLazyMemberScope) { - AbstractLazyMemberScope lazyMemberScope = (AbstractLazyMemberScope) scope; - providerInfoString = lazyMemberScope.toProviderString(); - } - throw new IllegalArgumentException( - String.format( - "Could not find a classifier for %s.\n" + - "Found descriptor: %s (%s).\n" + - "Scope: %s.\n" + - "Provider: %s.", - PsiUtilsKt.getElementTextWithContext(classObjectOrScript), - scopeDescriptor != null ? DescriptorRenderer.DEBUG_TEXT.render(scopeDescriptor) : "null", - scopeDescriptor != null ? (scopeDescriptor.getContainingDeclaration().getClass()) : null, - scope, - providerInfoString != null ? providerInfoString : "null" - ) - ); - } - - return (ClassDescriptor) descriptor; - } - - @NotNull - private BindingContext getBindingContext() { - return trace.getBindingContext(); - } - - @NotNull - public DeclarationDescriptor resolveToDescriptor(@NotNull KtDeclaration declaration) { - return resolveToDescriptor(declaration, /*track =*/true); - } - - @NotNull - private DeclarationDescriptor resolveToDescriptor(@NotNull KtDeclaration declaration, boolean track) { - DeclarationDescriptor result = declaration.accept(new KtVisitor() { - @NotNull - private LookupLocation lookupLocationFor(@NotNull KtDeclaration declaration, boolean isTopLevel) { - return isTopLevel && track ? new KotlinLookupLocation(declaration) : NoLookupLocation.WHEN_RESOLVE_DECLARATION; - } - - @Override - public DeclarationDescriptor visitClass(@NotNull KtClass klass, Void data) { - return getClassDescriptor(klass, lookupLocationFor(klass, klass.isTopLevel())); - } - - @Override - public DeclarationDescriptor visitObjectDeclaration(@NotNull KtObjectDeclaration declaration, Void data) { - return getClassDescriptor(declaration, lookupLocationFor(declaration, declaration.isTopLevel())); - } - - @Override - public DeclarationDescriptor visitTypeParameter(@NotNull KtTypeParameter parameter, Void data) { - KtTypeParameterListOwner ownerElement = PsiTreeUtil.getParentOfType(parameter, KtTypeParameterListOwner.class); - assert ownerElement != null : "Owner not found for type parameter: " + parameter.getText(); - DeclarationDescriptor ownerDescriptor = resolveToDescriptor(ownerElement, /*track =*/false); - - List typeParameters; - if (ownerDescriptor instanceof CallableDescriptor) { - CallableDescriptor callableDescriptor = (CallableDescriptor) ownerDescriptor; - typeParameters = callableDescriptor.getTypeParameters(); - } - else if (ownerDescriptor instanceof ClassifierDescriptorWithTypeParameters) { - ClassifierDescriptorWithTypeParameters classifierDescriptor = (ClassifierDescriptorWithTypeParameters) ownerDescriptor; - typeParameters = classifierDescriptor.getTypeConstructor().getParameters(); - } - else { - throw new IllegalStateException("Unknown owner kind for a type parameter: " + ownerDescriptor); - } - - Name name = parameter.getNameAsSafeName(); - for (TypeParameterDescriptor typeParameterDescriptor : typeParameters) { - if (typeParameterDescriptor.getName().equals(name)) { - return typeParameterDescriptor; - } - } - - throw new IllegalStateException("Type parameter " + name + " not found for " + ownerDescriptor); - } - - @Override - public DeclarationDescriptor visitNamedFunction(@NotNull KtNamedFunction function, Void data) { - LookupLocation location = lookupLocationFor(function, function.isTopLevel()); - MemberScope scopeForDeclaration = getMemberScopeDeclaredIn(function, location); - scopeForDeclaration.getContributedFunctions(function.getNameAsSafeName(), location); - return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, function); - } - - @Override - public DeclarationDescriptor visitParameter(@NotNull KtParameter parameter, Void data) { - PsiElement grandFather = parameter.getParent().getParent(); - if (grandFather instanceof KtPrimaryConstructor) { - KtClassOrObject jetClass = ((KtPrimaryConstructor) grandFather).getContainingClassOrObject(); - // This is a primary constructor parameter - ClassDescriptor classDescriptor = getClassDescriptor(jetClass, lookupLocationFor(jetClass, false)); - if (parameter.hasValOrVar()) { - classDescriptor.getDefaultType().getMemberScope().getContributedVariables(parameter.getNameAsSafeName(), lookupLocationFor(parameter, false)); - return getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter); - } - else { - ConstructorDescriptor constructor = classDescriptor.getUnsubstitutedPrimaryConstructor(); - assert constructor != null: "There are constructor parameters found, so a constructor should also exist"; - constructor.getValueParameters(); - return getBindingContext().get(BindingContext.VALUE_PARAMETER, parameter); - } - } - else if (grandFather instanceof KtNamedFunction) { - FunctionDescriptor function = (FunctionDescriptor) visitNamedFunction((KtNamedFunction) grandFather, data); - function.getValueParameters(); - return getBindingContext().get(BindingContext.VALUE_PARAMETER, parameter); - } - else if (grandFather instanceof KtSecondaryConstructor) { - ConstructorDescriptor constructorDescriptor = (ConstructorDescriptor) visitSecondaryConstructor( - (KtSecondaryConstructor) grandFather, data - ); - constructorDescriptor.getValueParameters(); - return getBindingContext().get(BindingContext.VALUE_PARAMETER, parameter); - } - else { - //TODO: support parameters in accessors and other places(?) - return super.visitParameter(parameter, data); - } - } - - @Override - public DeclarationDescriptor visitSecondaryConstructor(@NotNull KtSecondaryConstructor constructor, Void data) { - getClassDescriptor((KtClassOrObject) constructor.getParent().getParent(), lookupLocationFor(constructor, false)).getConstructors(); - return getBindingContext().get(BindingContext.CONSTRUCTOR, constructor); - } - - @Override - public DeclarationDescriptor visitPrimaryConstructor(@NotNull KtPrimaryConstructor constructor, Void data) { - getClassDescriptor(constructor.getContainingClassOrObject(), lookupLocationFor(constructor, false)).getConstructors(); - return getBindingContext().get(BindingContext.CONSTRUCTOR, constructor); - } - - @Override - public DeclarationDescriptor visitProperty(@NotNull KtProperty property, Void data) { - LookupLocation location = lookupLocationFor(property, property.isTopLevel()); - MemberScope scopeForDeclaration = getMemberScopeDeclaredIn(property, location); - scopeForDeclaration.getContributedVariables(property.getNameAsSafeName(), location); - return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, property); - } - - @Override - public DeclarationDescriptor visitDestructuringDeclarationEntry( - @NotNull KtDestructuringDeclarationEntry destructuringDeclarationEntry, Void data - ) { - LookupLocation location = lookupLocationFor(destructuringDeclarationEntry, false); - KtDestructuringDeclaration destructuringDeclaration = ((KtDestructuringDeclaration) destructuringDeclarationEntry.getParent()); - MemberScope scopeForDeclaration = getMemberScopeDeclaredIn(destructuringDeclaration, location); - scopeForDeclaration.getContributedVariables(destructuringDeclarationEntry.getNameAsSafeName(), location); - return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, destructuringDeclarationEntry); - } - - @Override - public DeclarationDescriptor visitTypeAlias(@NotNull KtTypeAlias typeAlias, Void data) { - LookupLocation location = lookupLocationFor(typeAlias, typeAlias.isTopLevel()); - MemberScope scopeForDeclaration = getMemberScopeDeclaredIn(typeAlias, location); - scopeForDeclaration.getContributedClassifier(typeAlias.getNameAsSafeName(), location); - return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, typeAlias); - } - - @Override - public DeclarationDescriptor visitScript(@NotNull KtScript script, Void data) { - return getScriptDescriptor(script, lookupLocationFor(script, true)); - } - - @Override - public DeclarationDescriptor visitKtElement(@NotNull KtElement element, Void data) { - throw new IllegalArgumentException("Unsupported declaration type: " + element + " " + - PsiUtilsKt.getElementTextWithContext(element)); - } - }, null); - if (result == null) { - return absentDescriptorHandler.diagnoseDescriptorNotFound(declaration); - } - return result; - } - - @NotNull - /*package*/ MemberScope getMemberScopeDeclaredIn(@NotNull KtDeclaration declaration, @NotNull LookupLocation location) { - KtDeclaration parentDeclaration = KtStubbedPsiUtil.getContainingDeclaration(declaration); - boolean isTopLevel = parentDeclaration == null; - if (isTopLevel) { // for top level declarations we search directly in package because of possible conflicts with imports - KtFile ktFile = (KtFile) declaration.getContainingFile(); - FqName fqName = ktFile.getPackageFqName(); - topLevelDescriptorProvider.assertValid(); - LazyPackageDescriptor packageDescriptor = topLevelDescriptorProvider.getPackageFragment(fqName); - if (packageDescriptor == null) { - if (topLevelDescriptorProvider instanceof LazyClassContext) { - ((LazyClassContext) topLevelDescriptorProvider).getDeclarationProviderFactory().diagnoseMissingPackageFragment(ktFile); - } - else { - throw new IllegalStateException("Cannot find package fragment for file " + ktFile.getName() + " with package " + fqName); - } - } - return packageDescriptor.getMemberScope(); - } - else { - if (parentDeclaration instanceof KtClassOrObject) { - return getClassDescriptor((KtClassOrObject) parentDeclaration, location).getUnsubstitutedMemberScope(); - } - else if (parentDeclaration instanceof KtScript) { - return getScriptDescriptor((KtScript) parentDeclaration, location).getUnsubstitutedMemberScope(); - } - else { - throw new IllegalStateException("Don't call this method for local declarations: " + declaration + "\n" + - PsiUtilsKt.getElementTextWithContext(declaration)); - } - } - } -} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.kt new file mode 100644 index 00000000000..7e0669dcebd --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.kt @@ -0,0 +1,239 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve.lazy + +import com.intellij.psi.util.PsiTreeUtil +import org.jetbrains.kotlin.context.GlobalContext +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.incremental.KotlinLookupLocation +import org.jetbrains.kotlin.incremental.components.LookupLocation +import org.jetbrains.kotlin.incremental.components.NoLookupLocation +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.BindingTrace +import org.jetbrains.kotlin.resolve.scopes.MemberScope +import org.jetbrains.kotlin.storage.LockBasedLazyResolveStorageManager +import javax.inject.Inject + +open class LazyDeclarationResolver @Deprecated("") constructor( + globalContext: GlobalContext, + delegationTrace: BindingTrace, + private val topLevelDescriptorProvider: TopLevelDescriptorProvider, + private val absentDescriptorHandler: AbsentDescriptorHandler +) { + private val trace: BindingTrace + + protected lateinit var scopeProvider: DeclarationScopeProvider + + private val bindingContext: BindingContext + get() = trace.bindingContext + + // component dependency cycle + @Inject + fun setDeclarationScopeProvider(scopeProvider: DeclarationScopeProviderImpl) { + this.scopeProvider = scopeProvider + } + + init { + val lockBasedLazyResolveStorageManager = LockBasedLazyResolveStorageManager(globalContext.storageManager) + + this.trace = lockBasedLazyResolveStorageManager.createSafeTrace(delegationTrace) + } + + open fun getClassDescriptorIfAny(classOrObject: KtClassOrObject, location: LookupLocation): ClassDescriptor? = + findClassDescriptorIfAny(classOrObject, location) + + open fun getClassDescriptor(classOrObject: KtClassOrObject, location: LookupLocation): ClassDescriptor = + findClassDescriptor(classOrObject, location) + + fun getScriptDescriptor(script: KtScript, location: LookupLocation): ScriptDescriptor = + findClassDescriptor(script, location) as ScriptDescriptor + + private fun findClassDescriptorIfAny( + classObjectOrScript: KtNamedDeclaration, + location: LookupLocation + ): ClassDescriptor? { + val scope = getMemberScopeDeclaredIn(classObjectOrScript, location) + + // Why not use the result here. Because it may be that there is a redeclaration: + // class A {} class A { fun foo(): A} + // and if we find the class by name only, we may b-not get the right one. + // This call is only needed to make sure the classes are written to trace + scope.getContributedClassifier(classObjectOrScript.nameAsSafeName, location) + val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, classObjectOrScript) + + return descriptor as? ClassDescriptor + } + + private fun findClassDescriptor( + classObjectOrScript: KtNamedDeclaration, + location: LookupLocation + ): ClassDescriptor = + findClassDescriptorIfAny(classObjectOrScript, location) + ?: (absentDescriptorHandler.diagnoseDescriptorNotFound(classObjectOrScript) as ClassDescriptor) + + fun resolveToDescriptor(declaration: KtDeclaration): DeclarationDescriptor = + resolveToDescriptor(declaration, /*track =*/true) ?: absentDescriptorHandler.diagnoseDescriptorNotFound(declaration) + + private fun resolveToDescriptor(declaration: KtDeclaration, track: Boolean): DeclarationDescriptor? { + return declaration.accept(object : KtVisitor() { + private fun lookupLocationFor(declaration: KtDeclaration, isTopLevel: Boolean): LookupLocation = + if (isTopLevel && track) KotlinLookupLocation(declaration) + else NoLookupLocation.WHEN_RESOLVE_DECLARATION + + override fun visitClass(klass: KtClass, data: Nothing?): DeclarationDescriptor? = + getClassDescriptorIfAny(klass, lookupLocationFor(klass, klass.isTopLevel())) + + override fun visitObjectDeclaration(declaration: KtObjectDeclaration, data: Nothing?): DeclarationDescriptor? = + getClassDescriptorIfAny(declaration, lookupLocationFor(declaration, declaration.isTopLevel())) + + override fun visitTypeParameter(parameter: KtTypeParameter, data: Nothing?): DeclarationDescriptor? { + val ownerElement = PsiTreeUtil.getParentOfType(parameter, KtTypeParameterListOwner::class.java) ?: error("Owner not found for type parameter: " + parameter.text) + val ownerDescriptor = resolveToDescriptor(ownerElement, /*track =*/false) ?: return null + + val typeParameters: List + typeParameters = when (ownerDescriptor) { + is CallableDescriptor -> ownerDescriptor.typeParameters + is ClassifierDescriptorWithTypeParameters -> ownerDescriptor.typeConstructor.parameters + else -> throw IllegalStateException("Unknown owner kind for a type parameter: " + ownerDescriptor) + } + + val name = parameter.nameAsSafeName + return typeParameters.firstOrNull { it.name == name } + ?: throw IllegalStateException("Type parameter $name not found for $ownerDescriptor") + } + + override fun visitNamedFunction(function: KtNamedFunction, data: Nothing?): DeclarationDescriptor? { + val location = lookupLocationFor(function, function.isTopLevel) + val scopeForDeclaration = getMemberScopeDeclaredIn(function, location) + scopeForDeclaration.getContributedFunctions(function.nameAsSafeName, location) + return bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, function) + } + + override fun visitParameter(parameter: KtParameter, data: Nothing?): DeclarationDescriptor? { + val grandFather = parameter.parent.parent + when (grandFather) { + is KtPrimaryConstructor -> { + val jetClass = grandFather.getContainingClassOrObject() + // This is a primary constructor parameter + val classDescriptor = getClassDescriptorIfAny(jetClass, lookupLocationFor(jetClass, false)) + return when { + classDescriptor == null -> null + parameter.hasValOrVar() -> { + classDescriptor.defaultType.memberScope.getContributedVariables( + parameter.nameAsSafeName, lookupLocationFor(parameter, false)) + bindingContext.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter) + } + else -> { + val constructor = classDescriptor.unsubstitutedPrimaryConstructor + ?: error("There are constructor parameters found, so a constructor should also exist") + constructor.valueParameters + bindingContext.get(BindingContext.VALUE_PARAMETER, parameter) + } + } + } + is KtNamedFunction -> { + val function = visitNamedFunction(grandFather, data) as? FunctionDescriptor + function?.valueParameters + return bindingContext.get(BindingContext.VALUE_PARAMETER, parameter) + } + is KtSecondaryConstructor -> { + val constructorDescriptor = visitSecondaryConstructor( + grandFather, data + ) as? ConstructorDescriptor + constructorDescriptor?.valueParameters + return bindingContext.get(BindingContext.VALUE_PARAMETER, parameter) + } + else -> //TODO: support parameters in accessors and other places(?) + return super.visitParameter(parameter, data) + } + } + + override fun visitSecondaryConstructor(constructor: KtSecondaryConstructor, data: Nothing?): DeclarationDescriptor? { + getClassDescriptorIfAny(constructor.parent.parent as KtClassOrObject, lookupLocationFor(constructor, false))?.constructors + return bindingContext.get(BindingContext.CONSTRUCTOR, constructor) + } + + override fun visitPrimaryConstructor(constructor: KtPrimaryConstructor, data: Nothing?): DeclarationDescriptor? { + getClassDescriptorIfAny(constructor.getContainingClassOrObject(), lookupLocationFor(constructor, false))?.constructors + return bindingContext.get(BindingContext.CONSTRUCTOR, constructor) + } + + override fun visitProperty(property: KtProperty, data: Nothing?): DeclarationDescriptor? { + val location = lookupLocationFor(property, property.isTopLevel) + val scopeForDeclaration = getMemberScopeDeclaredIn(property, location) + scopeForDeclaration.getContributedVariables(property.nameAsSafeName, location) + return bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, property) + } + + override fun visitDestructuringDeclarationEntry( + destructuringDeclarationEntry: KtDestructuringDeclarationEntry, data: Nothing? + ): DeclarationDescriptor? { + val location = lookupLocationFor(destructuringDeclarationEntry, false) + val destructuringDeclaration = destructuringDeclarationEntry.parent as? KtDestructuringDeclaration ?: return null + val scopeForDeclaration = getMemberScopeDeclaredIn(destructuringDeclaration, location) + scopeForDeclaration.getContributedVariables(destructuringDeclarationEntry.nameAsSafeName, location) + return bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, destructuringDeclarationEntry) + } + + override fun visitTypeAlias(typeAlias: KtTypeAlias, data: Nothing?): DeclarationDescriptor? { + val location = lookupLocationFor(typeAlias, typeAlias.isTopLevel()) + val scopeForDeclaration = getMemberScopeDeclaredIn(typeAlias, location) + scopeForDeclaration.getContributedClassifier(typeAlias.nameAsSafeName, location) + return bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, typeAlias) + } + + override fun visitScript(script: KtScript, data: Nothing?): DeclarationDescriptor = + getScriptDescriptor(script, lookupLocationFor(script, true)) + + override fun visitKtElement(element: KtElement, data: Nothing?): DeclarationDescriptor? { + throw IllegalArgumentException("Unsupported declaration type: " + element + " " + + element.getElementTextWithContext()) + } + }, null) + } + + internal fun getMemberScopeDeclaredIn(declaration: KtDeclaration, location: LookupLocation): + /*package*/ MemberScope { + val parentDeclaration = KtStubbedPsiUtil.getContainingDeclaration(declaration) + val isTopLevel = parentDeclaration == null + if (isTopLevel) { // for top level declarations we search directly in package because of possible conflicts with imports + val ktFile = declaration.containingFile as KtFile + val fqName = ktFile.packageFqName + topLevelDescriptorProvider.assertValid() + val packageDescriptor = topLevelDescriptorProvider.getPackageFragment(fqName) + if (packageDescriptor == null) { + if (topLevelDescriptorProvider is LazyClassContext) { + topLevelDescriptorProvider.declarationProviderFactory.diagnoseMissingPackageFragment(ktFile) + } + else { + throw IllegalStateException("Cannot find package fragment for file " + ktFile.name + " with package " + fqName) + } + } + return packageDescriptor!!.getMemberScope() + } + else { + return when (parentDeclaration) { + is KtClassOrObject -> getClassDescriptor(parentDeclaration, location).unsubstitutedMemberScope + is KtScript -> getScriptDescriptor(parentDeclaration, location).unsubstitutedMemberScope + else -> throw IllegalStateException("Don't call this method for local declarations: " + declaration + "\n" + + declaration.getElementTextWithContext()) + } + } + } +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt index 5ea473866b9..fc6a4b3804b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt @@ -37,6 +37,7 @@ import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.expressions.OperatorConventions import org.jetbrains.kotlin.util.collectionUtils.concat import org.jetbrains.kotlin.utils.Printer +import org.jetbrains.kotlin.utils.addToStdlib.flatMapToNullable import java.util.* interface IndexedImports { @@ -81,7 +82,7 @@ class LazyImportResolver( val indexedImports: IndexedImports, excludedImportNames: Collection, private val traceForImportResolve: BindingTrace, - private val packageFragment: PackageFragmentDescriptor, + private val packageFragment: PackageFragmentDescriptor?, val deprecationResolver: DeprecationResolver ) : ImportResolver { private val importedScopesProvider = storageManager.createMemoizedFunctionWithNullableValues { @@ -191,6 +192,19 @@ class LazyImportResolver( fun getImportScope(directive: KtImportDirective): ImportingScope { return importedScopesProvider(directive) ?: ImportingScope.Empty } + + val allNames: Set? by lazy(LazyThreadSafetyMode.PUBLICATION) { + indexedImports.imports.flatMapToNullable(hashSetOf()) { getImportScope(it).computeImportedNames() } + } + + fun definitelyDoesNotContainName(name: Name) = allNames?.let { name !in it } == true + + fun recordLookup(name: Name, location: LookupLocation) { + if (allNames == null) return + indexedImports.importsForName(name).forEach { + getImportScope(it).recordLookup(name, location) + } + } } class LazyImportScope( @@ -269,4 +283,12 @@ class LazyImportScope( p.popIndent() p.println("}") } + + override fun definitelyDoesNotContainName(name: Name) = importResolver.definitelyDoesNotContainName(name) + + override fun recordLookup(name: Name, location: LookupLocation) { + importResolver.recordLookup(name, location) + } + + override fun computeImportedNames() = importResolver.allNames } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/AbstractPsiBasedDeclarationProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/AbstractPsiBasedDeclarationProvider.kt index e68a698bd30..4d0e1c5c7c0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/AbstractPsiBasedDeclarationProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/AbstractPsiBasedDeclarationProvider.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.resolve.lazy.declarations import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.Sets import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils.safeNameForLazyResolve @@ -37,6 +38,7 @@ abstract class AbstractPsiBasedDeclarationProvider(storageManager: StorageManage val classesAndObjects = ArrayListMultimap.create() // order matters here val typeAliases = ArrayListMultimap.create() val destructuringDeclarationsEntries = ArrayListMultimap.create() + val names = Sets.newHashSet() fun putToIndex(declaration: KtDeclaration) { if (declaration is KtAnonymousInitializer || declaration is KtSecondaryConstructor) return @@ -57,7 +59,9 @@ abstract class AbstractPsiBasedDeclarationProvider(storageManager: StorageManage } is KtDestructuringDeclaration -> { for (entry in declaration.entries) { - destructuringDeclarationsEntries.put(safeNameForLazyResolve(entry.nameAsName), entry) + val name = safeNameForLazyResolve(entry.nameAsName) + destructuringDeclarationsEntries.put(name, entry) + names.add(name) } } is KtParameter -> { @@ -65,11 +69,17 @@ abstract class AbstractPsiBasedDeclarationProvider(storageManager: StorageManage } else -> throw IllegalArgumentException("Unknown declaration: " + declaration) } + + when (declaration) { + is KtNamedDeclaration -> names.add(safeNameForLazyResolve(declaration)) + } } override fun toString() = "allDeclarations: " + allDeclarations.mapNotNull { it.name } } + override fun getDeclarationNames() = index().names + private val index = storageManager.createLazyValue { val index = Index() doCreateIndex(index) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/CombinedPackageMemberDeclarationProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/CombinedPackageMemberDeclarationProvider.kt index c457578d570..f3851057a73 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/CombinedPackageMemberDeclarationProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/CombinedPackageMemberDeclarationProvider.kt @@ -41,4 +41,6 @@ class CombinedPackageMemberDeclarationProvider( override fun getClassOrObjectDeclarations(name: Name) = providers.flatMap { it.getClassOrObjectDeclarations(name) } override fun getTypeAliasDeclarations(name: Name) = providers.flatMap { it.getTypeAliasDeclarations(name) } + + override fun getDeclarationNames(): Set = providers.flatMapTo(HashSet()) { it.getDeclarationNames() } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/DeclarationProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/DeclarationProvider.kt index 4957527f3ed..cf484b2588e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/DeclarationProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/DeclarationProvider.kt @@ -33,4 +33,6 @@ interface DeclarationProvider { fun getClassOrObjectDeclarations(name: Name): Collection fun getTypeAliasDeclarations(name: Name): Collection + + fun getDeclarationNames(): Set } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt index 9d1ac9d11fe..3951107526d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt @@ -219,8 +219,6 @@ protected constructor( return result.toList() } - abstract fun recordLookup(name: Name, from: LookupLocation) - // Do not change this, override in concrete subclasses: // it is very easy to compromise laziness of this class, and fail all the debugging // a generic implementation can't do this properly diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyPackageMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyPackageMemberScope.kt index 98932bdde9c..5ecd085013f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyPackageMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyPackageMemberScope.kt @@ -58,6 +58,10 @@ class LazyPackageMemberScope( c.lookupTracker.record(from, thisDescriptor, name) } + override fun getClassifierNames(): Set? = declarationProvider.getDeclarationNames() + override fun getFunctionNames() = declarationProvider.getDeclarationNames() + override fun getVariableNames() = declarationProvider.getDeclarationNames() + // Do not add details here, they may compromise the laziness during debugging override fun toString() = "lazy scope for package " + thisDescriptor.name } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt index 38aa306cfb0..28389553ef9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt @@ -18,10 +18,8 @@ package org.jetbrains.kotlin.types.expressions import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiTreeUtil -import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.config.TargetPlatformVersion -import org.jetbrains.kotlin.config.languageVersionSettings import org.jetbrains.kotlin.container.get import org.jetbrains.kotlin.context.GlobalContext import org.jetbrains.kotlin.context.withModule @@ -200,6 +198,13 @@ class LocalLazyDeclarationResolver( } return super.getClassDescriptor(classOrObject, location) } + + override fun getClassDescriptorIfAny(classOrObject: KtClassOrObject, location: LookupLocation): ClassDescriptor? { + if (localClassDescriptorManager.isMyClass(classOrObject)) { + return localClassDescriptorManager.getClassDescriptor(classOrObject, scopeProvider) + } + return super.getClassDescriptorIfAny(classOrObject, location) + } } diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/BuildDiffsStorage.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/BuildDiffsStorage.kt new file mode 100644 index 00000000000..1ba8074d4b1 --- /dev/null +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/BuildDiffsStorage.kt @@ -0,0 +1,132 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.incremental + +import org.jetbrains.annotations.TestOnly +import org.jetbrains.kotlin.name.FqName +import java.io.File +import java.io.IOException +import java.io.ObjectInputStream +import java.io.ObjectOutputStream + +data class BuildDifference(val ts: Long, val isIncremental: Boolean, val dirtyData: DirtyData) + +// todo: storage format can be optimized by compressing fq-names +data class BuildDiffsStorage(val buildDiffs: List) { + companion object { + fun readFromFile(file: File, reporter: ICReporter?): BuildDiffsStorage? { + fun reportFail(reason: String) { + reporter?.report { "Could not read diff from file $file: $reason" } + } + + if (!file.exists()) return null + + try { + ObjectInputStream(file.inputStream().buffered()).use { input -> + val version = input.readInt() + if (version != CURRENT_VERSION) { + reportFail("incompatible version $version, actual version is $CURRENT_VERSION") + return null + } + + val size = input.readInt() + val result = ArrayList(size) + repeat(size) { + result.add(input.readBuildDifference()) + } + return BuildDiffsStorage(result) + } + } + catch (e: IOException) { + reportFail(e.toString()) + } + + return null + } + + fun writeToFile(file: File, storage: BuildDiffsStorage, reporter: ICReporter?) { + file.parentFile.mkdirs() + + try { + ObjectOutputStream(file.outputStream().buffered()).use { output -> + output.writeInt(CURRENT_VERSION) + + val diffsToWrite = storage.buildDiffs.sortedBy { it.ts }.takeLast(MAX_DIFFS_ENTRIES) + output.writeInt(diffsToWrite.size) + for (diff in diffsToWrite) { + output.writeBuildDifference(diff) + } + } + } + catch (e: IOException) { + reporter?.report { "Could not write diff to file $file: $e" } + } + } + + private fun ObjectInputStream.readBuildDifference(): BuildDifference { + val ts = readLong() + val isIncremental = readBoolean() + val dirtyData = readDirtyData() + return BuildDifference(ts, isIncremental, dirtyData) + } + + private fun ObjectOutputStream.writeBuildDifference(diff: BuildDifference) { + writeLong(diff.ts) + writeBoolean(diff.isIncremental) + writeDirtyData(diff.dirtyData) + } + + private fun ObjectInputStream.readDirtyData(): DirtyData { + val lookupSymbolSize = readInt() + val lookupSymbols = ArrayList(lookupSymbolSize) + repeat(lookupSymbolSize) { + val name = readUTF() + val scope = readUTF() + lookupSymbols.add(LookupSymbol(name = name, scope = scope)) + } + + val dirtyClassesSize = readInt() + val dirtyClassesFqNames = ArrayList(dirtyClassesSize) + repeat(dirtyClassesSize) { + val fqNameString = readUTF() + dirtyClassesFqNames.add(FqName(fqNameString)) + } + + return DirtyData(lookupSymbols, dirtyClassesFqNames) + } + + private fun ObjectOutputStream.writeDirtyData(dirtyData: DirtyData) { + val lookupSymbols = dirtyData.dirtyLookupSymbols + writeInt(lookupSymbols.size) + for ((name, scope) in lookupSymbols) { + writeUTF(name) + writeUTF(scope) + } + + val dirtyClassesFqNames = dirtyData.dirtyClassesFqNames + writeInt(dirtyClassesFqNames.size) + for (fqName in dirtyClassesFqNames) { + writeUTF(fqName.asString()) + } + } + + internal val MAX_DIFFS_ENTRIES: Int = 10 + + @set:TestOnly + var CURRENT_VERSION: Int = 0 + } +} \ No newline at end of file diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/BuildInfo.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/BuildInfo.kt index d5cfc2ded94..d5149dfadb9 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/BuildInfo.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/BuildInfo.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.incremental import java.io.* -internal data class BuildInfo(val startTS: Long) : Serializable { +data class BuildInfo(val startTS: Long) : Serializable { companion object { fun read(file: File): BuildInfo? = try { diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalCompilerRunner.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalCompilerRunner.kt index fcd9688ea0b..dfa187249b7 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalCompilerRunner.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalCompilerRunner.kt @@ -255,16 +255,9 @@ abstract class IncrementalCompilerRunner< if (exitCode == ExitCode.OK && compilationMode is CompilationMode.Incremental) { buildDirtyLookupSymbols.addAll(additionalDirtyLookupSymbols()) } - if (changesRegistry != null) { - if (compilationMode is CompilationMode.Incremental) { - val dirtyData = DirtyData(buildDirtyLookupSymbols, buildDirtyFqNames) - changesRegistry.registerChanges(currentBuildInfo.startTS, dirtyData) - } - else { - assert(compilationMode is CompilationMode.Rebuild) { "Unexpected compilation mode: ${compilationMode::class.java}" } - changesRegistry.unknownChanges(currentBuildInfo.startTS) - } - } + + val dirtyData = DirtyData(buildDirtyLookupSymbols, buildDirtyFqNames) + processChangesAfterBuild(compilationMode, currentBuildInfo, dirtyData) if (exitCode == ExitCode.OK) { cacheVersions.forEach { it.saveIfNeeded() } @@ -273,6 +266,18 @@ abstract class IncrementalCompilerRunner< return exitCode } + protected open fun processChangesAfterBuild(compilationMode: CompilationMode, currentBuildInfo: BuildInfo, dirtyData: DirtyData) { + if (changesRegistry == null) return + + if (compilationMode is CompilationMode.Incremental) { + changesRegistry.registerChanges(currentBuildInfo.startTS, dirtyData) + } + else { + assert(compilationMode is CompilationMode.Rebuild) { "Unexpected compilation mode: ${compilationMode::class.java}" } + changesRegistry.unknownChanges(currentBuildInfo.startTS) + } + } + companion object { const val DIRTY_SOURCES_FILE_NAME = "dirty-sources.txt" const val LAST_BUILD_INFO_FILE_NAME = "last-build.bin" diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt index 881e14df20c..45ab3f6d3f8 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt @@ -16,10 +16,10 @@ package org.jetbrains.kotlin.incremental +import com.intellij.openapi.util.io.FileUtil import org.jetbrains.kotlin.annotation.AnnotationFileUpdater import org.jetbrains.kotlin.build.GeneratedFile import org.jetbrains.kotlin.build.GeneratedJvmClass -import org.jetbrains.kotlin.build.isModuleMappingFile import org.jetbrains.kotlin.build.JvmSourceRoot import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments @@ -38,6 +38,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.jvm.JvmClassName import java.io.File import java.util.* +import kotlin.collections.HashSet fun makeIncrementally( cachesDir: File, @@ -89,7 +90,9 @@ class IncrementalJvmCompilerRunner( reporter: ICReporter, private var kaptAnnotationsFileUpdater: AnnotationFileUpdater? = null, artifactChangesProvider: ArtifactChangesProvider? = null, - changesRegistry: ChangesRegistry? = null + changesRegistry: ChangesRegistry? = null, + private val buildHistoryFile: File? = null, + private val friendBuildHistoryFile: File? = null ) : IncrementalCompilerRunner( workingDir, "caches-jvm", @@ -110,16 +113,58 @@ class IncrementalJvmCompilerRunner( private var javaFilesProcessor = ChangedJavaFilesProcessor(reporter) override fun calculateSourcesToCompile(caches: IncrementalJvmCachesManager, changedFiles: ChangedFiles.Known, args: K2JVMCompilerArguments): CompilationMode { - val removedClassFiles = changedFiles.removed.filter(File::isClassFile) - if (removedClassFiles.any()) return CompilationMode.Rebuild { "Removed class files: ${reporter.pathsAsString(removedClassFiles)}" } + val dirtyFiles = getDirtyFiles(changedFiles) - val modifiedClassFiles = changedFiles.modified.filter(File::isClassFile) - if (modifiedClassFiles.any()) return CompilationMode.Rebuild { "Modified class files: ${reporter.pathsAsString(modifiedClassFiles)}" } + fun markDirtyBy(lookupSymbols: Collection) { + if (lookupSymbols.isEmpty()) return + + val dirtyFilesFromLookups = mapLookupSymbolsToFiles(caches.lookupCache, lookupSymbols, reporter) + dirtyFiles.addAll(dirtyFilesFromLookups) + } + + fun markDirtyBy(dirtyClassesFqNames: Collection) { + if (dirtyClassesFqNames.isEmpty()) return + + val fqNamesWithSubtypes = dirtyClassesFqNames.flatMap { withSubtypes(it, listOf(caches.platformCache)) } + val dirtyFilesFromFqNames = mapClassesFqNamesToFiles(listOf(caches.platformCache), fqNamesWithSubtypes, reporter) + dirtyFiles.addAll(dirtyFilesFromFqNames) + } + + val lastBuildInfo = BuildInfo.read(lastBuildInfoFile) + reporter.report { "Last Kotlin Build info -- $lastBuildInfo" } + + val changesFromFriend by lazy { + val myLastTS = lastBuildInfo?.startTS ?: return@lazy ChangesEither.Unknown() + val storage = friendBuildHistoryFile?.let { BuildDiffsStorage.readFromFile(it, reporter) } ?: return@lazy ChangesEither.Unknown() + + val (prevDiffs, newDiffs) = storage.buildDiffs.partition { it.ts < myLastTS } + if (prevDiffs.isEmpty()) return@lazy ChangesEither.Unknown() + + val dirtyLookupSymbols = HashSet() + val dirtyClassesFqNames = HashSet() + for ((_, isIncremental, dirtyData) in newDiffs) { + if (!isIncremental) return@lazy ChangesEither.Unknown() + + dirtyLookupSymbols.addAll(dirtyData.dirtyLookupSymbols) + dirtyClassesFqNames.addAll(dirtyData.dirtyClassesFqNames) + } + + markDirtyBy(dirtyLookupSymbols) + markDirtyBy(dirtyClassesFqNames) + ChangesEither.Known(dirtyLookupSymbols, dirtyClassesFqNames) + } + val friendDirs = args.friendPaths?.map { File(it) } ?: emptyList() + for (file in changedFiles.removed.asSequence() + changedFiles.modified.asSequence()) { + if (!file.isClassFile()) continue + + val isFriendClassFile = friendDirs.any { FileUtil.isAncestor(it, file, false) } + if (isFriendClassFile && changesFromFriend is ChangesEither.Known) continue + + return CompilationMode.Rebuild { "Cannot get changes from modified or removed class file: ${reporter.pathsAsString(file)}" } + } val classpathSet = args.classpathAsList.toHashSet() val modifiedClasspathEntries = changedFiles.modified.filter { it in classpathSet } - val lastBuildInfo = BuildInfo.read(lastBuildInfoFile) - reporter.report { "Last Kotlin Build info -- $lastBuildInfo" } val classpathChanges = getClasspathChanges(modifiedClasspathEntries, lastBuildInfo) if (classpathChanges !is ChangesEither.Known) { return CompilationMode.Rebuild { "could not get changes from modified classpath entries: ${reporter.pathsAsString(modifiedClasspathEntries)}" } @@ -131,21 +176,9 @@ class IncrementalJvmCompilerRunner( is ChangesEither.Unknown -> return CompilationMode.Rebuild { "Could not get changes for java files" } } - val dirtyFiles = getDirtyFiles(changedFiles) - val lookupSymbols = HashSet() - lookupSymbols.addAll(affectedJavaSymbols) - lookupSymbols.addAll(classpathChanges.lookupSymbols) - - if (lookupSymbols.any()) { - val dirtyFilesFromLookups = mapLookupSymbolsToFiles(caches.lookupCache, lookupSymbols, reporter) - dirtyFiles.addAll(dirtyFilesFromLookups) - } - - val dirtyClassesFqNames = classpathChanges.fqNames.flatMap { withSubtypes(it, listOf(caches.platformCache)) } - if (dirtyClassesFqNames.any()) { - val dirtyFilesFromFqNames = mapClassesFqNamesToFiles(listOf(caches.platformCache), dirtyClassesFqNames, reporter) - dirtyFiles.addAll(dirtyFilesFromFqNames) - } + markDirtyBy(affectedJavaSymbols) + markDirtyBy(classpathChanges.lookupSymbols) + markDirtyBy(classpathChanges.fqNames) return CompilationMode.Incremental(dirtyFiles) } @@ -263,6 +296,23 @@ class IncrementalJvmCompilerRunner( override fun additionalDirtyLookupSymbols(): Iterable = javaFilesProcessor.allChangedSymbols + override fun processChangesAfterBuild(compilationMode: CompilationMode, currentBuildInfo: BuildInfo, dirtyData: DirtyData) { + super.processChangesAfterBuild(compilationMode, currentBuildInfo, dirtyData) + + if (buildHistoryFile == null) return + + val prevDiffs = BuildDiffsStorage.readFromFile(buildHistoryFile, reporter)?.buildDiffs ?: emptyList() + val newDiff = if (compilationMode is CompilationMode.Incremental) { + BuildDifference(currentBuildInfo.startTS, true, dirtyData) + } + else { + val emptyDirtyData = DirtyData() + BuildDifference(currentBuildInfo.startTS, false, emptyDirtyData) + } + + BuildDiffsStorage.writeToFile(buildHistoryFile, BuildDiffsStorage(prevDiffs + newDiff), reporter) + } + override fun makeServices( args: K2JVMCompilerArguments, lookupTracker: LookupTracker, diff --git a/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/BuildDiffsStorageTest.kt b/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/BuildDiffsStorageTest.kt new file mode 100644 index 00000000000..66f34b3d09a --- /dev/null +++ b/compiler/incremental-compilation-impl/test/org/jetbrains/kotlin/incremental/BuildDiffsStorageTest.kt @@ -0,0 +1,102 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.incremental + +import org.jetbrains.kotlin.name.FqName +import org.junit.After +import org.junit.Assert +import org.junit.Before +import org.junit.Test +import java.io.File +import java.io.OutputStream +import java.util.* + +class BuildDiffsStorageTest { + lateinit var storageFile: File + private val random = Random(System.currentTimeMillis()) + + @Before + fun setUp() { + storageFile = File.createTempFile("BuildDiffsStorageTest", "storage") + } + + @After + fun tearDown() { + storageFile.delete() + } + + @Test + fun testToString() { + val lookupSymbols = listOf(LookupSymbol("foo", "bar")) + val fqNames = listOf(FqName("fizz.Buzz")) + val diff = BuildDifference(100, true, DirtyData(lookupSymbols, fqNames)) + val diffs = BuildDiffsStorage(listOf(diff)) + Assert.assertEquals("BuildDiffsStorage(buildDiffs=[BuildDifference(ts=100, isIncremental=true, dirtyData=DirtyData(dirtyLookupSymbols=[LookupSymbol(name=foo, scope=bar)], dirtyClassesFqNames=[fizz.Buzz]))])", + diffs.toString()) + } + + @Test + fun writeReadSimple() { + val diffs = BuildDiffsStorage(listOf(getRandomDiff())) + BuildDiffsStorage.writeToFile(storageFile, diffs, reporter = null) + + val diffsDeserialized = BuildDiffsStorage.readFromFile(storageFile, reporter = null) + Assert.assertEquals(diffs.toString(), diffsDeserialized.toString()) + } + + @Test + fun writeReadMany() { + val generated = Array(20) { getRandomDiff() }.toList() + val diffs = BuildDiffsStorage(generated) + BuildDiffsStorage.writeToFile(storageFile, diffs, reporter = null) + + val diffsDeserialized = BuildDiffsStorage.readFromFile(storageFile, reporter = null) + val expected = generated.sortedBy { it.ts }.takeLast(BuildDiffsStorage.MAX_DIFFS_ENTRIES).toTypedArray() + Assert.assertArrayEquals(expected, diffsDeserialized?.buildDiffs?.toTypedArray()) + } + + @Test + fun readFileNotExist() { + storageFile.delete() + + val diffsDeserialized = BuildDiffsStorage.readFromFile(storageFile, reporter = null) + Assert.assertEquals(null, diffsDeserialized) + } + + @Test + fun versionChanged() { + val diffs = BuildDiffsStorage(listOf(getRandomDiff())) + BuildDiffsStorage.writeToFile(storageFile, diffs, reporter = null) + + val versionBackup = BuildDiffsStorage.CURRENT_VERSION + try { + BuildDiffsStorage.CURRENT_VERSION++ + val diffsDeserialized = BuildDiffsStorage.readFromFile(storageFile, reporter = null) + Assert.assertEquals(null, diffsDeserialized) + } + finally { + BuildDiffsStorage.CURRENT_VERSION = versionBackup + } + } + + private fun getRandomDiff(): BuildDifference { + val ts = random.nextLong() + val lookupSymbols = listOf(LookupSymbol("foo", "bar")) + val fqNames = listOf(FqName("fizz.Buzz")) + return BuildDifference(ts, true, DirtyData(lookupSymbols, fqNames)) + } +} \ No newline at end of file diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/elements/lightAnnotations.kt b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/elements/lightAnnotations.kt index 8844bd063f5..036ff13a5df 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/elements/lightAnnotations.kt +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/elements/lightAnnotations.kt @@ -183,7 +183,13 @@ class KtLightAnnotationForSourceEntry( private val _initializers by lazyPub { delegate.initializers.mapIndexed { i, it -> wrapAnnotationValue(it, this, { - (originalExpression as KtCallElement).valueArguments[i].getArgumentExpression()!! + originalExpression.let { + when (it) { + is KtCallElement -> it.valueArguments[i].getArgumentExpression()!! + is KtCollectionLiteralExpression -> it.getInnerExpressions()[i] + else -> throw UnsupportedOperationException("cant process $it of type ${it?.javaClass}") + } + } }) }.toTypedArray() } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/KotlinCallResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/KotlinCallResolver.kt index 12d4457ddc9..3326fc6d30e 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/KotlinCallResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/KotlinCallResolver.kt @@ -55,11 +55,11 @@ class KotlinCallResolver( } if (collectAllCandidates) { - val allCandidates = towerResolver.collectAllCandidates(scopeTower, processor) + val allCandidates = towerResolver.collectAllCandidates(scopeTower, processor, kotlinCall.name) return kotlinCallCompleter.createAllCandidatesResult(allCandidates, expectedType, resolutionCallbacks) } - val candidates = towerResolver.runResolve(scopeTower, processor, useOrder = kotlinCall.callKind != KotlinCallKind.UNSUPPORTED) + val candidates = towerResolver.runResolve(scopeTower, processor, useOrder = kotlinCall.callKind != KotlinCallKind.UNSUPPORTED, name = kotlinCall.name) return choseMostSpecific(candidateFactory, resolutionCallbacks, expectedType, candidates) } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolver.kt index c53ca974002..35e5496f9d3 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolver.kt @@ -115,7 +115,7 @@ class CallableReferenceResolver( ): Set { val factory = CallableReferencesCandidateFactory(callableReference, callComponents, scopeTower, compatibilityChecker, expectedType) val processor = createCallableReferenceProcessor(factory) - val candidates = towerResolver.runResolve(scopeTower, processor, useOrder = true) + val candidates = towerResolver.runResolve(scopeTower, processor, useOrder = true, name = callableReference.rhsName) return callableReferenceOverloadConflictResolver.chooseMaximallySpecificCandidates( candidates, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ImplicitScopeTower.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ImplicitScopeTower.kt index 7f0d0baa6c9..4838ce435ac 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ImplicitScopeTower.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ImplicitScopeTower.kt @@ -50,6 +50,8 @@ interface ScopeTowerLevel { fun getObjects(name: Name, extensionReceiver: ReceiverValueWithSmartCastInfo?): Collection fun getFunctions(name: Name, extensionReceiver: ReceiverValueWithSmartCastInfo?): Collection + + fun recordLookup(name: Name) } interface CandidateWithBoundDispatchReceiver { diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/InvokeProcessors.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/InvokeProcessors.kt index ac68d186966..15211751e74 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/InvokeProcessors.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/InvokeProcessors.kt @@ -27,41 +27,54 @@ import java.util.* abstract class AbstractInvokeTowerProcessor( protected val factoryProviderForInvoke: CandidateFactoryProviderForInvoke, - private val variableProcessor: ScopeTowerProcessor + protected val variableProcessor: ScopeTowerProcessor ) : ScopeTowerProcessor { // todo optimize it private val previousData = ArrayList() private val invokeProcessors: MutableList> = ArrayList() - private inner class VariableInvokeProcessor(val variableCandidate: C): ScopeTowerProcessor { - val invokeProcessor: ScopeTowerProcessor = createInvokeProcessor(variableCandidate) + protected fun hasInvokeProcessors() = invokeProcessors.isNotEmpty() + + private inner class VariableInvokeProcessor( + var variableCandidate: C, + val invokeProcessor: ScopeTowerProcessor + ): ScopeTowerProcessor { override fun process(data: TowerData) = invokeProcessor.process(data).map { candidateGroup -> candidateGroup.map { factoryProviderForInvoke.transformCandidate(variableCandidate, it) } } + + override fun recordLookups(skippedData: Collection, name: Name) { + invokeProcessor.recordLookups(skippedData, name) + } } - protected abstract fun createInvokeProcessor(variableCandidate: C): ScopeTowerProcessor + private fun createVariableInvokeProcessor(variableCandidate: C): VariableInvokeProcessor? = + createInvokeProcessor(variableCandidate)?.let { VariableInvokeProcessor(variableCandidate, it) } + + protected abstract fun createInvokeProcessor(variableCandidate: C): ScopeTowerProcessor? + + protected abstract fun mayDataBeApplicable(data: TowerData): Boolean override fun process(data: TowerData): List> { - previousData.add(data) val candidateGroups = ArrayList>(0) - for (processorsGroup in invokeProcessors) { - candidateGroups.addAll(processorsGroup.processVariableGroup(data)) + if (mayDataBeApplicable(data)) { + previousData.add(data) + for (processorsGroup in invokeProcessors) { + candidateGroups.addAll(processorsGroup.processVariableGroup(data)) + } } for (variableCandidates in variableProcessor.process(data)) { - val successfulVariables = variableCandidates.filter { - it.isSuccessful + val variableProcessors = variableCandidates.mapNotNull { + if (it.isSuccessful) createVariableInvokeProcessor(it) else null } - if (successfulVariables.isNotEmpty()) { - val variableProcessors = successfulVariables.map { VariableInvokeProcessor(it) } + if (variableProcessors.isNotEmpty()) { invokeProcessors.add(variableProcessors) - for (oldData in previousData) { candidateGroups.addAll(variableProcessors.processVariableGroup(oldData)) } @@ -95,11 +108,25 @@ class InvokeTowerProcessor( ) { // todo filter by operator - override fun createInvokeProcessor(variableCandidate: C): ScopeTowerProcessor { + override fun createInvokeProcessor(variableCandidate: C): ScopeTowerProcessor? { val (variableReceiver, invokeContext) = factoryProviderForInvoke.factoryForInvoke(variableCandidate, useExplicitReceiver = false) - ?: return KnownResultProcessor(emptyList()) + ?: return null return ExplicitReceiverScopeTowerProcessor(scopeTower, invokeContext, variableReceiver) { getFunctions(OperatorNameConventions.INVOKE, it) } } + + override fun mayDataBeApplicable(data: TowerData) = + data == TowerData.Empty || data is TowerData.TowerLevel + + override fun recordLookups(skippedData: Collection, name: Name) { + variableProcessor.recordLookups(skippedData, name) + if (!hasInvokeProcessors()) return + + skippedData.forEach { + if (it is TowerData.TowerLevel) { + it.level.recordLookup(OperatorNameConventions.INVOKE) + } + } + } } class InvokeExtensionTowerProcessor( @@ -112,13 +139,19 @@ class InvokeExtensionTowerProcessor( createVariableAndObjectProcessor(scopeTower, name, factoryProviderForInvoke.factoryForVariable(stripExplicitReceiver = true), explicitReceiver = null) ) { - override fun createInvokeProcessor(variableCandidate: C): ScopeTowerProcessor { + override fun createInvokeProcessor(variableCandidate: C): ScopeTowerProcessor? { val (variableReceiver, invokeContext) = factoryProviderForInvoke.factoryForInvoke(variableCandidate, useExplicitReceiver = true) - ?: return KnownResultProcessor(emptyList()) + ?: return null val invokeDescriptor = scopeTower.getExtensionInvokeCandidateDescriptor(variableReceiver) - ?: return KnownResultProcessor(emptyList()) + ?: return null return InvokeExtensionScopeTowerProcessor(invokeContext, invokeDescriptor, explicitReceiver) } + + override fun mayDataBeApplicable(data: TowerData): Boolean = data == TowerData.Empty || data is TowerData.OnlyImplicitReceiver + + override fun recordLookups(skippedData: Collection, name: Name) { + variableProcessor.recordLookups(skippedData, name) + } } private class InvokeExtensionScopeTowerProcessor( @@ -138,6 +171,9 @@ private class InvokeExtensionScopeTowerProcessor( return emptyList() } + + // No lookups happen in `simpleProcess` + override fun recordLookups(skippedData: Collection, name: Name) {} } // todo debug info diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerProcessors.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerProcessors.kt index 84320fc7506..e20cc7c0c37 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerProcessors.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/ScopeTowerProcessors.kt @@ -28,6 +28,8 @@ class KnownResultProcessor( ): ScopeTowerProcessor { override fun process(data: TowerData) = if (data == TowerData.Empty) listOfNotNull(result.takeIf { it.isNotEmpty() }) else emptyList() + + override fun recordLookups(skippedData: Collection, name: Name) {} } // use this if processors priority is important @@ -35,6 +37,11 @@ class PrioritizedCompositeScopeTowerProcessor( vararg val processors: ScopeTowerProcessor ) : ScopeTowerProcessor { override fun process(data: TowerData): List> = processors.flatMap { it.process(data) } + + override fun recordLookups(skippedData: Collection, name: Name) { + processors.forEach { it.recordLookups(skippedData, name) } + } + } // use this if all processors has same priority @@ -42,6 +49,10 @@ class SamePriorityCompositeScopeTowerProcessor( private vararg val processors: SimpleScopeTowerProcessor ): SimpleScopeTowerProcessor { override fun simpleProcess(data: TowerData): Collection = processors.flatMap { it.simpleProcess(data) } + override fun recordLookups(skippedData: Collection, name: Name) { + processors.forEach { it.recordLookups(skippedData, name) } + } + } internal abstract class AbstractSimpleScopeTowerProcessor( @@ -84,6 +95,14 @@ internal class ExplicitReceiverScopeTowerProcessor( } return extensions } + + override fun recordLookups(skippedData: Collection, name: Name) { + for (data in skippedData) { + if (data is TowerData.TowerLevel) { + data.level.recordLookup(name) + } + } + } } private class QualifierScopeTowerProcessor( @@ -103,6 +122,9 @@ private class QualifierScopeTowerProcessor( } return staticMembers } + + // QualifierScopeTowerProcessor works only with TowerData.Empty that should not be ignored + override fun recordLookups(skippedData: Collection, name: Name) {} } private class NoExplicitReceiverScopeTowerProcessor( @@ -132,6 +154,15 @@ private class NoExplicitReceiverScopeTowerProcessor( else -> emptyList() } + override fun recordLookups(skippedData: Collection, name: Name) { + for (data in skippedData) { + when (data) { + is TowerData.TowerLevel -> data.level.recordLookup(name) + is TowerData.BothTowerLevelAndImplicitReceiver -> data.level.recordLookup(name) + is TowerData.ForLookupForNoExplicitReceiver -> data.level.recordLookup(name) + } + } + } } private fun createSimpleProcessorWithoutClassValueReceiver( diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt index cee2f639914..a1bae96f1be 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt @@ -169,6 +169,13 @@ internal class MemberScopeTowerLevel( syntheticScopes.collectSyntheticMemberFunctions(listOfNotNull(it), name, location) } } + + override fun recordLookup(name: Name) { + dispatchReceiver.receiverValue.type.memberScope.recordLookup(name, location) + dispatchReceiver.possibleTypes.forEach { + it.memberScope.recordLookup(name, location) + } + } } internal class QualifierScopeTowerLevel(scopeTower: ImplicitScopeTower, val qualifier: QualifierReceiver) : AbstractScopeTowerLevel(scopeTower) { @@ -189,6 +196,8 @@ internal class QualifierScopeTowerLevel(scopeTower: ImplicitScopeTower, val qual qualifier.staticScope).map { createCandidateDescriptor(it, dispatchReceiver = null) } + + override fun recordLookup(name: Name) {} } // KT-3335 Creating imported super class' inner class fails in codegen @@ -216,6 +225,10 @@ internal open class ScopeBasedTowerLevel protected constructor( resolutionScope).map { createCandidateDescriptor(it, dispatchReceiver = null) } + + override fun recordLookup(name: Name) { + resolutionScope.recordLookup(name, location) + } } internal class ImportingScopeBasedTowerLevel( scopeTower: ImplicitScopeTower, @@ -247,6 +260,10 @@ internal class SyntheticScopeBasedTowerLevel( extensionReceiver: ReceiverValueWithSmartCastInfo? ): Collection = emptyList() + + override fun recordLookup(name: Name) { + + } } internal class HidesMembersTowerLevel(scopeTower: ImplicitScopeTower): AbstractScopeTowerLevel(scopeTower) { @@ -272,6 +289,8 @@ internal class HidesMembersTowerLevel(scopeTower: ImplicitScopeTower): AbstractS createCandidateDescriptor(it, dispatchReceiver = null) } } + + override fun recordLookup(name: Name) {} } private fun KotlinType.getClassifierFromMeAndSuperclasses(name: Name, location: LookupLocation): ClassifierDescriptor? { diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt index b97fac2e46b..e7db86f3494 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerResolver.kt @@ -16,12 +16,18 @@ package org.jetbrains.kotlin.resolve.calls.tower +import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind +import org.jetbrains.kotlin.resolve.descriptorUtil.HIDES_MEMBERS_NAME_LIST import org.jetbrains.kotlin.resolve.scopes.ImportingScope import org.jetbrains.kotlin.resolve.scopes.LexicalScope +import org.jetbrains.kotlin.resolve.scopes.ResolutionScope import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo import org.jetbrains.kotlin.resolve.scopes.utils.parentsWithSelf +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.isDynamic +import org.jetbrains.kotlin.util.OperatorNameConventions import java.util.* interface Candidate { @@ -56,12 +62,16 @@ sealed class TowerData { class OnlyImplicitReceiver(val implicitReceiver: ReceiverValueWithSmartCastInfo): TowerData() class TowerLevel(val level: ScopeTowerLevel) : TowerData() class BothTowerLevelAndImplicitReceiver(val level: ScopeTowerLevel, val implicitReceiver: ReceiverValueWithSmartCastInfo) : TowerData() + // Has the same meaning as BothTowerLevelAndImplicitReceiver, but it's only used for names lookup, so it doesn't need implicit receiver + class ForLookupForNoExplicitReceiver(val level: ScopeTowerLevel) : TowerData() } interface ScopeTowerProcessor { // Candidates with matched receivers (dispatch receiver was already matched in ScopeTowerLevel) // Candidates in one groups have same priority, first group has highest priority. fun process(data: TowerData): List> + + fun recordLookups(skippedData: Collection, name: Name) } interface SimpleScopeTowerProcessor : ScopeTowerProcessor { @@ -74,103 +84,183 @@ class TowerResolver { fun runResolve( scopeTower: ImplicitScopeTower, processor: ScopeTowerProcessor, - useOrder: Boolean - ): Collection = scopeTower.run(processor, SuccessfulResultCollector(), useOrder) + useOrder: Boolean, + name: Name + ): Collection = scopeTower.run(processor, SuccessfulResultCollector(), useOrder, name) fun collectAllCandidates( scopeTower: ImplicitScopeTower, - processor: ScopeTowerProcessor + processor: ScopeTowerProcessor, + name: Name ): Collection - = scopeTower.run(processor, AllCandidatesCollector(), false) + = scopeTower.run(processor, AllCandidatesCollector(), false, name) - private fun ImplicitScopeTower.createNonLocalLevels(): List { - val result = ArrayList() - - lexicalScope.parentsWithSelf.forEach { scope -> - if (scope is LexicalScope) { - if (!scope.kind.withLocalDescriptors) result.add(ScopeBasedTowerLevel(this, scope)) - - getImplicitReceiver(scope)?.let { result.add(MemberScopeTowerLevel(this, it)) } - } - else { - result.add(ImportingScopeBasedTowerLevel(this, scope as ImportingScope)) - } - } - - return result - } - - private fun ImplicitScopeTower.run( + fun ImplicitScopeTower.run( processor: ScopeTowerProcessor, resultCollector: ResultCollector, - useOrder: Boolean - ): Collection { - fun TowerData.process() = processTowerData(processor, resultCollector, useOrder, this) + useOrder: Boolean, + name: Name + ): Collection = Task(this, processor, resultCollector, useOrder, name).run() - val localLevels = lexicalScope.parentsWithSelf. - filterIsInstance().filter { it.kind.withLocalDescriptors }. - map { ScopeBasedTowerLevel(this@run, it) } + private inner class Task( + private val implicitScopeTower: ImplicitScopeTower, + private val processor: ScopeTowerProcessor, + private val resultCollector: ResultCollector, + private val useOrder: Boolean, + private val name: Name + ) { + private val isNameForHidesMember = name in HIDES_MEMBERS_NAME_LIST + private val skippedDataForLookup = mutableListOf() - // Lazy calculation - var nonLocalLevels: Collection? = null - val hidesMembersLevel = HidesMembersTowerLevel(this) - val syntheticLevel = SyntheticScopeBasedTowerLevel(this, syntheticScopes) - - // hides members extensions for explicit receiver - TowerData.TowerLevel(hidesMembersLevel).process()?.let { return it } - // possibly there is explicit member - TowerData.Empty.process()?.let { return it } - // synthetic property for explicit receiver - TowerData.TowerLevel(syntheticLevel).process()?.let { return it } - - // local non-extensions or extension for explicit receiver - for (localLevel in localLevels) { - TowerData.TowerLevel(localLevel).process()?.let { return it } + private val localLevels: Collection by lazy(LazyThreadSafetyMode.NONE) { + implicitScopeTower.lexicalScope.parentsWithSelf. + filterIsInstance().filter { it.kind.withLocalDescriptors && it.mayFitForName(name) }. + map { ScopeBasedTowerLevel(implicitScopeTower, it) }.toList() } - for (scope in lexicalScope.parentsWithSelf) { - if (scope is LexicalScope) { - // statics - if (!scope.kind.withLocalDescriptors) { - TowerData.TowerLevel(ScopeBasedTowerLevel(this, scope)).process()?.let { return it } - } - - val implicitReceiver = getImplicitReceiver(scope) - if (implicitReceiver != null) { - // hides members extensions - TowerData.BothTowerLevelAndImplicitReceiver(hidesMembersLevel, implicitReceiver).process()?.let { return it } - - // members of implicit receiver or member extension for explicit receiver - TowerData.TowerLevel(MemberScopeTowerLevel(this, implicitReceiver)).process()?.let { return it } - - // synthetic properties - TowerData.BothTowerLevelAndImplicitReceiver(syntheticLevel, implicitReceiver).process()?.let { return it } - - // invokeExtension on local variable - TowerData.OnlyImplicitReceiver(implicitReceiver).process()?.let { return it } - - // local extensions for implicit receiver - for (localLevel in localLevels) { - TowerData.BothTowerLevelAndImplicitReceiver(localLevel, implicitReceiver).process()?.let { return it } - } - - // extension for implicit receiver - if (nonLocalLevels == null) { - nonLocalLevels = createNonLocalLevels() - } - - for (nonLocalLevel in nonLocalLevels) { - TowerData.BothTowerLevelAndImplicitReceiver(nonLocalLevel, implicitReceiver).process()?.let { return it } - } - } - } - else { - // functions with no receiver or extension for explicit receiver - TowerData.TowerLevel(ImportingScopeBasedTowerLevel(this, scope as ImportingScope)).process()?.let { return it } - } + private val nonLocalLevels: Collection by lazy(LazyThreadSafetyMode.NONE) { + implicitScopeTower.createNonLocalLevels() } - return resultCollector.getFinalCandidates() + val hidesMembersLevel = HidesMembersTowerLevel(implicitScopeTower) + val syntheticLevel = SyntheticScopeBasedTowerLevel(implicitScopeTower, implicitScopeTower.syntheticScopes) + + private fun ImplicitScopeTower.createNonLocalLevels(): Collection { + val mainResult = mutableListOf() + + fun addLevel(scopeTowerLevel: ScopeTowerLevel, mayFitForName: Boolean) { + if (mayFitForName) { + mainResult.add(scopeTowerLevel) + } + else { + skippedDataForLookup.add(TowerData.ForLookupForNoExplicitReceiver(scopeTowerLevel)) + } + } + + lexicalScope.parentsWithSelf.forEach { scope -> + if (scope is LexicalScope) { + if (!scope.kind.withLocalDescriptors) { + addLevel( + ScopeBasedTowerLevel(this@createNonLocalLevels, scope), + scope.mayFitForName(name) + ) + } + + getImplicitReceiver(scope)?.let { + addLevel( + MemberScopeTowerLevel(this@createNonLocalLevels, it), + it.mayFitForName(name) + ) + } + } + else { + addLevel( + ImportingScopeBasedTowerLevel(this@createNonLocalLevels, scope as ImportingScope), + scope.mayFitForName(name) + ) + } + } + + return mainResult + } + + private fun TowerData.process() = processTowerData(processor, resultCollector, useOrder, this)?.also { + recordLookups() + } + + private fun TowerData.process(mayFitForName: Boolean): Collection? { + if (!mayFitForName) { + skippedDataForLookup.add(this) + return null + } + return process() + } + + fun run(): Collection { + if (isNameForHidesMember) { + // hides members extensions for explicit receiver + TowerData.TowerLevel(hidesMembersLevel).process()?.let { return it } + } + + // possibly there is explicit member + TowerData.Empty.process()?.let { return it } + // synthetic property for explicit receiver + TowerData.TowerLevel(syntheticLevel).process()?.let { return it } + + // local non-extensions or extension for explicit receiver + for (localLevel in localLevels) { + TowerData.TowerLevel(localLevel).process()?.let { return it } + } + + for (scope in implicitScopeTower.lexicalScope.parentsWithSelf) { + if (scope is LexicalScope) { + // statics + if (!scope.kind.withLocalDescriptors) { + TowerData.TowerLevel(ScopeBasedTowerLevel(implicitScopeTower, scope)) + .process(scope.mayFitForName(name))?.let { return it } + } + + implicitScopeTower.getImplicitReceiver(scope) + ?.let(this::processImplicitReceiver) + ?.let { return it } + } + else { + TowerData.TowerLevel(ImportingScopeBasedTowerLevel(implicitScopeTower, scope as ImportingScope)) + .process(scope.mayFitForName(name))?.let { return it } + } + } + + recordLookups() + + return resultCollector.getFinalCandidates() + } + + private fun processImplicitReceiver(implicitReceiver: ReceiverValueWithSmartCastInfo): Collection? { + if (isNameForHidesMember) { + // hides members extensions + TowerData.BothTowerLevelAndImplicitReceiver(hidesMembersLevel, implicitReceiver).process()?.let { return it } + } + + // members of implicit receiver or member extension for explicit receiver + TowerData.TowerLevel(MemberScopeTowerLevel(implicitScopeTower, implicitReceiver)) + .process(implicitReceiver.mayFitForName(name))?.let { return it } + + // synthetic properties + TowerData.BothTowerLevelAndImplicitReceiver(syntheticLevel, implicitReceiver).process()?.let { return it } + + // invokeExtension on local variable + TowerData.OnlyImplicitReceiver(implicitReceiver).process()?.let { return it } + + // local extensions for implicit receiver + for (localLevel in localLevels) { + TowerData.BothTowerLevelAndImplicitReceiver(localLevel, implicitReceiver).process()?.let { return it } + } + + // extension for implicit receiver + for (nonLocalLevel in nonLocalLevels) { + TowerData.BothTowerLevelAndImplicitReceiver(nonLocalLevel, implicitReceiver).process()?.let { return it } + } + + return null + } + + private fun recordLookups() { + processor.recordLookups(skippedDataForLookup, name) + } + + private fun ReceiverValueWithSmartCastInfo.mayFitForName(name: Name): Boolean { + if (receiverValue.type.mayFitForName(name)) return true + if (possibleTypes.isEmpty()) return false + return possibleTypes.any { it.mayFitForName(name) } + } + + private fun KotlinType.mayFitForName(name: Name) = + isDynamic() || + !memberScope.definitelyDoesNotContainName(name) || + !memberScope.definitelyDoesNotContainName(OperatorNameConventions.INVOKE) + + private fun ResolutionScope.mayFitForName(name: Name) = + !definitelyDoesNotContainName(name) || !definitelyDoesNotContainName(OperatorNameConventions.INVOKE) } fun runWithEmptyTowerData( @@ -234,7 +324,7 @@ class TowerResolver { val firstGroupWithResolved = candidateGroups.firstOrNull { it.any { it.resultingApplicability == ResolutionCandidateApplicability.RESOLVED } } ?: return null - + return firstGroupWithResolved.filter { it.resultingApplicability == ResolutionCandidateApplicability.RESOLVED } } @@ -261,8 +351,8 @@ class TowerResolver { return moreSuitableGroup.filter { it.resultingApplicability == groupApplicability } } - - private val Collection.groupApplicability get() = - minBy { it.resultingApplicability }?.resultingApplicability ?: ResolutionCandidateApplicability.HIDDEN + + private val Collection.groupApplicability get() = + minBy { it.resultingApplicability }?.resultingApplicability ?: ResolutionCandidateApplicability.HIDDEN } } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt index c4102719b4c..f2e67b63155 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/LexicalScopeStorage.kt @@ -124,4 +124,7 @@ abstract class LexicalScopeStorage( } while (rest != null) return result } + + override fun definitelyDoesNotContainName(name: Name) = + functionsByName?.get(name) == null && variablesAndClassifiersByName?.get(name) == null } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt index 2c4ed9ece15..8d84419555b 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt @@ -55,6 +55,8 @@ interface LexicalScope : HierarchicalScope { override val kind: LexicalScopeKind get() = LexicalScopeKind.EMPTY + override fun definitelyDoesNotContainName(name: Name) = true + override fun printStructure(p: Printer) { p.println("Base lexical scope with owner = $ownerDescriptor and parent = $parent") } @@ -119,10 +121,16 @@ interface ImportingScope : HierarchicalScope { return getContributedDescriptors(kindFilter, nameFilter, changeNamesForAliased = false) } + fun computeImportedNames(): Set? + object Empty : BaseImportingScope(null) { override fun printStructure(p: Printer) { p.println("ImportingScope.Empty") } + + override fun computeImportedNames() = emptySet() + + override fun definitelyDoesNotContainName(name: Name) = true } } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/SubpackagesImportingScope.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/SubpackagesImportingScope.kt index 6590af831e1..ac0db8a37df 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/SubpackagesImportingScope.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/SubpackagesImportingScope.kt @@ -48,4 +48,5 @@ class SubpackagesImportingScope( //TODO: kept old behavior, but it seems very strange (super call seems more applicable) override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean, changeNamesForAliased: Boolean): Collection = emptyList() + override fun computeImportedNames() = emptySet() } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt index adf068a4785..7eb021a35ff 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt @@ -122,6 +122,8 @@ private class MemberScopeToImportingScopeAdapter(override val parent: ImportingS override fun toString() = "${this::class.java.simpleName} for $memberScope" + override fun computeImportedNames() = memberScope.computeAllNames() + override fun printStructure(p: Printer) { p.println(this::class.java.simpleName) p.pushIndent() diff --git a/compiler/testData/cfg-variables/basic/ExhaustiveInitialization.instructions b/compiler/testData/cfg-variables/basic/ExhaustiveInitialization.instructions index b6dac5b140b..9bb7fb604e4 100644 --- a/compiler/testData/cfg-variables/basic/ExhaustiveInitialization.instructions +++ b/compiler/testData/cfg-variables/basic/ExhaustiveInitialization.instructions @@ -38,66 +38,66 @@ fun foo(dir: Direction): Int { --------------------- L0: 1 INIT: in: {} out: {} - v(dir: Direction) INIT: in: {} out: {dir=D} - magic[FAKE_INITIALIZER](dir: Direction) -> INIT: in: {dir=D} out: {dir=D} - w(dir|) INIT: in: {dir=D} out: {dir=ID} USE: in: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, dir=READ} out: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, dir=READ} - 2 mark({ val res: Int when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 } return res }) INIT: in: {dir=ID} out: {dir=ID} - v(val res: Int) INIT: in: {dir=ID} out: {dir=ID, res=D} - mark(when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }) INIT: in: {dir=ID, res=D} out: {dir=ID, res=D} USE: in: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, dir=READ, res=READ} out: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, dir=READ, res=READ} - r(dir) -> USE: in: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, res=READ} out: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, dir=READ, res=READ} + v(dir: Direction) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](dir: Direction) -> INIT: in: {} out: {} + w(dir|) INIT: in: {} out: {} USE: in: {} out: {} + 2 mark({ val res: Int when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 } return res }) INIT: in: {} out: {} + v(val res: Int) INIT: in: {} out: {res=D} + mark(when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }) INIT: in: {res=D} out: {res=D} + r(dir) -> mark(Direction.NORTH -> res = 1) mark(Direction.NORTH) - mark(Direction.NORTH) USE: in: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, res=READ} out: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, res=READ} - r(NORTH) -> USE: in: {EAST=READ, SOUTH=READ, WEST=READ, res=READ} out: {EAST=READ, NORTH=READ, SOUTH=READ, WEST=READ, res=READ} + mark(Direction.NORTH) + r(NORTH) -> magic[EQUALS_IN_WHEN_CONDITION](Direction.NORTH|, ) -> - jmp?(L4|) USE: in: {EAST=READ, SOUTH=READ, WEST=READ, res=READ} out: {EAST=READ, SOUTH=READ, WEST=READ, res=READ} + jmp?(L4|) USE: in: {res=READ} out: {res=READ} L3 ['when' entry body]: - r(1) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} - w(res|) INIT: in: {dir=ID, res=D} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} - jmp(L2) INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=READ} + r(1) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} + w(res|) INIT: in: {res=D} out: {res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} + jmp(L2) INIT: in: {res=ID} out: {res=ID} L4 [next 'when' entry]: - mark(Direction.SOUTH -> res = 2) INIT: in: {dir=ID, res=D} out: {dir=ID, res=D} + mark(Direction.SOUTH -> res = 2) INIT: in: {res=D} out: {res=D} mark(Direction.SOUTH) - mark(Direction.SOUTH) USE: in: {EAST=READ, SOUTH=READ, WEST=READ, res=READ} out: {EAST=READ, SOUTH=READ, WEST=READ, res=READ} - r(SOUTH) -> USE: in: {EAST=READ, WEST=READ, res=READ} out: {EAST=READ, SOUTH=READ, WEST=READ, res=READ} + mark(Direction.SOUTH) + r(SOUTH) -> magic[EQUALS_IN_WHEN_CONDITION](Direction.SOUTH|, ) -> - jmp?(L6|) USE: in: {EAST=READ, WEST=READ, res=READ} out: {EAST=READ, WEST=READ, res=READ} + jmp?(L6|) USE: in: {res=READ} out: {res=READ} L5 ['when' entry body]: - r(2) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} - w(res|) INIT: in: {dir=ID, res=D} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} - jmp(L2) INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=READ} + r(2) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} + w(res|) INIT: in: {res=D} out: {res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} + jmp(L2) INIT: in: {res=ID} out: {res=ID} L6 [next 'when' entry]: - mark(Direction.WEST -> res = 3) INIT: in: {dir=ID, res=D} out: {dir=ID, res=D} + mark(Direction.WEST -> res = 3) INIT: in: {res=D} out: {res=D} mark(Direction.WEST) - mark(Direction.WEST) USE: in: {EAST=READ, WEST=READ, res=READ} out: {EAST=READ, WEST=READ, res=READ} - r(WEST) -> USE: in: {EAST=READ, res=READ} out: {EAST=READ, WEST=READ, res=READ} + mark(Direction.WEST) + r(WEST) -> magic[EQUALS_IN_WHEN_CONDITION](Direction.WEST|, ) -> - jmp?(L8|) USE: in: {EAST=READ, res=READ} out: {EAST=READ, res=READ} + jmp?(L8|) USE: in: {res=READ} out: {res=READ} L7 ['when' entry body]: - r(3) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} - w(res|) INIT: in: {dir=ID, res=D} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} - jmp(L2) INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=READ} + r(3) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} + w(res|) INIT: in: {res=D} out: {res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} + jmp(L2) INIT: in: {res=ID} out: {res=ID} L8 [next 'when' entry]: - mark(Direction.EAST -> res = 4) INIT: in: {dir=ID, res=D} out: {dir=ID, res=D} + mark(Direction.EAST -> res = 4) INIT: in: {res=D} out: {res=D} mark(Direction.EAST) - mark(Direction.EAST) USE: in: {EAST=READ, res=READ} out: {EAST=READ, res=READ} - r(EAST) -> USE: in: {res=READ} out: {EAST=READ, res=READ} + mark(Direction.EAST) + r(EAST) -> magic[EQUALS_IN_WHEN_CONDITION](Direction.EAST|, ) -> - jmp?(L10|) USE: in: {res=READ} out: {res=READ} + jmp?(L10|) USE: in: {res=READ} out: {res=READ} L9 ['when' entry body]: - r(4) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} - w(res|) INIT: in: {dir=ID, res=D} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} - jmp(L2) INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} + r(4) -> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} + w(res|) INIT: in: {res=D} out: {res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} + jmp(L2) INIT: in: {res=ID} out: {res=ID} L10 [next 'when' entry]: - magic[EXHAUSTIVE_WHEN_ELSE](when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }) -> INIT: in: {dir=ID, res=D} out: {dir=ID, res=IED} + magic[EXHAUSTIVE_WHEN_ELSE](when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }) -> INIT: in: {res=D} out: {res=IED} L2 [after 'when' expression]: - merge(when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }|!, !, !, !) -> INIT: in: {dir=ID, res=ID} out: {dir=ID, res=ID} USE: in: {res=READ} out: {res=READ} - r(res) -> USE: in: {} out: {res=READ} + merge(when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }|!, !, !, !) -> INIT: in: {res=ID} out: {res=ID} USE: in: {res=READ} out: {res=READ} + r(res) -> USE: in: {} out: {res=READ} ret(*|) L1 L1: - 1 INIT: in: {dir=ID} out: {dir=ID} + 1 INIT: in: {} out: {} error: - INIT: in: {} out: {} + sink: - INIT: in: {dir=I?} out: {dir=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/basic/IfWithUninitialized.instructions b/compiler/testData/cfg-variables/basic/IfWithUninitialized.instructions index 8fef6c3a2bc..d4606e0ae29 100644 --- a/compiler/testData/cfg-variables/basic/IfWithUninitialized.instructions +++ b/compiler/testData/cfg-variables/basic/IfWithUninitialized.instructions @@ -42,15 +42,15 @@ fun use(vararg a: Any?) = a --------------------- L0: 1 INIT: in: {} out: {} - v(vararg a: Any?) INIT: in: {} out: {a=D} - magic[FAKE_INITIALIZER](vararg a: Any?) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} USE: in: {a=READ} out: {a=READ} - r(a) -> INIT: in: {a=ID} out: {a=ID} USE: in: {} out: {a=READ} + v(vararg a: Any?) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](vararg a: Any?) -> INIT: in: {} out: {} + w(a|) INIT: in: {} out: {} + r(a) -> INIT: in: {} out: {} ret(*|) L1 L1: error: - INIT: in: {} out: {} + sink: - INIT: in: {a=I?} out: {a=I?} USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {} out: {} +===================== diff --git a/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.instructions b/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.instructions index 58677b74e8f..3316e336849 100644 --- a/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.instructions +++ b/compiler/testData/cfg-variables/basic/UsageInFunctionLiteral.instructions @@ -8,24 +8,24 @@ fun foo() { } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {} out: {} + 1 INIT: in: {} out: {} 2 mark({ val a = 1 val f = { x: Int -> val y = x + a use(a) } }) - v(val a = 1) INIT: in: {} out: {a=D} - r(1) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} - v(val f = { x: Int -> val y = x + a use(a) }) INIT: in: {a=ID} out: {a=ID, f=D} - mark({ x: Int -> val y = x + a use(a) }) INIT: in: {a=ID, f=D} out: {a=ID, f=D} + v(val a = 1) INIT: in: {} out: {} + r(1) -> INIT: in: {} out: {} + w(a|) INIT: in: {} out: {} + v(val f = { x: Int -> val y = x + a use(a) }) INIT: in: {} out: {} + mark({ x: Int -> val y = x + a use(a) }) INIT: in: {} out: {} jmp?(L2) - d({ x: Int -> val y = x + a use(a) }) INIT: in: {a=I, f=I?} out: {a=I, f=I?} USE: in: {a=READ} out: {a=READ} + d({ x: Int -> val y = x + a use(a) }) INIT: in: {} out: {} L2 [after local declaration]: - r({ x: Int -> val y = x + a use(a) }) -> INIT: in: {a=ID, f=D} out: {a=ID, f=D} - w(f|) INIT: in: {a=ID, f=D} out: {a=ID, f=ID} + r({ x: Int -> val y = x + a use(a) }) -> + w(f|) INIT: in: {} out: {} L1: 1 INIT: in: {} out: {} error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== == anonymous_0 == { x: Int -> @@ -34,42 +34,42 @@ sink: } --------------------- L3: - 3 INIT: in: {a=ID, f=D} out: {a=ID, f=D} - v(x: Int) INIT: in: {a=ID, f=D} out: {a=ID, f=D, x=D} - magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {a=ID, f=D, x=D} out: {a=ID, f=D, x=D} - w(x|) INIT: in: {a=ID, f=D, x=D} out: {a=ID, f=D, x=ID} - 4 mark(val y = x + a use(a)) INIT: in: {a=ID, f=D, x=ID} out: {a=ID, f=D, x=ID} - v(val y = x + a) INIT: in: {a=ID, f=D, x=ID} out: {a=ID, f=D, x=ID, y=D} USE: in: {a=READ, x=READ} out: {a=READ, x=READ} - r(x) -> INIT: in: {a=ID, f=D, x=ID, y=D} out: {a=ID, f=D, x=ID, y=D} USE: in: {a=READ} out: {a=READ, x=READ} + 3 INIT: in: {} out: {} + v(x: Int) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {} out: {} + w(x|) INIT: in: {} out: {} + 4 mark(val y = x + a use(a)) INIT: in: {} out: {} + v(val y = x + a) INIT: in: {} out: {} + r(x) -> INIT: in: {} out: {} r(a) -> mark(x + a) call(x + a, plus|, ) -> - w(y|) INIT: in: {a=ID, f=D, x=ID, y=D} out: {a=ID, f=D, x=ID, y=ID} USE: in: {a=READ} out: {a=READ} - r(a) -> INIT: in: {a=ID, f=D, x=ID, y=ID} out: {a=ID, f=D, x=ID, y=ID} USE: in: {} out: {a=READ} + w(y|) INIT: in: {} out: {} + r(a) -> INIT: in: {} out: {} mark(use(a)) call(use(a), use|) -> - 3 ret(*|) L4 INIT: in: {a=ID, f=D, x=ID} out: {a=ID, f=D, x=ID} + 3 ret(*|) L4 L4: error: - INIT: in: {} out: {} + sink: - INIT: in: {a=I, f=I?, x=I?} out: {a=I, f=I?, x=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == use == fun use(vararg a: Any?) = a --------------------- L0: 1 INIT: in: {} out: {} - v(vararg a: Any?) INIT: in: {} out: {a=D} - magic[FAKE_INITIALIZER](vararg a: Any?) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} USE: in: {a=READ} out: {a=READ} - r(a) -> INIT: in: {a=ID} out: {a=ID} USE: in: {} out: {a=READ} + v(vararg a: Any?) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](vararg a: Any?) -> INIT: in: {} out: {} + w(a|) INIT: in: {} out: {} + r(a) -> INIT: in: {} out: {} ret(*|) L1 L1: error: - INIT: in: {} out: {} + sink: - INIT: in: {a=I?} out: {a=I?} USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {} out: {} +===================== diff --git a/compiler/testData/cfg-variables/basic/UseUninitializedInLambda.instructions b/compiler/testData/cfg-variables/basic/UseUninitializedInLambda.instructions index db7d08ed818..aadd7c026d2 100644 --- a/compiler/testData/cfg-variables/basic/UseUninitializedInLambda.instructions +++ b/compiler/testData/cfg-variables/basic/UseUninitializedInLambda.instructions @@ -3,19 +3,19 @@ fun bar(f: () -> Unit) = f() --------------------- L0: 1 INIT: in: {} out: {} - v(f: () -> Unit) INIT: in: {} out: {f=D} - magic[FAKE_INITIALIZER](f: () -> Unit) -> INIT: in: {f=D} out: {f=D} - w(f|) INIT: in: {f=D} out: {f=ID} USE: in: {f=READ} out: {f=READ} - r(f) -> INIT: in: {f=ID} out: {f=ID} USE: in: {} out: {f=READ} + v(f: () -> Unit) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](f: () -> Unit) -> INIT: in: {} out: {} + w(f|) INIT: in: {} out: {} + r(f) -> INIT: in: {} out: {} mark(f()) call(f(), invoke|) -> ret(*|) L1 L1: error: - INIT: in: {} out: {} + sink: - INIT: in: {f=I?} out: {f=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == foo == fun foo() { diff --git a/compiler/testData/cfg-variables/basic/VariablesInitialization.instructions b/compiler/testData/cfg-variables/basic/VariablesInitialization.instructions index 50aea77f14f..9d344f7e2dc 100644 --- a/compiler/testData/cfg-variables/basic/VariablesInitialization.instructions +++ b/compiler/testData/cfg-variables/basic/VariablesInitialization.instructions @@ -7,21 +7,21 @@ fun foo() { } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {} out: {} + 1 INIT: in: {} out: {} USE: in: {} out: {} 2 mark({ val a = 1 val b: Int b = 2 42 }) - v(val a = 1) INIT: in: {} out: {a=D} - r(1) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} - v(val b: Int) INIT: in: {a=ID} out: {a=ID, b=D} - r(2) -> INIT: in: {a=ID, b=D} out: {a=ID, b=D} USE: in: {b=ONLY_WRITTEN_NEVER_READ} out: {b=ONLY_WRITTEN_NEVER_READ} - w(b|) INIT: in: {a=ID, b=D} out: {a=ID, b=ID} USE: in: {} out: {b=ONLY_WRITTEN_NEVER_READ} - r(42) -> INIT: in: {a=ID, b=ID} out: {a=ID, b=ID} + v(val a = 1) INIT: in: {} out: {} + r(1) -> INIT: in: {} out: {} + w(a|) INIT: in: {} out: {} + v(val b: Int) INIT: in: {} out: {b=D} + r(2) -> INIT: in: {b=D} out: {b=D} USE: in: {b=ONLY_WRITTEN_NEVER_READ} out: {b=ONLY_WRITTEN_NEVER_READ} + w(b|) INIT: in: {b=D} out: {b=ID} USE: in: {} out: {b=ONLY_WRITTEN_NEVER_READ} + r(42) -> INIT: in: {b=ID} out: {b=ID} L1: 1 INIT: in: {} out: {} error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== == bar == fun bar(foo: Foo) { @@ -32,23 +32,23 @@ fun bar(foo: Foo) { --------------------- L0: 1 INIT: in: {} out: {} - v(foo: Foo) INIT: in: {} out: {foo=D} - magic[FAKE_INITIALIZER](foo: Foo) -> INIT: in: {foo=D} out: {foo=D} - w(foo|) INIT: in: {foo=D} out: {foo=ID} - 2 mark({ foo.c foo.c = 2 42 }) INIT: in: {foo=ID} out: {foo=ID} + v(foo: Foo) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](foo: Foo) -> INIT: in: {} out: {} + w(foo|) INIT: in: {} out: {} + 2 mark({ foo.c foo.c = 2 42 }) INIT: in: {} out: {} mark(foo.c) - r(foo) -> USE: in: {c=READ, foo=READ} out: {c=READ, foo=READ} - r(c|) -> USE: in: {c=ONLY_WRITTEN_NEVER_READ, foo=READ} out: {c=READ, foo=READ} - r(foo) -> USE: in: {c=ONLY_WRITTEN_NEVER_READ} out: {c=ONLY_WRITTEN_NEVER_READ, foo=READ} - r(2) -> USE: in: {c=ONLY_WRITTEN_NEVER_READ} out: {c=ONLY_WRITTEN_NEVER_READ} - w(foo.c|, ) USE: in: {} out: {c=ONLY_WRITTEN_NEVER_READ} + r(foo) -> + r(c|) -> + r(foo) -> + r(2) -> + w(foo.c|, ) r(42) -> L1: 1 error: - INIT: in: {} out: {} + sink: - INIT: in: {foo=I?} out: {foo=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == Foo == interface Foo { @@ -57,11 +57,11 @@ interface Foo { --------------------- L0: 1 INIT: in: {} out: {} - v(var c: Int) INIT: in: {} out: {c=D} + v(var c: Int) INIT: in: {} out: {} L1: - INIT: in: {c=D} out: {c=D} + INIT: in: {} out: {} error: - INIT: in: {} out: {} + sink: - INIT: in: {c=-} out: {c=-} USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/basic/VariablesUsage.instructions b/compiler/testData/cfg-variables/basic/VariablesUsage.instructions index 87940f1b4cf..120ab47ef92 100644 --- a/compiler/testData/cfg-variables/basic/VariablesUsage.instructions +++ b/compiler/testData/cfg-variables/basic/VariablesUsage.instructions @@ -51,15 +51,15 @@ fun use(a: Int) = a --------------------- L0: 1 INIT: in: {} out: {} - v(a: Int) INIT: in: {} out: {a=D} - magic[FAKE_INITIALIZER](a: Int) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} USE: in: {a=READ} out: {a=READ} - r(a) -> INIT: in: {a=ID} out: {a=ID} USE: in: {} out: {a=READ} + v(a: Int) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](a: Int) -> INIT: in: {} out: {} + w(a|) INIT: in: {} out: {} + r(a) -> INIT: in: {} out: {} ret(*|) L1 L1: error: - INIT: in: {} out: {} + sink: - INIT: in: {a=I?} out: {a=I?} USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {} out: {} +===================== diff --git a/compiler/testData/cfg-variables/bugs/initializationInLocalClass.instructions b/compiler/testData/cfg-variables/bugs/initializationInLocalClass.instructions index 6b5f23273a4..0d11c4d3e54 100644 --- a/compiler/testData/cfg-variables/bugs/initializationInLocalClass.instructions +++ b/compiler/testData/cfg-variables/bugs/initializationInLocalClass.instructions @@ -10,18 +10,18 @@ fun foo() { } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {length=READ} out: {length=READ} + 1 INIT: in: {} out: {} USE: in: {} out: {} 2 mark({ var x: String class A { init { x = "" } } x.length }) v(var x: String) INIT: in: {} out: {x=D} - jmp?(L2) INIT: in: {x=D} out: {x=D} USE: in: {length=READ, x=READ} out: {length=READ, x=READ} + jmp?(L2) INIT: in: {x=D} out: {x=D} USE: in: {x=READ} out: {x=READ} 3 mark({ x = "" }) mark("") - r("") -> USE: in: {length=READ, x=WRITTEN_AFTER_READ} out: {length=READ, x=WRITTEN_AFTER_READ} - w(x|) INIT: in: {x=D} out: {x=ID} USE: in: {length=READ, x=READ} out: {length=READ, x=WRITTEN_AFTER_READ} + r("") -> USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ} + w(x|) INIT: in: {x=D} out: {x=ID} USE: in: {x=READ} out: {x=WRITTEN_AFTER_READ} L2 [after local class]: - 2 mark(x.length) INIT: in: {x=I?D} out: {x=I?D} USE: in: {length=READ, x=READ} out: {length=READ, x=READ} - r(x) -> USE: in: {length=READ} out: {length=READ, x=READ} - r(length|) -> USE: in: {} out: {length=READ} + 2 mark(x.length) INIT: in: {x=I?D} out: {x=I?D} USE: in: {x=READ} out: {x=READ} + r(x) -> USE: in: {} out: {x=READ} + r(length|) -> L1: 1 INIT: in: {} out: {} error: diff --git a/compiler/testData/cfg-variables/bugs/kt10243.instructions b/compiler/testData/cfg-variables/bugs/kt10243.instructions index 70bdf82c8a4..f350f845553 100644 --- a/compiler/testData/cfg-variables/bugs/kt10243.instructions +++ b/compiler/testData/cfg-variables/bugs/kt10243.instructions @@ -25,73 +25,73 @@ fun foo(f: Boolean) { --------------------- L0: 1 INIT: in: {} out: {} - v(f: Boolean) INIT: in: {} out: {f=D} - magic[FAKE_INITIALIZER](f: Boolean) -> INIT: in: {f=D} out: {f=D} - w(f|) INIT: in: {f=D} out: {f=ID} - 2 mark({ try { if (f) { x = 0 } } finally { fun bar() {} } }) INIT: in: {f=ID} out: {f=ID} + v(f: Boolean) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](f: Boolean) -> INIT: in: {} out: {} + w(f|) INIT: in: {} out: {} + 2 mark({ try { if (f) { x = 0 } } finally { fun bar() {} } }) INIT: in: {} out: {} mark(try { if (f) { x = 0 } } finally { fun bar() {} }) jmp?(L2) 3 mark({ if (f) { x = 0 } }) - mark(if (f) { x = 0 }) USE: in: {f=READ, x=ONLY_WRITTEN_NEVER_READ} out: {f=READ, x=ONLY_WRITTEN_NEVER_READ} - r(f) -> USE: in: {x=ONLY_WRITTEN_NEVER_READ} out: {f=READ, x=ONLY_WRITTEN_NEVER_READ} + mark(if (f) { x = 0 }) + r(f) -> jf(L3|) 4 mark({ x = 0 }) - r(0) -> USE: in: {x=ONLY_WRITTEN_NEVER_READ} out: {x=ONLY_WRITTEN_NEVER_READ} - w(x|) INIT: in: {f=ID} out: {f=ID, x=I} USE: in: {} out: {x=ONLY_WRITTEN_NEVER_READ} - 3 jmp(L4) INIT: in: {f=ID, x=I} out: {f=ID, x=I} + r(0) -> + w(x|) + 3 jmp(L4) L3 [else branch]: - read (Unit) INIT: in: {f=ID} out: {f=ID} + read (Unit) L4 ['if' expression result]: - merge(if (f) { x = 0 }|!) -> INIT: in: {f=ID, x=I} out: {f=ID, x=I} + merge(if (f) { x = 0 }|!) -> 2 jmp?(L2) jmp(L5) L2 [onExceptionToFinallyBlock]: L6 [start finally]: 3 mark({ fun bar() {} }) jmp?(L7) - d(fun bar() {}) INIT: in: {f=I, x=I} out: {f=I, x=I} + d(fun bar() {}) L7 [after local declaration]: L10 [finish finally]: - 2 jmp(error) INIT: in: {f=ID, x=I} out: {f=ID, x=I} + 2 jmp(error) L5 [skipFinallyToErrorBlock]: L11 [copy of L2, onExceptionToFinallyBlock]: 3 mark({ fun bar() {} }) jmp?(L12) - d(fun bar() {}) INIT: in: {f=I, x=I} out: {f=I, x=I} + d(fun bar() {}) L12 [copy of L7, after local declaration]: - 2 merge(try { if (f) { x = 0 } } finally { fun bar() {} }|) -> INIT: in: {f=ID, x=I} out: {f=ID, x=I} + 2 merge(try { if (f) { x = 0 } } finally { fun bar() {} }|) -> L1: 1 error: sink: - INIT: in: {f=I, x=I} out: {f=I, x=I} USE: in: {} out: {} + USE: in: {} out: {} ===================== == bar == fun bar() {} --------------------- L8: - 4 INIT: in: {f=ID, x=I} out: {f=ID, x=I} + 4 INIT: in: {} out: {} 5 mark({}) read (Unit) L9: 4 error: - INIT: in: {} out: {} + sink: - INIT: in: {f=I, x=I} out: {f=I, x=I} USE: in: {} out: {} + USE: in: {} out: {} ===================== == bar == fun bar() {} --------------------- L2 [copy of L8, null]: - 4 INIT: in: {f=ID, x=I} out: {f=ID, x=I} + 4 INIT: in: {} out: {} 5 mark({}) read (Unit) L3 [copy of L9, null]: 4 L0 [copy of error, null]: - INIT: in: {} out: {} + L1 [copy of sink, null]: - INIT: in: {f=I, x=I} out: {f=I, x=I} USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/bugs/kt4764.instructions b/compiler/testData/cfg-variables/bugs/kt4764.instructions index b08aa6912e0..cca1dbf8cb7 100644 --- a/compiler/testData/cfg-variables/bugs/kt4764.instructions +++ b/compiler/testData/cfg-variables/bugs/kt4764.instructions @@ -39,7 +39,7 @@ L4 [start finally]: 5 mark({}) read (Unit) L5 [finish finally]: - 4 ret(*|) L1 USE: in: {} out: {} + 4 ret(*|) L1 USE: in: {} out: {} - 3 jmp(L6) L3 [else branch]: 4 mark({ if (false) { if (false) { var foo: String? = null try { foo = "test" } catch (e: Exception) { return "fail" } finally { println(foo) // Variable 'foo' must be initialized } } return "fail" } }) INIT: in: {} out: {} @@ -49,52 +49,52 @@ L3 [else branch]: 5 mark({ if (false) { var foo: String? = null try { foo = "test" } catch (e: Exception) { return "fail" } finally { println(foo) // Variable 'foo' must be initialized } } return "fail" }) mark(if (false) { var foo: String? = null try { foo = "test" } catch (e: Exception) { return "fail" } finally { println(foo) // Variable 'foo' must be initialized } }) r(false) -> - jf(L8|) USE: in: {} out: {} + jf(L8|) USE: in: {} out: {} 6 mark({ var foo: String? = null try { foo = "test" } catch (e: Exception) { return "fail" } finally { println(foo) // Variable 'foo' must be initialized } }) v(var foo: String? = null) INIT: in: {} out: {foo=D} r(null) -> INIT: in: {foo=D} out: {foo=D} w(foo|) INIT: in: {foo=D} out: {foo=ID} mark(try { foo = "test" } catch (e: Exception) { return "fail" } finally { println(foo) // Variable 'foo' must be initialized }) INIT: in: {foo=ID} out: {foo=ID} jmp?(L9) - jmp?(L10) USE: in: {foo=READ} out: {foo=READ} + jmp?(L10) USE: in: {foo=READ} out: {foo=READ} 7 mark({ foo = "test" }) mark("test") - r("test") -> USE: in: {foo=WRITTEN_AFTER_READ} out: {foo=WRITTEN_AFTER_READ} - w(foo|) USE: in: {foo=READ} out: {foo=WRITTEN_AFTER_READ} + r("test") -> USE: in: {foo=WRITTEN_AFTER_READ} out: {foo=WRITTEN_AFTER_READ} + w(foo|) USE: in: {foo=READ} out: {foo=WRITTEN_AFTER_READ} 6 jmp?(L9) jmp?(L10) jmp(L11) L9 [onException]: - 7 v(e: Exception) INIT: in: {foo=ID} out: {e=D, foo=ID} - magic[FAKE_INITIALIZER](e: Exception) -> INIT: in: {e=D, foo=ID} out: {e=D, foo=ID} - w(e|) INIT: in: {e=D, foo=ID} out: {e=ID, foo=ID} - 8 mark({ return "fail" }) INIT: in: {e=ID, foo=ID} out: {e=ID, foo=ID} + 7 v(e: Exception) INIT: in: {foo=ID} out: {foo=ID} + magic[FAKE_INITIALIZER](e: Exception) -> INIT: in: {foo=ID} out: {foo=ID} + w(e|) INIT: in: {foo=ID} out: {foo=ID} + 8 mark({ return "fail" }) INIT: in: {foo=ID} out: {foo=ID} jmp?(L2) mark("fail") r("fail") -> L12 [start finally]: - 9 mark({ println(foo) // Variable 'foo' must be initialized }) USE: in: {foo=READ} out: {foo=READ} - r(foo) -> USE: in: {} out: {foo=READ} + 9 mark({ println(foo) // Variable 'foo' must be initialized }) USE: in: {foo=READ} out: {foo=READ} + r(foo) -> USE: in: {} out: {foo=READ} mark(println(foo)) magic[UNRESOLVED_CALL](println(foo)|, !) -> L13 [finish finally]: 5 mark({}) INIT: in: {} out: {} read (Unit) - 8 ret(*|) L1 USE: in: {} out: {} + 8 ret(*|) L1 USE: in: {} out: {} - 7 jmp(L11) L11 [afterCatches]: 6 jmp(L14) INIT: in: {foo=ID} out: {foo=ID} L10 [onExceptionToFinallyBlock]: - 9 mark({ println(foo) // Variable 'foo' must be initialized }) USE: in: {foo=READ} out: {foo=READ} - r(foo) -> USE: in: {} out: {foo=READ} + 9 mark({ println(foo) // Variable 'foo' must be initialized }) USE: in: {foo=READ} out: {foo=READ} + r(foo) -> USE: in: {} out: {foo=READ} mark(println(foo)) magic[UNRESOLVED_CALL](println(foo)|, !) -> 5 mark({}) INIT: in: {} out: {} read (Unit) - 6 jmp(error) USE: in: {} out: {} + 6 jmp(error) USE: in: {} out: {} L14 [skipFinallyToErrorBlock]: - 9 mark({ println(foo) // Variable 'foo' must be initialized }) INIT: in: {foo=ID} out: {foo=ID} USE: in: {foo=READ} out: {foo=READ} - r(foo) -> USE: in: {} out: {foo=READ} + 9 mark({ println(foo) // Variable 'foo' must be initialized }) INIT: in: {foo=ID} out: {foo=ID} USE: in: {foo=READ} out: {foo=READ} + r(foo) -> USE: in: {} out: {foo=READ} mark(println(foo)) magic[UNRESOLVED_CALL](println(foo)|, !) -> 6 merge(try { foo = "test" } catch (e: Exception) { return "fail" } finally { println(foo) // Variable 'foo' must be initialized }|!, !) -> @@ -108,7 +108,7 @@ L15 ['if' expression result]: r("fail") -> mark({}) read (Unit) - ret(*|) L1 USE: in: {} out: {} + ret(*|) L1 USE: in: {} out: {} - 4 jmp(L16) L7 [else branch]: read (Unit) INIT: in: {} out: {} @@ -133,5 +133,5 @@ L1: error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/bugs/kt5469.instructions b/compiler/testData/cfg-variables/bugs/kt5469.instructions index 9b8a48de51c..2bffc859dba 100644 --- a/compiler/testData/cfg-variables/bugs/kt5469.instructions +++ b/compiler/testData/cfg-variables/bugs/kt5469.instructions @@ -10,38 +10,38 @@ fun f() { } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {} out: {} + 1 INIT: in: {} out: {} USE: in: {} out: {} 2 mark({ var foo = 1 try { foo = 2 throw RuntimeException() } catch (e: Throwable) { println(foo) } }) v(var foo = 1) INIT: in: {} out: {foo=D} r(1) -> INIT: in: {foo=D} out: {foo=D} w(foo|) INIT: in: {foo=D} out: {foo=ID} mark(try { foo = 2 throw RuntimeException() } catch (e: Throwable) { println(foo) }) INIT: in: {foo=ID} out: {foo=ID} - jmp?(L2) USE: in: {foo=READ} out: {foo=READ} + jmp?(L2) USE: in: {foo=READ} out: {foo=READ} 3 mark({ foo = 2 throw RuntimeException() }) - r(2) -> USE: in: {foo=WRITTEN_AFTER_READ} out: {foo=WRITTEN_AFTER_READ} - w(foo|) USE: in: {foo=READ} out: {foo=WRITTEN_AFTER_READ} + r(2) -> USE: in: {foo=WRITTEN_AFTER_READ} out: {foo=WRITTEN_AFTER_READ} + w(foo|) USE: in: {foo=READ} out: {foo=WRITTEN_AFTER_READ} mark(throw RuntimeException()) - jmp?(L2) USE: in: {foo=READ} out: {foo=READ} + jmp?(L2) USE: in: {foo=READ} out: {foo=READ} mark(RuntimeException()) call(RuntimeException(), ) -> - throw (throw RuntimeException()|) USE: in: {} out: {} + throw (throw RuntimeException()|) USE: in: {} out: {} - 2 jmp?(L2) - jmp(L3) L2 [onException]: - 3 v(e: Throwable) INIT: in: {foo=ID} out: {e=D, foo=ID} - magic[FAKE_INITIALIZER](e: Throwable) -> INIT: in: {e=D, foo=ID} out: {e=D, foo=ID} - w(e|) INIT: in: {e=D, foo=ID} out: {e=ID, foo=ID} - 4 mark({ println(foo) }) INIT: in: {e=ID, foo=ID} out: {e=ID, foo=ID} USE: in: {foo=READ} out: {foo=READ} - r(foo) -> USE: in: {} out: {foo=READ} + 3 v(e: Throwable) INIT: in: {foo=ID} out: {foo=ID} + magic[FAKE_INITIALIZER](e: Throwable) -> INIT: in: {foo=ID} out: {foo=ID} + w(e|) INIT: in: {foo=ID} out: {foo=ID} + 4 mark({ println(foo) }) INIT: in: {foo=ID} out: {foo=ID} USE: in: {foo=READ} out: {foo=READ} + r(foo) -> USE: in: {} out: {foo=READ} mark(println(foo)) magic[UNRESOLVED_CALL](println(foo)|, !) -> 3 jmp(L3) L3 [afterCatches]: - 2 merge(try { foo = 2 throw RuntimeException() } catch (e: Throwable) { println(foo) }|!, ) -> INIT: in: {foo=ID} out: {foo=ID} + 2 merge(try { foo = 2 throw RuntimeException() } catch (e: Throwable) { println(foo) }|!, ) -> L1: 1 INIT: in: {} out: {} error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/bugs/localObjectInConstructor.instructions b/compiler/testData/cfg-variables/bugs/localObjectInConstructor.instructions index 0dc5d0dc039..72611e50337 100644 --- a/compiler/testData/cfg-variables/bugs/localObjectInConstructor.instructions +++ b/compiler/testData/cfg-variables/bugs/localObjectInConstructor.instructions @@ -3,17 +3,17 @@ fun println(obj: Any?) {} --------------------- L0: 1 INIT: in: {} out: {} - v(obj: Any?) INIT: in: {} out: {obj=D} - magic[FAKE_INITIALIZER](obj: Any?) -> INIT: in: {obj=D} out: {obj=D} - w(obj|) INIT: in: {obj=D} out: {obj=ID} - 2 mark({}) INIT: in: {obj=ID} out: {obj=ID} + v(obj: Any?) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](obj: Any?) -> INIT: in: {} out: {} + w(obj|) INIT: in: {} out: {} + 2 mark({}) INIT: in: {} out: {} read (Unit) L1: 1 error: - INIT: in: {} out: {} + sink: - INIT: in: {obj=I?} out: {obj=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == Demo0 == class Demo0 { @@ -28,22 +28,22 @@ class Demo0 { --------------------- L0: 1 INIT: in: {} out: {} - v(private val some = object { fun foo() { println(state) // Ok } }) INIT: in: {} out: {some=D} - mark(object { fun foo() { println(state) // Ok } }) INIT: in: {some=D} out: {some=D} + v(private val some = object { fun foo() { println(state) // Ok } }) INIT: in: {} out: {} + mark(object { fun foo() { println(state) // Ok } }) INIT: in: {} out: {} jmp?(L2) - d(fun foo() { println(state) // Ok }) INIT: in: {some=I?} out: {some=I?} USE: in: {state=READ} out: {state=READ} + d(fun foo() { println(state) // Ok }) USE: in: {state=READ} out: {state=READ} L2 [after local declaration]: - r(object { fun foo() { println(state) // Ok } }) -> INIT: in: {some=D} out: {some=D} - w(some|) INIT: in: {some=D} out: {some=ID} - v(private var state: Boolean = true) INIT: in: {some=ID} out: {some=ID, state=D} - r(true) -> INIT: in: {some=ID, state=D} out: {some=ID, state=D} - w(state|) INIT: in: {some=ID, state=D} out: {some=ID, state=ID} + r(object { fun foo() { println(state) // Ok } }) -> + w(some|) INIT: in: {} out: {} + v(private var state: Boolean = true) INIT: in: {} out: {state=D} + r(true) -> INIT: in: {state=D} out: {state=D} + w(state|) INIT: in: {state=D} out: {state=ID} L1: - INIT: in: {some=ID, state=ID} out: {some=ID, state=ID} + INIT: in: {state=ID} out: {state=ID} error: INIT: in: {} out: {} sink: - INIT: in: {some=I?, state=I?} out: {some=I?, state=I?} USE: in: {} out: {} + INIT: in: {state=I?} out: {state=I?} USE: in: {} out: {} ===================== == foo == fun foo() { @@ -51,18 +51,18 @@ fun foo() { } --------------------- L3: - 2 INIT: in: {some=D} out: {some=D} + 2 INIT: in: {} out: {} 3 mark({ println(state) // Ok }) - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {} out: {state=READ} + magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} + r(state|) -> USE: in: {} out: {state=READ} mark(println(state)) call(println(state), println|) -> L4: 2 error: - INIT: in: {} out: {} + sink: - INIT: in: {some=I?} out: {some=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == Demo1 == class Demo1 { @@ -80,22 +80,22 @@ class Demo1 { --------------------- L0: 1 INIT: in: {} out: {} - v(private val some = object { fun foo() { if (state) state = true println(state) // must be initialized } }) INIT: in: {} out: {some=D} - mark(object { fun foo() { if (state) state = true println(state) // must be initialized } }) INIT: in: {some=D} out: {some=D} + v(private val some = object { fun foo() { if (state) state = true println(state) // must be initialized } }) INIT: in: {} out: {} + mark(object { fun foo() { if (state) state = true println(state) // must be initialized } }) INIT: in: {} out: {} jmp?(L2) - d(fun foo() { if (state) state = true println(state) // must be initialized }) INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {state=READ} out: {state=READ} + d(fun foo() { if (state) state = true println(state) // must be initialized }) INIT: in: {state=I} out: {state=I} USE: in: {state=READ} out: {state=READ} L2 [after local declaration]: - r(object { fun foo() { if (state) state = true println(state) // must be initialized } }) -> INIT: in: {some=D} out: {some=D} - w(some|) INIT: in: {some=D} out: {some=ID} - v(private var state: Boolean = true) INIT: in: {some=ID} out: {some=ID, state=D} - r(true) -> INIT: in: {some=ID, state=D} out: {some=ID, state=D} - w(state|) INIT: in: {some=ID, state=D} out: {some=ID, state=ID} + r(object { fun foo() { if (state) state = true println(state) // must be initialized } }) -> INIT: in: {} out: {} + w(some|) INIT: in: {} out: {} + v(private var state: Boolean = true) INIT: in: {} out: {state=D} + r(true) -> INIT: in: {state=D} out: {state=D} + w(state|) INIT: in: {state=D} out: {state=ID} L1: - INIT: in: {some=ID, state=ID} out: {some=ID, state=ID} + INIT: in: {state=ID} out: {state=ID} error: INIT: in: {} out: {} sink: - INIT: in: {some=I?, state=I?} out: {some=I?, state=I?} USE: in: {} out: {} + INIT: in: {state=I?} out: {state=I?} USE: in: {} out: {} ===================== == foo == fun foo() { @@ -106,22 +106,22 @@ fun foo() { } --------------------- L3: - 2 INIT: in: {some=D} out: {some=D} + 2 INIT: in: {} out: {} 3 mark({ if (state) state = true println(state) // must be initialized }) mark(if (state) state = true) magic[IMPLICIT_RECEIVER](state) -> r(state|) -> - jf(L5|) USE: in: {state=READ} out: {state=READ} + jf(L5|) USE: in: {state=READ} out: {state=READ} magic[IMPLICIT_RECEIVER](state) -> - r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} - w(state|, ) INIT: in: {some=D} out: {some=D, state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} - jmp(L6) INIT: in: {some=D, state=I} out: {some=D, state=I} + r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} + w(state|, ) INIT: in: {} out: {state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} + jmp(L6) INIT: in: {state=I} out: {state=I} L5 [else branch]: - read (Unit) INIT: in: {some=D} out: {some=D} + read (Unit) INIT: in: {} out: {} L6 ['if' expression result]: - merge(if (state) state = true|!) -> INIT: in: {some=D, state=I} out: {some=D, state=I} - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {} out: {state=READ} + merge(if (state) state = true|!) -> INIT: in: {state=I} out: {state=I} + magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} + r(state|) -> USE: in: {} out: {state=READ} mark(println(state)) call(println(state), println|) -> L4: @@ -129,7 +129,7 @@ L4: error: INIT: in: {} out: {} sink: - INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {} out: {} + INIT: in: {state=I} out: {state=I} USE: in: {} out: {} ===================== == Demo1A == class Demo1A { @@ -169,25 +169,25 @@ L0: mark(if (state) state = true) magic[IMPLICIT_RECEIVER](state) -> r(state|) -> - jf(L2|) USE: in: {state=READ} out: {state=READ} + jf(L2|) magic[IMPLICIT_RECEIVER](state) -> - r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} - w(state|, ) INIT: in: {} out: {state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} - jmp(L3) INIT: in: {state=I} out: {state=I} + r(true) -> + w(state|, ) + jmp(L3) L2 [else branch]: - read (Unit) INIT: in: {} out: {} + read (Unit) L3 ['if' expression result]: - merge(if (state) state = true|!) -> INIT: in: {state=I} out: {state=I} - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {} out: {state=READ} + merge(if (state) state = true|!) -> + magic[IMPLICIT_RECEIVER](state) -> + r(state|) -> mark(println(state)) call(println(state), println|) -> L1: 1 error: - INIT: in: {} out: {} + sink: - INIT: in: {state=I} out: {state=I} USE: in: {} out: {} + USE: in: {} out: {} ===================== == Demo2 == class Demo2 { @@ -207,22 +207,22 @@ class Demo2 { --------------------- L0: 1 INIT: in: {} out: {} - v(private val some = object { fun foo() { if (state) state = true else state = false println(state) // OK } }) INIT: in: {} out: {some=D} - mark(object { fun foo() { if (state) state = true else state = false println(state) // OK } }) INIT: in: {some=D} out: {some=D} + v(private val some = object { fun foo() { if (state) state = true else state = false println(state) // OK } }) INIT: in: {} out: {} + mark(object { fun foo() { if (state) state = true else state = false println(state) // OK } }) INIT: in: {} out: {} jmp?(L2) - d(fun foo() { if (state) state = true else state = false println(state) // OK }) INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {state=READ} out: {state=READ} + d(fun foo() { if (state) state = true else state = false println(state) // OK }) INIT: in: {state=I} out: {state=I} USE: in: {state=READ} out: {state=READ} L2 [after local declaration]: - r(object { fun foo() { if (state) state = true else state = false println(state) // OK } }) -> INIT: in: {some=D} out: {some=D} - w(some|) INIT: in: {some=D} out: {some=ID} - v(private var state: Boolean = true) INIT: in: {some=ID} out: {some=ID, state=D} - r(true) -> INIT: in: {some=ID, state=D} out: {some=ID, state=D} - w(state|) INIT: in: {some=ID, state=D} out: {some=ID, state=ID} + r(object { fun foo() { if (state) state = true else state = false println(state) // OK } }) -> INIT: in: {} out: {} + w(some|) INIT: in: {} out: {} + v(private var state: Boolean = true) INIT: in: {} out: {state=D} + r(true) -> INIT: in: {state=D} out: {state=D} + w(state|) INIT: in: {state=D} out: {state=ID} L1: - INIT: in: {some=ID, state=ID} out: {some=ID, state=ID} + INIT: in: {state=ID} out: {state=ID} error: INIT: in: {} out: {} sink: - INIT: in: {some=I?, state=I?} out: {some=I?, state=I?} USE: in: {} out: {} + INIT: in: {state=I?} out: {state=I?} USE: in: {} out: {} ===================== == foo == fun foo() { @@ -235,24 +235,24 @@ fun foo() { } --------------------- L3: - 2 INIT: in: {some=D} out: {some=D} + 2 INIT: in: {} out: {} 3 mark({ if (state) state = true else state = false println(state) // OK }) mark(if (state) state = true else state = false) - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=READ} + magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} + r(state|) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=READ} jf(L5|) magic[IMPLICIT_RECEIVER](state) -> - r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} - w(state|, ) INIT: in: {some=D} out: {some=D, state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} - jmp(L6) INIT: in: {some=D, state=I} out: {some=D, state=I} USE: in: {state=READ} out: {state=READ} + r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} + w(state|, ) INIT: in: {} out: {state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} + jmp(L6) INIT: in: {state=I} out: {state=I} USE: in: {state=READ} out: {state=READ} L5 [else branch]: - magic[IMPLICIT_RECEIVER](state) -> INIT: in: {some=D} out: {some=D} - r(false) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} - w(state|, ) INIT: in: {some=D} out: {some=D, state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} + magic[IMPLICIT_RECEIVER](state) -> INIT: in: {} out: {} + r(false) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} + w(state|, ) INIT: in: {} out: {state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} L6 ['if' expression result]: - merge(if (state) state = true else state = false|!, !) -> INIT: in: {some=D, state=I} out: {some=D, state=I} - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {} out: {state=READ} + merge(if (state) state = true else state = false|!, !) -> INIT: in: {state=I} out: {state=I} + magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} + r(state|) -> USE: in: {} out: {state=READ} mark(println(state)) call(println(state), println|) -> L4: @@ -260,7 +260,7 @@ L4: error: INIT: in: {} out: {} sink: - INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {} out: {} + INIT: in: {state=I} out: {state=I} USE: in: {} out: {} ===================== == Demo3 == class Demo3 { @@ -276,25 +276,25 @@ class Demo3 { --------------------- L0: 1 INIT: in: {} out: {} - v(private val some = run { if (state) state = true println(state) // OK }) INIT: in: {} out: {some=D} - magic[IMPLICIT_RECEIVER](run { if (state) state = true println(state) // OK }) -> INIT: in: {some=D} out: {some=D} + v(private val some = run { if (state) state = true println(state) // OK }) INIT: in: {} out: {} + magic[IMPLICIT_RECEIVER](run { if (state) state = true println(state) // OK }) -> INIT: in: {} out: {} mark({ if (state) state = true println(state) // OK }) jmp?(L2) - d({ if (state) state = true println(state) // OK }) INIT: in: {some=I?} out: {some=I?} USE: in: {state=READ} out: {state=READ} + d({ if (state) state = true println(state) // OK }) USE: in: {state=READ} out: {state=READ} L2 [after local declaration]: - r({ if (state) state = true println(state) // OK }) -> INIT: in: {some=D} out: {some=D} + r({ if (state) state = true println(state) // OK }) -> mark(run { if (state) state = true println(state) // OK }) call(run { if (state) state = true println(state) // OK }, run|, ) -> - w(some|) INIT: in: {some=D} out: {some=ID} - v(private var state: Boolean = true) INIT: in: {some=ID} out: {some=ID, state=D} - r(true) -> INIT: in: {some=ID, state=D} out: {some=ID, state=D} - w(state|) INIT: in: {some=ID, state=D} out: {some=ID, state=ID} + w(some|) INIT: in: {} out: {} + v(private var state: Boolean = true) INIT: in: {} out: {state=D} + r(true) -> INIT: in: {state=D} out: {state=D} + w(state|) INIT: in: {state=D} out: {state=ID} L1: - INIT: in: {some=ID, state=ID} out: {some=ID, state=ID} + INIT: in: {state=ID} out: {state=ID} error: INIT: in: {} out: {} sink: - INIT: in: {some=I?, state=I?} out: {some=I?, state=I?} USE: in: {} out: {} + INIT: in: {state=I?} out: {state=I?} USE: in: {} out: {} ===================== == anonymous_0 == { @@ -305,49 +305,49 @@ sink: } --------------------- L3: - 2 INIT: in: {some=D} out: {some=D} + 2 INIT: in: {} out: {} 3 mark(if (state) state = true println(state) // OK) mark(if (state) state = true) magic[IMPLICIT_RECEIVER](state) -> r(state|) -> - jf(L5|) USE: in: {state=READ} out: {state=READ} + jf(L5|) USE: in: {state=READ} out: {state=READ} magic[IMPLICIT_RECEIVER](state) -> - r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} - w(state|, ) USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} + r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} + w(state|, ) USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} jmp(L6) L5 [else branch]: read (Unit) L6 ['if' expression result]: merge(if (state) state = true|!) -> - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {} out: {state=READ} + magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} + r(state|) -> USE: in: {} out: {state=READ} mark(println(state)) call(println(state), println|) -> L4: 2 error: - INIT: in: {} out: {} + sink: - INIT: in: {some=I?} out: {some=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == exec == fun exec(f: () -> T): T = f() --------------------- L0: 1 INIT: in: {} out: {} - v(f: () -> T) INIT: in: {} out: {f=D} - magic[FAKE_INITIALIZER](f: () -> T) -> INIT: in: {f=D} out: {f=D} - w(f|) INIT: in: {f=D} out: {f=ID} USE: in: {f=READ} out: {f=READ} - r(f) -> INIT: in: {f=ID} out: {f=ID} USE: in: {} out: {f=READ} + v(f: () -> T) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](f: () -> T) -> INIT: in: {} out: {} + w(f|) INIT: in: {} out: {} + r(f) -> INIT: in: {} out: {} mark(f()) call(f(), invoke|) -> ret(*|) L1 L1: error: - INIT: in: {} out: {} + sink: - INIT: in: {f=I?} out: {f=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == Demo4 == class Demo4 { @@ -363,24 +363,24 @@ class Demo4 { --------------------- L0: 1 INIT: in: {} out: {} - v(private val some = exec { if (state) state = true println(state) // must be initialized }) INIT: in: {} out: {some=D} - mark({ if (state) state = true println(state) // must be initialized }) INIT: in: {some=D} out: {some=D} + v(private val some = exec { if (state) state = true println(state) // must be initialized }) INIT: in: {} out: {} + mark({ if (state) state = true println(state) // must be initialized }) INIT: in: {} out: {} jmp?(L2) - d({ if (state) state = true println(state) // must be initialized }) INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {state=READ} out: {state=READ} + d({ if (state) state = true println(state) // must be initialized }) INIT: in: {state=I} out: {state=I} USE: in: {state=READ} out: {state=READ} L2 [after local declaration]: - r({ if (state) state = true println(state) // must be initialized }) -> INIT: in: {some=D} out: {some=D} + r({ if (state) state = true println(state) // must be initialized }) -> INIT: in: {} out: {} mark(exec { if (state) state = true println(state) // must be initialized }) call(exec { if (state) state = true println(state) // must be initialized }, exec|) -> - w(some|) INIT: in: {some=D} out: {some=ID} - v(private var state: Boolean = true) INIT: in: {some=ID} out: {some=ID, state=D} - r(true) -> INIT: in: {some=ID, state=D} out: {some=ID, state=D} - w(state|) INIT: in: {some=ID, state=D} out: {some=ID, state=ID} + w(some|) INIT: in: {} out: {} + v(private var state: Boolean = true) INIT: in: {} out: {state=D} + r(true) -> INIT: in: {state=D} out: {state=D} + w(state|) INIT: in: {state=D} out: {state=ID} L1: - INIT: in: {some=ID, state=ID} out: {some=ID, state=ID} + INIT: in: {state=ID} out: {state=ID} error: INIT: in: {} out: {} sink: - INIT: in: {some=I?, state=I?} out: {some=I?, state=I?} USE: in: {} out: {} + INIT: in: {state=I?} out: {state=I?} USE: in: {} out: {} ===================== == anonymous_1 == { @@ -391,22 +391,22 @@ sink: } --------------------- L3: - 2 INIT: in: {some=D} out: {some=D} + 2 INIT: in: {} out: {} 3 mark(if (state) state = true println(state) // must be initialized) mark(if (state) state = true) magic[IMPLICIT_RECEIVER](state) -> r(state|) -> - jf(L5|) USE: in: {state=READ} out: {state=READ} + jf(L5|) USE: in: {state=READ} out: {state=READ} magic[IMPLICIT_RECEIVER](state) -> - r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} - w(state|, ) INIT: in: {some=D} out: {some=D, state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} - jmp(L6) INIT: in: {some=D, state=I} out: {some=D, state=I} + r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} + w(state|, ) INIT: in: {} out: {state=I} USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} + jmp(L6) INIT: in: {state=I} out: {state=I} L5 [else branch]: - read (Unit) INIT: in: {some=D} out: {some=D} + read (Unit) INIT: in: {} out: {} L6 ['if' expression result]: - merge(if (state) state = true|!) -> INIT: in: {some=D, state=I} out: {some=D, state=I} - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {} out: {state=READ} + merge(if (state) state = true|!) -> INIT: in: {state=I} out: {state=I} + magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} + r(state|) -> USE: in: {} out: {state=READ} mark(println(state)) call(println(state), println|) -> L4: @@ -414,7 +414,7 @@ L4: error: INIT: in: {} out: {} sink: - INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {} out: {} + INIT: in: {state=I} out: {state=I} USE: in: {} out: {} ===================== == Demo5 == class Demo5 { @@ -435,19 +435,19 @@ L0: v(private var state: Boolean = true) INIT: in: {} out: {state=D} r(true) -> INIT: in: {state=D} out: {state=D} w(state|) INIT: in: {state=D} out: {state=ID} - v(private val some = object { fun foo() { if (state) state = true println(state) // OK } }) INIT: in: {state=ID} out: {some=D, state=ID} - mark(object { fun foo() { if (state) state = true println(state) // OK } }) INIT: in: {some=D, state=ID} out: {some=D, state=ID} + v(private val some = object { fun foo() { if (state) state = true println(state) // OK } }) INIT: in: {state=ID} out: {state=ID} + mark(object { fun foo() { if (state) state = true println(state) // OK } }) INIT: in: {state=ID} out: {state=ID} jmp?(L2) - d(fun foo() { if (state) state = true println(state) // OK }) INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {state=READ} out: {state=READ} + d(fun foo() { if (state) state = true println(state) // OK }) INIT: in: {state=I} out: {state=I} USE: in: {state=READ} out: {state=READ} L2 [after local declaration]: - r(object { fun foo() { if (state) state = true println(state) // OK } }) -> INIT: in: {some=D, state=ID} out: {some=D, state=ID} - w(some|) INIT: in: {some=D, state=ID} out: {some=ID, state=ID} + r(object { fun foo() { if (state) state = true println(state) // OK } }) -> INIT: in: {state=ID} out: {state=ID} + w(some|) INIT: in: {state=ID} out: {state=ID} L1: - INIT: in: {some=ID, state=ID} out: {some=ID, state=ID} + INIT: in: {state=ID} out: {state=ID} error: INIT: in: {} out: {} sink: - INIT: in: {some=I?, state=I?} out: {some=I?, state=I?} USE: in: {} out: {} + INIT: in: {state=I?} out: {state=I?} USE: in: {} out: {} ===================== == foo == fun foo() { @@ -458,22 +458,22 @@ fun foo() { } --------------------- L3: - 2 INIT: in: {some=D, state=ID} out: {some=D, state=ID} + 2 INIT: in: {state=ID} out: {state=ID} 3 mark({ if (state) state = true println(state) // OK }) mark(if (state) state = true) magic[IMPLICIT_RECEIVER](state) -> r(state|) -> - jf(L5|) USE: in: {state=READ} out: {state=READ} + jf(L5|) USE: in: {state=READ} out: {state=READ} magic[IMPLICIT_RECEIVER](state) -> - r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} - w(state|, ) USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} + r(true) -> USE: in: {state=WRITTEN_AFTER_READ} out: {state=WRITTEN_AFTER_READ} + w(state|, ) USE: in: {state=READ} out: {state=WRITTEN_AFTER_READ} jmp(L6) L5 [else branch]: read (Unit) L6 ['if' expression result]: merge(if (state) state = true|!) -> - magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} - r(state|) -> USE: in: {} out: {state=READ} + magic[IMPLICIT_RECEIVER](state) -> USE: in: {state=READ} out: {state=READ} + r(state|) -> USE: in: {} out: {state=READ} mark(println(state)) call(println(state), println|) -> L4: @@ -481,5 +481,5 @@ L4: error: INIT: in: {} out: {} sink: - INIT: in: {some=I?, state=I} out: {some=I?, state=I} USE: in: {} out: {} + INIT: in: {state=I} out: {state=I} USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.instructions b/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.instructions index 89c0240de35..bbac4a9a2a7 100644 --- a/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.instructions +++ b/compiler/testData/cfg-variables/bugs/referenceToPropertyInitializer.instructions @@ -7,19 +7,19 @@ class TestFunctionLiteral { --------------------- L0: 1 INIT: in: {} out: {} - v(val sum: (Int)->Int = { x: Int -> sum(x - 1) + x }) INIT: in: {} out: {sum=D} - mark({ x: Int -> sum(x - 1) + x }) INIT: in: {sum=D} out: {sum=D} + v(val sum: (Int)->Int = { x: Int -> sum(x - 1) + x }) INIT: in: {} out: {} + mark({ x: Int -> sum(x - 1) + x }) INIT: in: {} out: {} jmp?(L2) - d({ x: Int -> sum(x - 1) + x }) INIT: in: {sum=I?} out: {sum=I?} USE: in: {sum=READ} out: {sum=READ} + d({ x: Int -> sum(x - 1) + x }) INIT: in: {} out: {} L2 [after local declaration]: - r({ x: Int -> sum(x - 1) + x }) -> INIT: in: {sum=D} out: {sum=D} - w(sum|) INIT: in: {sum=D} out: {sum=ID} + r({ x: Int -> sum(x - 1) + x }) -> + w(sum|) INIT: in: {} out: {} L1: - INIT: in: {sum=ID} out: {sum=ID} + INIT: in: {} out: {} error: - INIT: in: {} out: {} + sink: - INIT: in: {sum=I?} out: {sum=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == anonymous_0 == { x: Int -> @@ -27,44 +27,44 @@ sink: } --------------------- L3: - 2 INIT: in: {sum=D} out: {sum=D} - v(x: Int) INIT: in: {sum=D} out: {sum=D, x=D} - magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {sum=D, x=D} out: {sum=D, x=D} - w(x|) INIT: in: {sum=D, x=D} out: {sum=D, x=ID} - 3 mark(sum(x - 1) + x) INIT: in: {sum=D, x=ID} out: {sum=D, x=ID} - magic[IMPLICIT_RECEIVER](sum) -> USE: in: {sum=READ, x=READ} out: {sum=READ, x=READ} - r(sum|) -> USE: in: {x=READ} out: {sum=READ, x=READ} + 2 INIT: in: {} out: {} + v(x: Int) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {} out: {} + w(x|) INIT: in: {} out: {} + 3 mark(sum(x - 1) + x) INIT: in: {} out: {} + magic[IMPLICIT_RECEIVER](sum) -> + r(sum|) -> r(x) -> r(1) -> mark(x - 1) call(x - 1, minus|, ) -> mark(sum(x - 1)) - call(sum(x - 1), invoke|, ) -> USE: in: {x=READ} out: {x=READ} - r(x) -> USE: in: {} out: {x=READ} + call(sum(x - 1), invoke|, ) -> + r(x) -> mark(sum(x - 1) + x) call(sum(x - 1) + x, plus|, ) -> 2 ret(*|) L4 L4: error: - INIT: in: {} out: {} + sink: - INIT: in: {sum=I?, x=I?} out: {sum=I?, x=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == A == open class A(val a: A) --------------------- L0: 1 INIT: in: {} out: {} - v(val a: A) INIT: in: {} out: {a=D} - magic[FAKE_INITIALIZER](val a: A) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} + v(val a: A) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](val a: A) -> INIT: in: {} out: {} + w(a|) INIT: in: {} out: {} L1: - INIT: in: {a=ID} out: {a=ID} + INIT: in: {} out: {} error: - INIT: in: {} out: {} + sink: - INIT: in: {a=I?} out: {a=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == TestObjectLiteral == class TestObjectLiteral { @@ -80,28 +80,28 @@ class TestObjectLiteral { --------------------- L0: 1 INIT: in: {} out: {} - v(val obj: A = object: A(obj) { init { val x = obj } fun foo() { val y = obj } }) INIT: in: {} out: {obj=D} - mark(object: A(obj) { init { val x = obj } fun foo() { val y = obj } }) INIT: in: {obj=D} out: {obj=D} + v(val obj: A = object: A(obj) { init { val x = obj } fun foo() { val y = obj } }) INIT: in: {} out: {} + mark(object: A(obj) { init { val x = obj } fun foo() { val y = obj } }) INIT: in: {} out: {} magic[IMPLICIT_RECEIVER](obj) -> r(obj|) -> mark(A(obj)) call(A(obj), |) -> 2 mark({ val x = obj }) - v(val x = obj) INIT: in: {obj=D} out: {obj=D, x=D} - magic[IMPLICIT_RECEIVER](obj) -> INIT: in: {obj=D, x=D} out: {obj=D, x=D} + v(val x = obj) INIT: in: {} out: {} + magic[IMPLICIT_RECEIVER](obj) -> INIT: in: {} out: {} r(obj|) -> - w(x|) INIT: in: {obj=D, x=D} out: {obj=D, x=ID} - 1 jmp?(L2) INIT: in: {obj=D} out: {obj=D} - d(fun foo() { val y = obj }) INIT: in: {obj=I?} out: {obj=I?} USE: in: {obj=READ} out: {obj=READ} + w(x|) INIT: in: {} out: {} + 1 jmp?(L2) INIT: in: {} out: {} + d(fun foo() { val y = obj }) INIT: in: {} out: {} L2 [after local declaration]: - r(object: A(obj) { init { val x = obj } fun foo() { val y = obj } }) -> INIT: in: {obj=D} out: {obj=D} - w(obj|) INIT: in: {obj=D} out: {obj=ID} + r(object: A(obj) { init { val x = obj } fun foo() { val y = obj } }) -> + w(obj|) INIT: in: {} out: {} L1: - INIT: in: {obj=ID} out: {obj=ID} + INIT: in: {} out: {} error: - INIT: in: {} out: {} + sink: - INIT: in: {obj=I?} out: {obj=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == foo == fun foo() { @@ -109,18 +109,18 @@ fun foo() { } --------------------- L3: - 2 INIT: in: {obj=D} out: {obj=D} + 2 INIT: in: {} out: {} 3 mark({ val y = obj }) - v(val y = obj) INIT: in: {obj=D} out: {obj=D, y=D} - magic[IMPLICIT_RECEIVER](obj) -> INIT: in: {obj=D, y=D} out: {obj=D, y=D} USE: in: {obj=READ} out: {obj=READ} - r(obj|) -> USE: in: {} out: {obj=READ} - w(y|) INIT: in: {obj=D, y=D} out: {obj=D, y=ID} + v(val y = obj) INIT: in: {} out: {} + magic[IMPLICIT_RECEIVER](obj) -> INIT: in: {} out: {} + r(obj|) -> + w(y|) INIT: in: {} out: {} L4: - 2 INIT: in: {obj=D} out: {obj=D} + 2 INIT: in: {} out: {} error: - INIT: in: {} out: {} + sink: - INIT: in: {obj=I?} out: {obj=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == TestOther == class TestOther { @@ -129,17 +129,17 @@ class TestOther { --------------------- L0: 1 INIT: in: {} out: {} - v(val x: Int = x + 1) INIT: in: {} out: {x=D} - magic[IMPLICIT_RECEIVER](x) -> INIT: in: {x=D} out: {x=D} USE: in: {x=READ} out: {x=READ} - r(x|) -> USE: in: {} out: {x=READ} + v(val x: Int = x + 1) INIT: in: {} out: {} + magic[IMPLICIT_RECEIVER](x) -> INIT: in: {} out: {} + r(x|) -> r(1) -> mark(x + 1) call(x + 1, plus|, ) -> - w(x|) INIT: in: {x=D} out: {x=ID} + w(x|) INIT: in: {} out: {} L1: - INIT: in: {x=ID} out: {x=ID} + INIT: in: {} out: {} error: - INIT: in: {} out: {} + sink: - INIT: in: {x=I?} out: {x=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/bugs/varInitializationInIfInCycle.instructions b/compiler/testData/cfg-variables/bugs/varInitializationInIfInCycle.instructions index f24b711eae8..90cc8f2a78b 100644 --- a/compiler/testData/cfg-variables/bugs/varInitializationInIfInCycle.instructions +++ b/compiler/testData/cfg-variables/bugs/varInitializationInIfInCycle.instructions @@ -15,72 +15,72 @@ fun foo(numbers: Collection) { --------------------- L0: 1 INIT: in: {} out: {} - v(numbers: Collection) INIT: in: {} out: {numbers=D} - magic[FAKE_INITIALIZER](numbers: Collection) -> INIT: in: {numbers=D} out: {numbers=D} - w(numbers|) INIT: in: {numbers=D} out: {numbers=ID} - 2 mark({ for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue } }) INIT: in: {numbers=ID} out: {numbers=ID} USE: in: {numbers=READ} out: {numbers=READ} - 3 r(numbers) -> USE: in: {} out: {numbers=READ} + v(numbers: Collection) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](numbers: Collection) -> INIT: in: {} out: {} + w(numbers|) INIT: in: {} out: {} + 2 mark({ for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue } }) INIT: in: {} out: {} + 3 r(numbers) -> mark(numbers) call(numbers, iterator|) -> - v(i) INIT: in: {numbers=ID} out: {i=D, numbers=ID} + v(i) INIT: in: {} out: {} L2 [loop entry point]: L6 [condition entry point]: - mark(numbers) INIT: in: {i=I?D, numbers=ID} out: {i=I?D, numbers=ID} + mark(numbers) INIT: in: {} out: {} call(numbers, hasNext) -> jmp?(L3) mark(numbers) call(numbers, next) -> magic[LOOP_RANGE_ITERATION](numbers|) -> - w(i|) INIT: in: {i=I?D, numbers=ID} out: {i=ID, numbers=ID} - mark(for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue }) INIT: in: {i=ID, numbers=ID} out: {i=ID, numbers=ID} USE: in: {} out: {} + w(i|) INIT: in: {} out: {} + mark(for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue }) INIT: in: {} out: {} USE: in: {} out: {} L4 [body entry point]: 4 mark({ val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue }) - v(val b: Boolean) INIT: in: {i=ID, numbers=ID} out: {b=D, i=ID, numbers=ID} - mark(if (1 < 2) { b = false } else { b = true }) INIT: in: {b=D, i=ID, numbers=ID} out: {b=D, i=ID, numbers=ID} + v(val b: Boolean) INIT: in: {} out: {b=D} + mark(if (1 < 2) { b = false } else { b = true }) INIT: in: {b=D} out: {b=D} r(1) -> r(2) -> mark(1 < 2) call(1 < 2, compareTo|, ) -> jf(L7|) 5 mark({ b = false }) - r(false) -> USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ} - w(b|) INIT: in: {b=D, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ} - 4 jmp(L8) INIT: in: {b=ID, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=READ} + r(false) -> USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ} + w(b|) INIT: in: {b=D} out: {b=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ} + 4 jmp(L8) INIT: in: {b=ID} out: {b=ID} USE: in: {b=READ} out: {b=READ} L7 [else branch]: - 5 mark({ b = true }) INIT: in: {b=D, i=ID, numbers=ID} out: {b=D, i=ID, numbers=ID} - r(true) -> USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ} - w(b|) INIT: in: {b=D, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ} + 5 mark({ b = true }) INIT: in: {b=D} out: {b=D} + r(true) -> USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ} + w(b|) INIT: in: {b=D} out: {b=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ} L8 ['if' expression result]: - 4 merge(if (1 < 2) { b = false } else { b = true }|!, !) -> INIT: in: {b=ID, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=READ} - r(b) -> USE: in: {} out: {b=READ} + 4 merge(if (1 < 2) { b = false } else { b = true }|!, !) -> INIT: in: {b=ID} out: {b=ID} USE: in: {b=READ} out: {b=READ} + r(b) -> USE: in: {} out: {b=READ} mark(use(b)) call(use(b), use|) -> - jmp(L6) USE: in: {} out: {} + jmp(L6) USE: in: {} out: {} - 3 jmp(L2) L3 [loop exit point]: L5 [body exit point]: - read (Unit) INIT: in: {i=I?D, numbers=ID} out: {i=I?D, numbers=ID} + read (Unit) INIT: in: {} out: {} L1: - 1 INIT: in: {numbers=ID} out: {numbers=ID} + 1 error: - INIT: in: {} out: {} + sink: - INIT: in: {numbers=I?} out: {numbers=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== == use == fun use(vararg a: Any?) = a --------------------- L0: 1 INIT: in: {} out: {} - v(vararg a: Any?) INIT: in: {} out: {a=D} - magic[FAKE_INITIALIZER](vararg a: Any?) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} USE: in: {a=READ} out: {a=READ} - r(a) -> INIT: in: {a=ID} out: {a=ID} USE: in: {} out: {a=READ} + v(vararg a: Any?) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](vararg a: Any?) -> INIT: in: {} out: {} + w(a|) INIT: in: {} out: {} + r(a) -> INIT: in: {} out: {} ret(*|) L1 L1: error: - INIT: in: {} out: {} + sink: - INIT: in: {a=I?} out: {a=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/forScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/forScope.instructions index 30130fc9fd6..d82f2aac219 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/forScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/forScope.instructions @@ -11,39 +11,39 @@ L0: 1 INIT: in: {} out: {} 2 mark({ "before" for (i in 1..10) { val a = i } "after" }) mark("before") - r("before") -> USE: in: {} out: {} + r("before") -> 3 r(1) -> r(10) -> mark(1..10) call(1..10, rangeTo|, ) -> mark(1..10) call(1..10, iterator|) -> - v(i) INIT: in: {} out: {i=D} + v(i) INIT: in: {} out: {} L2 [loop entry point]: L6 [condition entry point]: - mark(1..10) INIT: in: {i=I?D} out: {i=I?D} + mark(1..10) INIT: in: {} out: {} call(1..10, hasNext) -> jmp?(L3) mark(1..10) call(1..10, next) -> magic[LOOP_RANGE_ITERATION](1..10|) -> - w(i|) INIT: in: {i=I?D} out: {i=ID} - mark(for (i in 1..10) { val a = i }) INIT: in: {i=ID} out: {i=ID} + w(i|) INIT: in: {} out: {} + mark(for (i in 1..10) { val a = i }) INIT: in: {} out: {} L4 [body entry point]: 4 mark({ val a = i }) - v(val a = i) INIT: in: {i=ID} out: {a=D, i=ID} - r(i) -> INIT: in: {a=D, i=ID} out: {a=D, i=ID} - w(a|) INIT: in: {a=D, i=ID} out: {a=ID, i=ID} - 3 jmp(L2) INIT: in: {i=ID} out: {i=ID} USE: in: {i=READ} out: {i=READ} + v(val a = i) INIT: in: {} out: {} + r(i) -> INIT: in: {} out: {} + w(a|) INIT: in: {} out: {} + 3 jmp(L2) INIT: in: {} out: {} L3 [loop exit point]: L5 [body exit point]: - read (Unit) INIT: in: {i=I?D} out: {i=I?D} - 2 mark("after") INIT: in: {} out: {} + read (Unit) + 2 mark("after") r("after") -> L1: 1 error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.instructions index 683974c44bf..cf296215eb8 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/functionLiteralScope.instructions @@ -9,28 +9,28 @@ fun foo() { } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {} out: {} + 1 INIT: in: {} out: {} 2 mark({ "before" val b = 1 val f = { x: Int -> val a = x + b } "after" }) mark("before") r("before") -> - v(val b = 1) INIT: in: {} out: {b=D} - r(1) -> INIT: in: {b=D} out: {b=D} - w(b|) INIT: in: {b=D} out: {b=ID} - v(val f = { x: Int -> val a = x + b }) INIT: in: {b=ID} out: {b=ID, f=D} - mark({ x: Int -> val a = x + b }) INIT: in: {b=ID, f=D} out: {b=ID, f=D} + v(val b = 1) INIT: in: {} out: {} + r(1) -> INIT: in: {} out: {} + w(b|) INIT: in: {} out: {} + v(val f = { x: Int -> val a = x + b }) INIT: in: {} out: {} + mark({ x: Int -> val a = x + b }) INIT: in: {} out: {} jmp?(L2) - d({ x: Int -> val a = x + b }) INIT: in: {b=I, f=I?} out: {b=I, f=I?} USE: in: {b=READ} out: {b=READ} + d({ x: Int -> val a = x + b }) INIT: in: {} out: {} L2 [after local declaration]: - r({ x: Int -> val a = x + b }) -> INIT: in: {b=ID, f=D} out: {b=ID, f=D} - w(f|) INIT: in: {b=ID, f=D} out: {b=ID, f=ID} - mark("after") INIT: in: {b=ID, f=ID} out: {b=ID, f=ID} + r({ x: Int -> val a = x + b }) -> + w(f|) INIT: in: {} out: {} + mark("after") INIT: in: {} out: {} r("after") -> L1: - 1 INIT: in: {} out: {} + 1 error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== == anonymous_0 == { x: Int -> @@ -38,21 +38,21 @@ sink: } --------------------- L3: - 3 INIT: in: {b=ID, f=D} out: {b=ID, f=D} - v(x: Int) INIT: in: {b=ID, f=D} out: {b=ID, f=D, x=D} - magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {b=ID, f=D, x=D} out: {b=ID, f=D, x=D} - w(x|) INIT: in: {b=ID, f=D, x=D} out: {b=ID, f=D, x=ID} - 4 mark(val a = x + b) INIT: in: {b=ID, f=D, x=ID} out: {b=ID, f=D, x=ID} - v(val a = x + b) INIT: in: {b=ID, f=D, x=ID} out: {a=D, b=ID, f=D, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ} - r(x) -> INIT: in: {a=D, b=ID, f=D, x=ID} out: {a=D, b=ID, f=D, x=ID} USE: in: {b=READ} out: {b=READ, x=READ} - r(b) -> USE: in: {} out: {b=READ} + 3 INIT: in: {} out: {} + v(x: Int) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {} out: {} + w(x|) INIT: in: {} out: {} + 4 mark(val a = x + b) INIT: in: {} out: {} + v(val a = x + b) INIT: in: {} out: {} + r(x) -> INIT: in: {} out: {} + r(b) -> mark(x + b) call(x + b, plus|, ) -> - w(a|) INIT: in: {a=D, b=ID, f=D, x=ID} out: {a=ID, b=ID, f=D, x=ID} + w(a|) INIT: in: {} out: {} L4: - 3 INIT: in: {b=ID, f=D, x=ID} out: {b=ID, f=D, x=ID} + 3 INIT: in: {} out: {} error: - INIT: in: {} out: {} + sink: - INIT: in: {b=I, f=I?, x=I?} out: {b=I, f=I?, x=I?} USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/ifScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/ifScope.instructions index 2485377a635..b8680fc8589 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/ifScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/ifScope.instructions @@ -19,15 +19,15 @@ L0: r(true) -> jf(L2|) 3 mark({ val a = 1 }) - v(val a = 1) INIT: in: {} out: {a=D} - r(1) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} + v(val a = 1) INIT: in: {} out: {} + r(1) -> INIT: in: {} out: {} + w(a|) INIT: in: {} out: {} 2 jmp(L3) INIT: in: {} out: {} L2 [else branch]: 3 mark({ val b = 2 }) - v(val b = 2) INIT: in: {} out: {b=D} - r(2) -> INIT: in: {b=D} out: {b=D} - w(b|) INIT: in: {b=D} out: {b=ID} + v(val b = 2) INIT: in: {} out: {} + r(2) -> INIT: in: {} out: {} + w(b|) INIT: in: {} out: {} L3 ['if' expression result]: 2 merge(if (true) { val a = 1 } else { val b = 2 }|!, !) -> INIT: in: {} out: {} mark("after") @@ -37,5 +37,5 @@ L1: error: sink: - USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {} out: {} +===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/localClass.instructions b/compiler/testData/cfg-variables/lexicalScopes/localClass.instructions index 4e84af904ae..e4568fcd064 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/localClass.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/localClass.instructions @@ -18,26 +18,26 @@ L0: mark("before") r("before") -> jmp?(L2) - v(val x: Int) INIT: in: {} out: {x=D} - magic[FAKE_INITIALIZER](val x: Int) -> INIT: in: {x=D} out: {x=D} - w(x|) INIT: in: {x=D} out: {x=ID} - 3 mark({ val a = x }) INIT: in: {x=ID} out: {x=ID} - v(val a = x) INIT: in: {x=ID} out: {a=D, x=ID} - magic[IMPLICIT_RECEIVER](x) -> INIT: in: {a=D, x=ID} out: {a=D, x=ID} + v(val x: Int) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](val x: Int) -> INIT: in: {} out: {} + w(x|) INIT: in: {} out: {} + 3 mark({ val a = x }) INIT: in: {} out: {} + v(val a = x) INIT: in: {} out: {} + magic[IMPLICIT_RECEIVER](x) -> INIT: in: {} out: {} r(x|) -> - w(a|) INIT: in: {a=D, x=ID} out: {a=ID, x=ID} - 2 jmp?(L3) INIT: in: {x=ID} out: {x=ID} - d(fun foo() { val b = x }) INIT: in: {x=I} out: {x=I} USE: in: {x=READ} out: {x=READ} + w(a|) INIT: in: {} out: {} + 2 jmp?(L3) INIT: in: {} out: {} + d(fun foo() { val b = x }) INIT: in: {} out: {} L2 [after local class]: L3 [after local declaration]: - mark("after") INIT: in: {x=I?} out: {x=I?} + mark("after") r("after") -> L1: - 1 INIT: in: {} out: {} + 1 error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== == foo == fun foo() { @@ -45,16 +45,16 @@ fun foo() { } --------------------- L4: - 3 INIT: in: {x=ID} out: {x=ID} + 3 INIT: in: {} out: {} 4 mark({ val b = x }) - v(val b = x) INIT: in: {x=ID} out: {b=D, x=ID} - magic[IMPLICIT_RECEIVER](x) -> INIT: in: {b=D, x=ID} out: {b=D, x=ID} USE: in: {x=READ} out: {x=READ} - r(x|) -> USE: in: {} out: {x=READ} - w(b|) INIT: in: {b=D, x=ID} out: {b=ID, x=ID} + v(val b = x) INIT: in: {} out: {} + magic[IMPLICIT_RECEIVER](x) -> INIT: in: {} out: {} + r(x|) -> + w(b|) INIT: in: {} out: {} L5: - 3 INIT: in: {x=ID} out: {x=ID} + 3 INIT: in: {} out: {} error: - INIT: in: {} out: {} + sink: - INIT: in: {x=I} out: {x=I} USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/localFunctionScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/localFunctionScope.instructions index 7698ee755fd..14a16c62a41 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/localFunctionScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/localFunctionScope.instructions @@ -9,24 +9,24 @@ fun foo() { } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {} out: {} + 1 INIT: in: {} out: {} 2 mark({ "before" val b = 1 fun local(x: Int) { val a = x + b } "after" }) mark("before") r("before") -> - v(val b = 1) INIT: in: {} out: {b=D} - r(1) -> INIT: in: {b=D} out: {b=D} - w(b|) INIT: in: {b=D} out: {b=ID} - jmp?(L2) INIT: in: {b=ID} out: {b=ID} - d(fun local(x: Int) { val a = x + b }) INIT: in: {b=I} out: {b=I} USE: in: {b=READ} out: {b=READ} + v(val b = 1) INIT: in: {} out: {} + r(1) -> INIT: in: {} out: {} + w(b|) INIT: in: {} out: {} + jmp?(L2) INIT: in: {} out: {} + d(fun local(x: Int) { val a = x + b }) INIT: in: {} out: {} L2 [after local declaration]: - mark("after") INIT: in: {b=ID} out: {b=ID} + mark("after") r("after") -> L1: - 1 INIT: in: {} out: {} + 1 error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== == local == fun local(x: Int) { @@ -34,21 +34,21 @@ fun local(x: Int) { } --------------------- L3: - 3 INIT: in: {b=ID} out: {b=ID} - v(x: Int) INIT: in: {b=ID} out: {b=ID, x=D} - magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {b=ID, x=D} out: {b=ID, x=D} - w(x|) INIT: in: {b=ID, x=D} out: {b=ID, x=ID} - 4 mark({ val a = x + b }) INIT: in: {b=ID, x=ID} out: {b=ID, x=ID} - v(val a = x + b) INIT: in: {b=ID, x=ID} out: {a=D, b=ID, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ} - r(x) -> INIT: in: {a=D, b=ID, x=ID} out: {a=D, b=ID, x=ID} USE: in: {b=READ} out: {b=READ, x=READ} - r(b) -> USE: in: {} out: {b=READ} + 3 INIT: in: {} out: {} + v(x: Int) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {} out: {} + w(x|) INIT: in: {} out: {} + 4 mark({ val a = x + b }) INIT: in: {} out: {} + v(val a = x + b) INIT: in: {} out: {} + r(x) -> INIT: in: {} out: {} + r(b) -> mark(x + b) call(x + b, plus|, ) -> - w(a|) INIT: in: {a=D, b=ID, x=ID} out: {a=ID, b=ID, x=ID} + w(a|) INIT: in: {} out: {} L4: - 3 INIT: in: {b=ID, x=ID} out: {b=ID, x=ID} + 3 INIT: in: {} out: {} error: - INIT: in: {} out: {} + sink: - INIT: in: {b=I, x=I?} out: {b=I, x=I?} USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {} out: {} +===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/localFunctionScopeWithoutBody.instructions b/compiler/testData/cfg-variables/lexicalScopes/localFunctionScopeWithoutBody.instructions index 003bc3b3273..8110cefbaf0 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/localFunctionScopeWithoutBody.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/localFunctionScopeWithoutBody.instructions @@ -7,42 +7,42 @@ fun foo() { } --------------------- L0: - 1 INIT: in: {} out: {} USE: in: {} out: {} + 1 INIT: in: {} out: {} 2 mark({ "before" val b = 1 fun local(x: Int) = x + b "after" }) mark("before") r("before") -> - v(val b = 1) INIT: in: {} out: {b=D} - r(1) -> INIT: in: {b=D} out: {b=D} - w(b|) INIT: in: {b=D} out: {b=ID} - jmp?(L2) INIT: in: {b=ID} out: {b=ID} - d(fun local(x: Int) = x + b) INIT: in: {b=I} out: {b=I} USE: in: {b=READ} out: {b=READ} + v(val b = 1) INIT: in: {} out: {} + r(1) -> INIT: in: {} out: {} + w(b|) INIT: in: {} out: {} + jmp?(L2) INIT: in: {} out: {} + d(fun local(x: Int) = x + b) INIT: in: {} out: {} L2 [after local declaration]: - mark("after") INIT: in: {b=ID} out: {b=ID} + mark("after") r("after") -> L1: - 1 INIT: in: {} out: {} + 1 error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== == local == fun local(x: Int) = x + b --------------------- L3: - 3 INIT: in: {b=ID} out: {b=ID} - v(x: Int) INIT: in: {b=ID} out: {b=ID, x=D} - magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {b=ID, x=D} out: {b=ID, x=D} - w(x|) INIT: in: {b=ID, x=D} out: {b=ID, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ} - r(x) -> INIT: in: {b=ID, x=ID} out: {b=ID, x=ID} USE: in: {b=READ} out: {b=READ, x=READ} - r(b) -> USE: in: {} out: {b=READ} + 3 INIT: in: {} out: {} + v(x: Int) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](x: Int) -> INIT: in: {} out: {} + w(x|) INIT: in: {} out: {} + r(x) -> INIT: in: {} out: {} + r(b) -> mark(x + b) call(x + b, plus|, ) -> ret(*|) L4 L4: error: - INIT: in: {} out: {} + sink: - INIT: in: {b=I, x=I?} out: {b=I, x=I?} USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {} out: {} +===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/localObject.instructions b/compiler/testData/cfg-variables/lexicalScopes/localObject.instructions index a379fa0e05b..9d654cdedeb 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/localObject.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/localObject.instructions @@ -19,11 +19,11 @@ L0: r("before") -> jmp?(L2) 3 mark({ val a = 1 }) - v(val a = 1) INIT: in: {} out: {a=D} - r(1) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} + v(val a = 1) INIT: in: {} out: {} + r(1) -> INIT: in: {} out: {} + w(a|) INIT: in: {} out: {} 2 jmp?(L3) INIT: in: {} out: {} - d(fun foo() { val b = 2 }) + d(fun foo() { val b = 2 }) INIT: in: {} out: {} L2 [after local class]: L3 [after local declaration]: mark("after") @@ -33,7 +33,7 @@ L1: error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== == foo == fun foo() { @@ -43,13 +43,13 @@ fun foo() { L4: 3 INIT: in: {} out: {} 4 mark({ val b = 2 }) - v(val b = 2) INIT: in: {} out: {b=D} - r(2) -> INIT: in: {b=D} out: {b=D} - w(b|) INIT: in: {b=D} out: {b=ID} + v(val b = 2) INIT: in: {} out: {} + r(2) -> INIT: in: {} out: {} + w(b|) INIT: in: {} out: {} L5: 3 INIT: in: {} out: {} error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/objectLiteralScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/objectLiteralScope.instructions index 9bd858d4db0..3d6ce75fad7 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/objectLiteralScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/objectLiteralScope.instructions @@ -17,25 +17,25 @@ L0: 2 mark({ "before" val bar = object { init { val x = 1 } fun foo() { val a = 2 } } "after" }) mark("before") r("before") -> - v(val bar = object { init { val x = 1 } fun foo() { val a = 2 } }) INIT: in: {} out: {bar=D} - mark(object { init { val x = 1 } fun foo() { val a = 2 } }) INIT: in: {bar=D} out: {bar=D} + v(val bar = object { init { val x = 1 } fun foo() { val a = 2 } }) INIT: in: {} out: {} + mark(object { init { val x = 1 } fun foo() { val a = 2 } }) INIT: in: {} out: {} 3 mark({ val x = 1 }) - v(val x = 1) INIT: in: {bar=D} out: {bar=D, x=D} - r(1) -> INIT: in: {bar=D, x=D} out: {bar=D, x=D} - w(x|) INIT: in: {bar=D, x=D} out: {bar=D, x=ID} - 2 jmp?(L2) INIT: in: {bar=D} out: {bar=D} - d(fun foo() { val a = 2 }) INIT: in: {bar=I?} out: {bar=I?} + v(val x = 1) INIT: in: {} out: {} + r(1) -> INIT: in: {} out: {} + w(x|) INIT: in: {} out: {} + 2 jmp?(L2) INIT: in: {} out: {} + d(fun foo() { val a = 2 }) INIT: in: {} out: {} L2 [after local declaration]: - r(object { init { val x = 1 } fun foo() { val a = 2 } }) -> INIT: in: {bar=D} out: {bar=D} - w(bar|) INIT: in: {bar=D} out: {bar=ID} - mark("after") INIT: in: {bar=ID} out: {bar=ID} + r(object { init { val x = 1 } fun foo() { val a = 2 } }) -> + w(bar|) INIT: in: {} out: {} + mark("after") INIT: in: {} out: {} r("after") -> L1: - 1 INIT: in: {} out: {} + 1 error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== == foo == fun foo() { @@ -43,15 +43,15 @@ fun foo() { } --------------------- L3: - 3 INIT: in: {bar=D} out: {bar=D} + 3 INIT: in: {} out: {} 4 mark({ val a = 2 }) - v(val a = 2) INIT: in: {bar=D} out: {a=D, bar=D} - r(2) -> INIT: in: {a=D, bar=D} out: {a=D, bar=D} - w(a|) INIT: in: {a=D, bar=D} out: {a=ID, bar=D} + v(val a = 2) INIT: in: {} out: {} + r(2) -> INIT: in: {} out: {} + w(a|) INIT: in: {} out: {} L4: - 3 INIT: in: {bar=D} out: {bar=D} + 3 INIT: in: {} out: {} error: - INIT: in: {} out: {} + sink: - INIT: in: {bar=I?} out: {bar=I?} USE: in: {} out: {} -===================== \ No newline at end of file + USE: in: {} out: {} +===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/propertyAccessorScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/propertyAccessorScope.instructions index 00fb06c2061..249f2d881f6 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/propertyAccessorScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/propertyAccessorScope.instructions @@ -16,11 +16,11 @@ L0: 2 mark({ class A { var a : Int get() { return field } set(v: Int) { field = v } } }) jmp?(L2) v(var a : Int get() { return field } set(v: Int) { field = v }) INIT: in: {} out: {a=D} - jmp?(L3) INIT: in: {a=D} out: {a=D} USE: in: {field=ONLY_WRITTEN_NEVER_READ, field=READ} out: {field=ONLY_WRITTEN_NEVER_READ, field=READ} - d(get() { return field }) INIT: in: {a=I?} out: {a=I?} USE: in: {field=READ} out: {field=READ} + jmp?(L3) INIT: in: {a=D} out: {a=D} + d(get() { return field }) INIT: in: {a=I?} out: {a=I?} L3 [after local declaration]: jmp?(L6) INIT: in: {a=D} out: {a=D} - d(set(v: Int) { field = v }) INIT: in: {a=I?, field=I} out: {a=I?, field=I} USE: in: {field=ONLY_WRITTEN_NEVER_READ} out: {field=ONLY_WRITTEN_NEVER_READ} + d(set(v: Int) { field = v }) INIT: in: {a=I?} out: {a=I?} L1: L2 [after local class]: L6 [after local declaration]: @@ -28,7 +28,7 @@ L6 [after local declaration]: error: sink: - INIT: in: {field=I} out: {field=I} USE: in: {} out: {} + USE: in: {} out: {} ===================== == get_a == get() { @@ -37,8 +37,8 @@ get() { --------------------- L4: 3 INIT: in: {a=D} out: {a=D} - 4 mark({ return field }) USE: in: {field=READ} out: {field=READ} - r(field) -> USE: in: {} out: {field=READ} + 4 mark({ return field }) + r(field) -> ret(*|) L5 L5: 3 @@ -54,16 +54,16 @@ set(v: Int) { --------------------- L7: 3 INIT: in: {a=D} out: {a=D} - v(v: Int) INIT: in: {a=D} out: {a=D, v=D} - magic[FAKE_INITIALIZER](v: Int) -> INIT: in: {a=D, v=D} out: {a=D, v=D} - w(v|) INIT: in: {a=D, v=D} out: {a=D, v=ID} - 4 mark({ field = v }) INIT: in: {a=D, v=ID} out: {a=D, v=ID} USE: in: {field=ONLY_WRITTEN_NEVER_READ, v=READ} out: {field=ONLY_WRITTEN_NEVER_READ, v=READ} - r(v) -> USE: in: {field=ONLY_WRITTEN_NEVER_READ} out: {field=ONLY_WRITTEN_NEVER_READ, v=READ} - w(field|) INIT: in: {a=D, v=ID} out: {a=D, field=I, v=ID} USE: in: {} out: {field=ONLY_WRITTEN_NEVER_READ} + v(v: Int) INIT: in: {a=D} out: {a=D} + magic[FAKE_INITIALIZER](v: Int) -> INIT: in: {a=D} out: {a=D} + w(v|) INIT: in: {a=D} out: {a=D} + 4 mark({ field = v }) INIT: in: {a=D} out: {a=D} + r(v) -> + w(field|) L8: - 3 INIT: in: {a=D, field=I, v=ID} out: {a=D, field=I, v=ID} + 3 error: INIT: in: {} out: {} sink: - INIT: in: {a=I?, field=I, v=I?} out: {a=I?, field=I, v=I?} USE: in: {} out: {} + INIT: in: {a=I?} out: {a=I?} USE: in: {} out: {} ===================== diff --git a/compiler/testData/cfg-variables/lexicalScopes/tryScope.instructions b/compiler/testData/cfg-variables/lexicalScopes/tryScope.instructions index 8d5d8633284..ac9e198e8b6 100644 --- a/compiler/testData/cfg-variables/lexicalScopes/tryScope.instructions +++ b/compiler/testData/cfg-variables/lexicalScopes/tryScope.instructions @@ -26,33 +26,33 @@ L0: call(foo(), foo) -> 2 jmp?(L2) jmp?(L3) - jmp(L4) USE: in: {} out: {} + jmp(L4) L2 [onException]: - 3 v(e: Exception) INIT: in: {} out: {e=D} - magic[FAKE_INITIALIZER](e: Exception) -> INIT: in: {e=D} out: {e=D} - w(e|) INIT: in: {e=D} out: {e=ID} - 4 mark({ val a = e }) INIT: in: {e=ID} out: {e=ID} - v(val a = e) INIT: in: {e=ID} out: {a=D, e=ID} USE: in: {e=READ} out: {e=READ} - r(e) -> INIT: in: {a=D, e=ID} out: {a=D, e=ID} USE: in: {} out: {e=READ} - w(a|) INIT: in: {a=D, e=ID} out: {a=ID, e=ID} - 3 jmp(L4) INIT: in: {e=ID} out: {e=ID} + 3 v(e: Exception) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](e: Exception) -> INIT: in: {} out: {} + w(e|) INIT: in: {} out: {} + 4 mark({ val a = e }) INIT: in: {} out: {} + v(val a = e) INIT: in: {} out: {} + r(e) -> INIT: in: {} out: {} + w(a|) INIT: in: {} out: {} + 3 jmp(L4) INIT: in: {} out: {} L4 [afterCatches]: - 2 jmp(L5) INIT: in: {} out: {} + 2 jmp(L5) L3 [onExceptionToFinallyBlock]: L6 [start finally]: 3 mark({ val a = 1 }) - v(val a = 1) INIT: in: {} out: {a=D} - r(1) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} + v(val a = 1) INIT: in: {} out: {} + r(1) -> INIT: in: {} out: {} + w(a|) INIT: in: {} out: {} L7 [finish finally]: 2 jmp(error) INIT: in: {} out: {} L5 [skipFinallyToErrorBlock]: L8 [copy of L3, onExceptionToFinallyBlock]: 3 mark({ val a = 1 }) - v(val a = 1) INIT: in: {} out: {a=D} - r(1) -> INIT: in: {a=D} out: {a=D} - w(a|) INIT: in: {a=D} out: {a=ID} - 2 merge(try { foo() } catch (e: Exception) { val a = e } finally { val a = 1 }|, !) -> INIT: in: {} out: {} + v(val a = 1) + r(1) -> + w(a|) + 2 merge(try { foo() } catch (e: Exception) { val a = e } finally { val a = 1 }|, !) -> mark("after") r("after") -> L1: @@ -60,5 +60,5 @@ L1: error: sink: - USE: in: {} out: {} + USE: in: {} out: {} ===================== diff --git a/compiler/testData/cli/js/jsHelp.out b/compiler/testData/cli/js/jsHelp.out index c1334ac1393..f76e57906fe 100644 --- a/compiler/testData/cli/js/jsHelp.out +++ b/compiler/testData/cli/js/jsHelp.out @@ -10,11 +10,10 @@ where possible options include: -output-postfix Path to file which will be added to the end of output file -output-prefix Path to file which will be added to the beginning of output file -source-map Generate source map + -source-map-base-dirs Base directories which are used to calculate relative paths to source files in source map -source-map-embed-sources { always, never, inlining } Embed source files into source map -source-map-prefix Prefix for paths in a source map - -source-map-source-roots - Base directories which are used to calculate relative paths to source files in source map -target { v5 } Generate JS files for specific ECMA version -api-version Allow to use declarations only from the specified version of bundled libraries -X Print a synopsis of advanced options diff --git a/compiler/testData/cli/js/sourceMapDuplicateRelativePaths.args b/compiler/testData/cli/js/sourceMapDuplicateRelativePaths.args index e99539d99f3..77f63052fe4 100644 --- a/compiler/testData/cli/js/sourceMapDuplicateRelativePaths.args +++ b/compiler/testData/cli/js/sourceMapDuplicateRelativePaths.args @@ -1,7 +1,7 @@ $TESTDATA_DIR$/sourceMapDuplicatePath/ -no-stdlib -source-map --source-map-source-roots +-source-map-base-dirs $TESTDATA_DIR$/sourceMapDuplicatePath/foo:$TESTDATA_DIR$/sourceMapDuplicatePath/bar -output $TEMP_DIR$/out.js diff --git a/compiler/testData/cli/js/sourceMapRootManual.args b/compiler/testData/cli/js/sourceMapRootManual.args index 92d3231bc81..e280b72da6f 100644 --- a/compiler/testData/cli/js/sourceMapRootManual.args +++ b/compiler/testData/cli/js/sourceMapRootManual.args @@ -2,7 +2,7 @@ $TESTDATA_DIR$/sourceMapRoot/foo/file1.kt $TESTDATA_DIR$/sourceMapRoot/bar/file2.kt -no-stdlib -source-map --source-map-source-roots +-source-map-base-dirs $TESTDATA_DIR$/ -output $TEMP_DIR$/out.js diff --git a/compiler/testData/cli/js/sourceMapRootMissing.args b/compiler/testData/cli/js/sourceMapRootMissing.args index 1afe84d1637..b7142ce5ce6 100644 --- a/compiler/testData/cli/js/sourceMapRootMissing.args +++ b/compiler/testData/cli/js/sourceMapRootMissing.args @@ -4,7 +4,7 @@ $TESTDATA_DIR$/sourceMapRoot/bar/baz/file3.kt $TESTDATA_DIR$/sourceMapRoot/foo/baz/file4.kt -no-stdlib -source-map --source-map-source-roots +-source-map-base-dirs $TESTDATA_DIR$/sourceMapRoot/foo -output $TEMP_DIR$/out.js diff --git a/compiler/testData/cli/js/sourceMapRootMultiple.args b/compiler/testData/cli/js/sourceMapRootMultiple.args index 1cc53c0a34b..6e122e374a2 100644 --- a/compiler/testData/cli/js/sourceMapRootMultiple.args +++ b/compiler/testData/cli/js/sourceMapRootMultiple.args @@ -2,7 +2,7 @@ $TESTDATA_DIR$/sourceMapRoot/foo/file1.kt $TESTDATA_DIR$/sourceMapRoot/bar/file2.kt -no-stdlib -source-map --source-map-source-roots +-source-map-base-dirs $TESTDATA_DIR$/foo:$TESTDATA_DIR$/bar -output $TEMP_DIR$/out.js diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index e8a58b632fa..e2842d9644a 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -9,7 +9,8 @@ where advanced options include: -Xmultifile-parts-inherit Compile multifile classes as a hierarchy of parts and facade -Xmodule-path= Paths where to find Java 9+ modules -Xjavac-arguments= Java compiler arguments - -Xjsr305={ignore|strict|warn} Specify global behavior for JSR-305 nullability annotations: ignore, treat as other supported nullability annotations, or report a warning + -Xjsr305={ignore|strict|warn}|under-migration:{ignore-strict-warn}|@:{ignore|strict|warn} + Specify behaviors for JSR-305 nullability annotations for: global, annotated with @UnderMigration or custom annotation with specific value: ignore, treat as other supported nullability annotations, or report a warning. Note that strict value is experimental yet -Xload-builtins-from-dependencies Load definitions of built-in declarations from module dependencies, instead of from the compiler -Xno-call-assertions Don't generate not-null assertions for arguments of platform types diff --git a/compiler/testData/cli/jvm/jsr305/Annotated.java b/compiler/testData/cli/jvm/jsr305/Annotated.java new file mode 100644 index 00000000000..4e63f6ca5bb --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305/Annotated.java @@ -0,0 +1,8 @@ + +public class Annotated { + public void foo(@MyNonnull String x) { + } + + public void bar(@MyMigrationNonnull String x) { + } +} \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jsr305/DefaultAnnotated.java b/compiler/testData/cli/jvm/jsr305/DefaultAnnotated.java new file mode 100644 index 00000000000..f47ac320289 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305/DefaultAnnotated.java @@ -0,0 +1,6 @@ + +@MyNonnullApi +public class DefaultAnnotated { + public void foo(String x) { + } +} \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jsr305/MyMigrationNonnull.java b/compiler/testData/cli/jvm/jsr305/MyMigrationNonnull.java new file mode 100644 index 00000000000..849fa721aeb --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305/MyMigrationNonnull.java @@ -0,0 +1,15 @@ +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +@Documented +@TypeQualifierNickname +@Nonnull(when = When.ALWAYS) +@Retention(RetentionPolicy.RUNTIME) +@kotlin.annotations.jvm.UnderMigration(status = MigrationStatus.STRICT) +public @interface MyMigrationNonnull { +} \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jsr305/MyNonnull.java b/compiler/testData/cli/jvm/jsr305/MyNonnull.java new file mode 100644 index 00000000000..0368297c0f2 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305/MyNonnull.java @@ -0,0 +1,15 @@ +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +@Documented +@TypeQualifierNickname +@Nonnull(when = When.ALWAYS) +@Retention(RetentionPolicy.RUNTIME) +public @interface MyNonnull { + +} \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jsr305/MyNonnullApi.java b/compiler/testData/cli/jvm/jsr305/MyNonnullApi.java new file mode 100644 index 00000000000..e4b2a0012b7 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305/MyNonnullApi.java @@ -0,0 +1,14 @@ + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.meta.TypeQualifierDefault; + +@Retention(RetentionPolicy.RUNTIME) +@Documented +@MyMigrationNonnull +@TypeQualifierDefault({ ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD }) +public @interface MyNonnullApi { +} \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jsr305AllIgnore.args b/compiler/testData/cli/jvm/jsr305AllIgnore.args new file mode 100644 index 00000000000..741bee0bf80 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305AllIgnore.args @@ -0,0 +1,7 @@ +-Xjsr305=ignore +-Xjsr305=under-migration:ignore +$TESTDATA_DIR$/jsr305Migration.kt +$TESTDATA_DIR$/jsr305 +$FOREIGN_ANNOTATIONS_DIR$ +-d +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/jsr305AllIgnore.out b/compiler/testData/cli/jvm/jsr305AllIgnore.out new file mode 100644 index 00000000000..d86bac9de59 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305AllIgnore.out @@ -0,0 +1 @@ +OK diff --git a/compiler/testData/cli/jvm/jsr305DefaultMigration.args b/compiler/testData/cli/jvm/jsr305DefaultMigration.args new file mode 100644 index 00000000000..7213fe2039e --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305DefaultMigration.args @@ -0,0 +1,5 @@ +$TESTDATA_DIR$/jsr305DefaultMigration.kt +$TESTDATA_DIR$/jsr305 +$FOREIGN_ANNOTATIONS_DIR$ +-d +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/jsr305DefaultMigration.kt b/compiler/testData/cli/jvm/jsr305DefaultMigration.kt new file mode 100644 index 00000000000..e5c91d3ed6d --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305DefaultMigration.kt @@ -0,0 +1,3 @@ +fun test(annotated: DefaultAnnotated) { + annotated.foo(null) +} \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jsr305DefaultMigration.out b/compiler/testData/cli/jvm/jsr305DefaultMigration.out new file mode 100644 index 00000000000..dfc596b5951 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305DefaultMigration.out @@ -0,0 +1,4 @@ +compiler/testData/cli/jvm/jsr305DefaultMigration.kt:2:19: error: null can not be a value of a non-null type String + annotated.foo(null) + ^ +COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/jsr305FqNameIgnore.args b/compiler/testData/cli/jvm/jsr305FqNameIgnore.args new file mode 100644 index 00000000000..e2c1b96fba0 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305FqNameIgnore.args @@ -0,0 +1,6 @@ +-Xjsr305=@MyNonnull:ignore +$TESTDATA_DIR$/jsr305Migration.kt +$TESTDATA_DIR$/jsr305 +$FOREIGN_ANNOTATIONS_DIR$ +-d +$TEMP_DIR$ \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jsr305FqNameIgnore.out b/compiler/testData/cli/jvm/jsr305FqNameIgnore.out new file mode 100644 index 00000000000..f64ed0aa7f6 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305FqNameIgnore.out @@ -0,0 +1,4 @@ +compiler/testData/cli/jvm/jsr305Migration.kt:3:19: error: null can not be a value of a non-null type String + annotated.bar(null) + ^ +COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/jsr305FqNameStrict.args b/compiler/testData/cli/jvm/jsr305FqNameStrict.args new file mode 100644 index 00000000000..4ec9b759945 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305FqNameStrict.args @@ -0,0 +1,6 @@ +-Xjsr305=@MyNonnull:strict +$TESTDATA_DIR$/jsr305Migration.kt +$TESTDATA_DIR$/jsr305 +$FOREIGN_ANNOTATIONS_DIR$ +-d +$TEMP_DIR$ \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jsr305FqNameStrict.out b/compiler/testData/cli/jvm/jsr305FqNameStrict.out new file mode 100644 index 00000000000..d3a633a1fe1 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305FqNameStrict.out @@ -0,0 +1,7 @@ +compiler/testData/cli/jvm/jsr305Migration.kt:2:19: error: null can not be a value of a non-null type String + annotated.foo(null) + ^ +compiler/testData/cli/jvm/jsr305Migration.kt:3:19: error: null can not be a value of a non-null type String + annotated.bar(null) + ^ +COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/jsr305Migration.kt b/compiler/testData/cli/jvm/jsr305Migration.kt new file mode 100644 index 00000000000..0fbd0819b25 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305Migration.kt @@ -0,0 +1,4 @@ +fun test(annotated: Annotated) { + annotated.foo(null) + annotated.bar(null) +} \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jsr305MigrationDefault.args b/compiler/testData/cli/jvm/jsr305MigrationDefault.args new file mode 100644 index 00000000000..91172f4fb6b --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305MigrationDefault.args @@ -0,0 +1,5 @@ +$TESTDATA_DIR$/jsr305Migration.kt +$TESTDATA_DIR$/jsr305 +$FOREIGN_ANNOTATIONS_DIR$ +-d +$TEMP_DIR$ \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jsr305MigrationDefault.out b/compiler/testData/cli/jvm/jsr305MigrationDefault.out new file mode 100644 index 00000000000..f64ed0aa7f6 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305MigrationDefault.out @@ -0,0 +1,4 @@ +compiler/testData/cli/jvm/jsr305Migration.kt:3:19: error: null can not be a value of a non-null type String + annotated.bar(null) + ^ +COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.args b/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.args new file mode 100644 index 00000000000..b7dc94756c2 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.args @@ -0,0 +1,6 @@ +-Xjsr305=@MyMigrationNonnull:ignore +$TESTDATA_DIR$/jsr305Migration.kt +$TESTDATA_DIR$/jsr305 +$FOREIGN_ANNOTATIONS_DIR$ +-d +$TEMP_DIR$ \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.out b/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.out new file mode 100644 index 00000000000..6a6ee78e833 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.out @@ -0,0 +1,4 @@ +compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin + annotated.foo(null) + ^ +OK diff --git a/compiler/testData/cli/jvm/jsr305MigrationIgnore.args b/compiler/testData/cli/jvm/jsr305MigrationIgnore.args new file mode 100644 index 00000000000..3a47b6f4aae --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305MigrationIgnore.args @@ -0,0 +1,6 @@ +-Xjsr305=under-migration:ignore +$TESTDATA_DIR$/jsr305Migration.kt +$TESTDATA_DIR$/jsr305 +$FOREIGN_ANNOTATIONS_DIR$ +-d +$TEMP_DIR$ \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jsr305MigrationIgnore.out b/compiler/testData/cli/jvm/jsr305MigrationIgnore.out new file mode 100644 index 00000000000..6a6ee78e833 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305MigrationIgnore.out @@ -0,0 +1,4 @@ +compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin + annotated.foo(null) + ^ +OK diff --git a/compiler/testData/cli/jvm/jsr305MigrationWarn.args b/compiler/testData/cli/jvm/jsr305MigrationWarn.args new file mode 100644 index 00000000000..9274345ed92 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305MigrationWarn.args @@ -0,0 +1,6 @@ +-Xjsr305=under-migration:warn +$TESTDATA_DIR$/jsr305Migration.kt +$TESTDATA_DIR$/jsr305 +$FOREIGN_ANNOTATIONS_DIR$ +-d +$TEMP_DIR$ \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jsr305MigrationWarn.out b/compiler/testData/cli/jvm/jsr305MigrationWarn.out new file mode 100644 index 00000000000..aa2bec44ea5 --- /dev/null +++ b/compiler/testData/cli/jvm/jsr305MigrationWarn.out @@ -0,0 +1,7 @@ +compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin + annotated.foo(null) + ^ +compiler/testData/cli/jvm/jsr305Migration.kt:3:19: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin + annotated.bar(null) + ^ +OK diff --git a/compiler/testData/cli/jvm/wrongXjsr305.args b/compiler/testData/cli/jvm/wrongXjsr305.args new file mode 100644 index 00000000000..1ba791849e4 --- /dev/null +++ b/compiler/testData/cli/jvm/wrongXjsr305.args @@ -0,0 +1,12 @@ +$TESTDATA_DIR$/simple.kt +-d +$TEMP_DIR$ +-Xjsr305=enable +-Xjsr305=under-migration\:stct +-Xjsr305=@hello\:warning +-Xjsr305=@hello\:warn +-Xjsr305=@hello\:ignore +-Xjsr305=strict +-Xjsr305=ignore +-Xjsr305=under-migration\:ignore +-Xjsr305=under-migration\:strict diff --git a/compiler/testData/cli/jvm/wrongXjsr305.out b/compiler/testData/cli/jvm/wrongXjsr305.out new file mode 100644 index 00000000000..78ec5fb7b0f --- /dev/null +++ b/compiler/testData/cli/jvm/wrongXjsr305.out @@ -0,0 +1,8 @@ +warning: option 'enable' for -Xjsr305 flag is deprecated. Please use 'strict' instead +error: unrecognized -Xjsr305 value: under-migration:stct +error: unrecognized -Xjsr305 value: @hello:warning +error: conflict duplicating -Xjsr305 value: @hello:warn, @hello:ignore +error: conflict duplicating -Xjsr305 value: strict, strict +error: conflict duplicating -Xjsr305 value: strict, ignore +error: conflict duplicating -Xjsr305 value: under-migration:ignore, under-migration:strict +COMPILATION_ERROR diff --git a/compiler/testData/codegen/box/constructorCall/inlineFunInConstructorCallEvaluationOrder.kt b/compiler/testData/codegen/box/constructorCall/inlineFunInConstructorCallEvaluationOrder.kt new file mode 100644 index 00000000000..6a07675236f --- /dev/null +++ b/compiler/testData/codegen/box/constructorCall/inlineFunInConstructorCallEvaluationOrder.kt @@ -0,0 +1,40 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME +// FILE: test.kt +fun box(): String { + Foo( + logged("i", 1.let { it }), + logged("j", + Foo( + logged("k", 2.let { it }), + null + ) + ) + ) + + val result = log.toString() + if (result != "ikj") return "Fail: '$result'" + + return "OK" +} + +// FILE: util.kt +val log = StringBuilder() + +fun logged(msg: String, value: T): T { + log.append(msg) + return value +} + +// FILE: Foo.kt +class Foo(i: Int, j: Foo?) { + init { + log.append("") + } + + companion object { + init { + log.append("") + } + } +} diff --git a/compiler/testData/codegen/box/constructorCall/inlineFunInInnerClassConstructorCall.kt b/compiler/testData/codegen/box/constructorCall/inlineFunInInnerClassConstructorCall.kt new file mode 100644 index 00000000000..9292242e2b6 --- /dev/null +++ b/compiler/testData/codegen/box/constructorCall/inlineFunInInnerClassConstructorCall.kt @@ -0,0 +1,43 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME +// FILE: test.kt +fun box(): String { + Outer().Inner( + logged("i;", 1.let { it }), + logged("j;", 2.let { it }) + ) + + val result = log.toString() + if (result != "Foo.;i;j;Foo.;Inner.;") return "Fail: '$result'" + + return "OK" +} + +// FILE: util.kt +val log = StringBuilder() + +fun logged(msg: String, value: T): T { + log.append(msg) + return value +} + +// FILE: Foo.kt +open class Foo { + init { + log.append("Foo.;") + } + + companion object { + init { + log.append("Foo.;") + } + } +} + +class Outer { + inner class Inner(val x: Int, val y: Int) : Foo() { + init { + log.append("Inner.;") + } + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/constructorCall/inlineFunInLocalClassConstructorCall.kt b/compiler/testData/codegen/box/constructorCall/inlineFunInLocalClassConstructorCall.kt new file mode 100644 index 00000000000..7061885f7aa --- /dev/null +++ b/compiler/testData/codegen/box/constructorCall/inlineFunInLocalClassConstructorCall.kt @@ -0,0 +1,41 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME +// FILE: test.kt +fun box(): String { + class Local(val i: Int, val j: Int) : Foo() { + init { + log.append("Local.;") + } + } + + Local( + logged("i;", 1.let { it }), + logged("j;", 2.let { it }) + ) + + val result = log.toString() + if (result != "Foo.;i;j;Foo.;Local.;") return "Fail: '$result'" + + return "OK" +} + +// FILE: util.kt +val log = StringBuilder() + +fun logged(msg: String, value: T): T { + log.append(msg) + return value +} + +// FILE: Foo.kt +open class Foo { + init { + log.append("Foo.;") + } + + companion object { + init { + log.append("Foo.;") + } + } +} diff --git a/compiler/testData/codegen/box/constructorCall/regularConstructorCallEvaluationOrder.kt b/compiler/testData/codegen/box/constructorCall/regularConstructorCallEvaluationOrder.kt new file mode 100644 index 00000000000..dcba51be98f --- /dev/null +++ b/compiler/testData/codegen/box/constructorCall/regularConstructorCallEvaluationOrder.kt @@ -0,0 +1,32 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME +// FILE: test.kt +fun box(): String { + Foo(logged("i", 1), logged("j", 2)) + + val result = log.toString() + if (result != "ij") return "Fail: '$result'" + + return "OK" +} + +// FILE: util.kt +val log = StringBuilder() + +fun logged(msg: String, value: T): T { + log.append(msg) + return value +} + +// FILE: Foo.kt +class Foo(i: Int, j: Int) { + init { + log.append("") + } + + companion object { + init { + log.append("") + } + } +} diff --git a/compiler/testData/codegen/box/constructorCall/tryCatchInConstructorCallEvaluationOrder.kt b/compiler/testData/codegen/box/constructorCall/tryCatchInConstructorCallEvaluationOrder.kt new file mode 100644 index 00000000000..4e3e586d5c4 --- /dev/null +++ b/compiler/testData/codegen/box/constructorCall/tryCatchInConstructorCallEvaluationOrder.kt @@ -0,0 +1,35 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME +// FILE: test.kt +fun box(): String { + Foo( + logged("i", try { 1 } catch (e: Exception) { 42 }), + logged("j", 2) + ) + + val result = log.toString() + if (result != "ij") return "Fail: '$result'" + + return "OK" +} + +// FILE: util.kt +val log = StringBuilder() + +fun logged(msg: String, value: T): T { + log.append(msg) + return value +} + +// FILE: Foo.kt +class Foo(i: Int, j: Int) { + init { + log.append("") + } + + companion object { + init { + log.append("") + } + } +} diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModule.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModule.kt new file mode 100644 index 00000000000..ad5db0563d9 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModule.kt @@ -0,0 +1,69 @@ +// IGNORE_BACKEND: NATIVE +// WITH_COROUTINES +// WITH_RUNTIME + +// MODULE: lib(support) +// FILE: lib.kt + +import helpers.* +import kotlin.coroutines.experimental.* +import kotlin.coroutines.experimental.intrinsics.* + +var continuation: () -> Unit = { } +var log = "" +var finished = false + +suspend fun foo(v: T): T = suspendCoroutineOrReturn { x -> + continuation = { + x.resume(v) + } + log += "foo($v);" + COROUTINE_SUSPENDED +} + +inline suspend fun bar(v: String) { + log += "before bar($v);" + foo("1:$v") + log += "inside bar($v);" + foo("2:$v") + log += "after bar($v);" +} + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(handleResultContinuation { + continuation = { } + finished = true + }) +} + +// MODULE: main(lib) +// FILE: main.kt + +import kotlin.coroutines.experimental.* +import kotlin.coroutines.experimental.intrinsics.* + +suspend fun baz() { + bar("A") + log += "between bar;" + bar("B") +} + +val expectedString = + "before bar(A);foo(1:A);@;inside bar(A);foo(2:A);@;after bar(A);" + + "between bar;" + + "before bar(B);foo(1:B);@;inside bar(B);foo(2:B);@;after bar(B);" + +fun box(): String { + builder { + baz() + } + + while (!finished) { + log += "@;" + continuation() + } + + if (log != expectedString) return "fail: $log" + + return "OK" +} diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleOverride.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleOverride.kt new file mode 100644 index 00000000000..bc9a47a50f5 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleOverride.kt @@ -0,0 +1,80 @@ +// IGNORE_BACKEND: NATIVE +// IGNORE_BACKEND: JVM +// WITH_COROUTINES +// WITH_RUNTIME + +// MODULE: lib(support) +// FILE: lib.kt + +import helpers.* +import kotlin.coroutines.experimental.* +import kotlin.coroutines.experimental.intrinsics.* + +var continuation: () -> Unit = { } +var log = "" +var finished = false + +suspend fun foo(v: T): T = suspendCoroutineOrReturn { x -> + continuation = { + x.resume(v) + } + log += "foo($v);" + COROUTINE_SUSPENDED +} + +interface I { + suspend fun bar() +} + +class A(val v: String) : I { + override inline suspend fun bar() { + log += "before bar($v);" + foo("1:$v") + log += "inside bar($v);" + foo("2:$v") + log += "after bar($v);" + } +} + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(handleResultContinuation { + continuation = { } + finished = true + }) +} + +// MODULE: main(lib) +// FILE: main.kt + +import kotlin.coroutines.experimental.* +import kotlin.coroutines.experimental.intrinsics.* + +suspend fun baz() { + val a = A("A") + a.bar() + + log += "between bar;" + + val b: I = A("B") + b.bar() +} + +val expectedString = + "before bar(A);foo(1:A);@;inside bar(A);foo(2:A);@;after bar(A);" + + "between bar;" + + "before bar(B);foo(1:B);@;inside bar(B);foo(2:B);@;after bar(B);" + +fun box(): String { + builder { + baz() + } + + while (!finished) { + log += "@;" + continuation() + } + + if (log != expectedString) return "fail: $log" + + return "OK" +} diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithController.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithController.kt new file mode 100644 index 00000000000..902ef8e991f --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithController.kt @@ -0,0 +1,77 @@ +// IGNORE_BACKEND: NATIVE +// WITH_COROUTINES +// WITH_RUNTIME + +// MODULE: lib(support) +// FILE: lib.kt + +import helpers.* +import kotlin.coroutines.experimental.* +import kotlin.coroutines.experimental.intrinsics.* + +var continuation: () -> Unit = { } +var log = "" +var finished = false + +class C { + var v: String = "" + + inline suspend fun bar() { + log += "before bar($v);" + foo("1:$v") + log += "inside bar($v);" + foo("2:$v") + log += "after bar($v);" + } +} + +suspend fun foo(v: T): T = suspendCoroutineOrReturn { x -> + continuation = { + x.resume(v) + } + log += "foo($v);" + COROUTINE_SUSPENDED +} + +fun C.builder(c: suspend C.() -> Unit) { + c.startCoroutine(this, handleResultContinuation { + continuation = { } + finished = true + }) +} + +// MODULE: main(lib) +// FILE: main.kt + +import kotlin.coroutines.experimental.* +import kotlin.coroutines.experimental.intrinsics.* + +suspend fun C.baz() { + v = "A" + bar() + log += "between bar;" + v = "B" + bar() +} + +val expectedString = + "before bar(A);foo(1:A);@;inside bar(A);foo(2:A);@;after bar(A);" + + "between bar;" + + "before bar(B);foo(1:B);@;inside bar(B);foo(2:B);@;after bar(B);" + +fun box(): String { + var c = C() + + c.builder { + baz() + } + + while (!finished) { + log += "@;" + continuation() + } + + if (log != expectedString) return "fail: $log" + + return "OK" +} diff --git a/compiler/testData/codegen/box/defaultArguments/inheritedFromInterfaceViaAbstractSuperclass.kt b/compiler/testData/codegen/box/defaultArguments/inheritedFromInterfaceViaAbstractSuperclass.kt new file mode 100644 index 00000000000..b74007df30e --- /dev/null +++ b/compiler/testData/codegen/box/defaultArguments/inheritedFromInterfaceViaAbstractSuperclass.kt @@ -0,0 +1,17 @@ +interface I { + fun foo(x: Int = 23): String +} + +abstract class Base : I + +class C : Base(), I { + override fun foo(x: Int) = "C:$x" +} + +fun box(): String { + val x: I = C() + val r = x.foo() + ";" + x.foo(42) + if (r != "C:23;C:42") return "fail: $r" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/delegatedProperty/genericSetValueViaSyntheticAccessor.kt b/compiler/testData/codegen/box/delegatedProperty/genericSetValueViaSyntheticAccessor.kt new file mode 100644 index 00000000000..cfcaceb9ebc --- /dev/null +++ b/compiler/testData/codegen/box/delegatedProperty/genericSetValueViaSyntheticAccessor.kt @@ -0,0 +1,25 @@ +// FILE: Var.kt +package pvar + +open class PVar(private var value: T) { + protected operator fun getValue(thisRef: Any?, prop: Any?) = value + + protected operator fun setValue(thisRef: Any?, prop: Any?, newValue: T) { + value = newValue + } +} + +// FILE: test.kt +import pvar.* + +class C : PVar(42L) { + inner class Inner { + var x by this@C + } +} + +fun box(): String { + val inner = C().Inner() + inner.x = 1L + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/operatorConventions/kt20387.kt b/compiler/testData/codegen/box/operatorConventions/kt20387.kt new file mode 100644 index 00000000000..95fcaa70ec6 --- /dev/null +++ b/compiler/testData/codegen/box/operatorConventions/kt20387.kt @@ -0,0 +1,17 @@ +// FILE: test.kt +import base.* + +class Derived : Base() { + inner class Inner { + fun foo() = this@Derived[0L] + } +} + +fun box() = Derived().Inner().foo() + +// FILE: Base.kt +package base + +open class Base { + protected operator fun get(key: K) = "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt b/compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt new file mode 100644 index 00000000000..0fdbe711937 --- /dev/null +++ b/compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt @@ -0,0 +1,39 @@ +fun test1(): Long { + var s = 0L + for (i in 1L..4) { + s = s * 10 + i + } + return s +} + +fun test2(): Long { + var s = 0L + for (i in 1L..4.toShort()) { + s = s * 10 + i + } + return s +} + +fun testLI(a: Long, b: Int): Long { + var s = 0L + for (i in a..b) { + s = s * 10 + i + } + return s +} + +fun testLS(a: Long, b: Short): Long { + var s = 0L + for (i in a..b) { + s = s * 10 + i + } + return s +} + +fun box(): String { + if (test1() != 1234L) return "Fail 1" + if (test2() != 1234L) return "Fail 1" + if (testLI(1L, 4) != 1234L) return "Fail 2" + if (testLS(1L, 4.toShort()) != 1234L) return "Fail 2" + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/secondaryConstructors/withNonLocalReturn.kt b/compiler/testData/codegen/box/secondaryConstructors/withNonLocalReturn.kt index 2e56fdc0e88..0b0be6bbbac 100644 --- a/compiler/testData/codegen/box/secondaryConstructors/withNonLocalReturn.kt +++ b/compiler/testData/codegen/box/secondaryConstructors/withNonLocalReturn.kt @@ -1,6 +1,3 @@ -// TODO enable for JS backend too when KT-14549 will be fixed -// IGNORE_BACKEND: JS - inline fun run(block: () -> Unit) = block() class A { diff --git a/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt new file mode 100644 index 00000000000..9a97980a5a6 --- /dev/null +++ b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt @@ -0,0 +1,20 @@ +fun box(): String { + A.Nested().nestedA() + A.Nested().Inner().innerA() + A.companionA() + return "OK" +} + +class A private constructor(val x: T, val y: Int = 0) { + class Nested { + fun nestedA() = A(1L) + + inner class Inner { + fun innerA() = A(1L) + } + } + + companion object { + fun companionA() = A(1L) + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt new file mode 100644 index 00000000000..a5ffca91336 --- /dev/null +++ b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt @@ -0,0 +1,29 @@ +// FILE: test.kt +import b.B + +fun box() = + B().getOK() + +// FILE: a.kt +package a + +open class A { + protected fun getO(x: T) = "O" + protected fun getK(x: T) = "K" +} + +// FILE: b.kt +package b + +import a.A + +class B : A() { + inner class Inner { + fun innerGetO() = getO(0L) + } + + fun lambdaGetK() = { -> getK(0L) } + + fun getOK() = + Inner().innerGetO() + lambdaGetK().invoke() +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt new file mode 100644 index 00000000000..943d7e681cd --- /dev/null +++ b/compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt @@ -0,0 +1,29 @@ +// FILE: test.kt +import b.B + +fun box() = + B().getOK() + +// FILE: a.kt +package a + +open class A { + protected fun getO(x: T, z: String = "") = "O" + z + protected fun getK(x: T, z: String = "") = "K" + z +} + +// FILE: b.kt +package b + +import a.A + +class B : A() { + inner class Inner { + fun innerGetO() = getO(0L) + } + + fun lambdaGetK() = { -> getK(0L) } + + fun getOK() = + Inner().innerGetO() + lambdaGetK().invoke() +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/vararg/doNotCopyImmediatelyCreatedArrays.kt b/compiler/testData/codegen/box/vararg/doNotCopyImmediatelyCreatedArrays.kt new file mode 100644 index 00000000000..6cc4d47dc23 --- /dev/null +++ b/compiler/testData/codegen/box/vararg/doNotCopyImmediatelyCreatedArrays.kt @@ -0,0 +1,102 @@ +fun booleanVararg(vararg xs: Boolean) { + if (xs.size != 1 && xs[0] != true) throw AssertionError() +} + +fun byteVararg(vararg xs: Byte) { + if (xs.size != 1 && xs[0] != 1.toByte()) throw AssertionError() +} + +fun shortVararg(vararg xs: Short) { + if (xs.size != 1 && xs[0] != 1.toShort()) throw AssertionError() +} + +fun intVararg(vararg xs: Int) { + if (xs.size != 1 && xs[0] != 1) throw AssertionError() +} + +fun longVararg(vararg xs: Long) { + if (xs.size != 1 && xs[0] != 1L) throw AssertionError() +} + +fun floatVararg(vararg xs: Float) { + if (xs.size != 1 && xs[0] != 1.0f) throw AssertionError() +} + +fun doubleVararg(vararg xs: Double) { + if (xs.size != 1 && xs[0] != 1.0) throw AssertionError() +} + +fun anyVararg(vararg xs: Any?) { + if (xs.size != 1 && (xs[0] != 1 && xs[0] != null)) throw AssertionError() +} + +fun genericVararg(vararg xs: T) { + if (xs.size != 1 && (xs[0] != 1 && xs[0] != null)) throw AssertionError() +} + +fun box(): String { + booleanVararg(*booleanArrayOf(true)) + booleanVararg(*BooleanArray(1)) + booleanVararg(*BooleanArray(1) { true }) + booleanVararg(xs = *booleanArrayOf(true)) + booleanVararg(xs = *BooleanArray(1)) + booleanVararg(xs = *BooleanArray(1) { true }) + + byteVararg(*byteArrayOf(1)) + byteVararg(*ByteArray(1)) + byteVararg(*ByteArray(1) { 1 }) + byteVararg(xs = *byteArrayOf(1)) + byteVararg(xs = *ByteArray(1)) + byteVararg(xs = *ByteArray(1) { 1 }) + + shortVararg(*shortArrayOf(1)) + shortVararg(*ShortArray(1)) + shortVararg(*ShortArray(1) { 1 }) + shortVararg(xs = *shortArrayOf(1)) + shortVararg(xs = *ShortArray(1)) + shortVararg(xs = *ShortArray(1) { 1 }) + + intVararg(*intArrayOf(1)) + intVararg(*IntArray(1)) + intVararg(*IntArray(1) { 1 }) + intVararg(xs = *intArrayOf(1)) + intVararg(xs = *IntArray(1)) + intVararg(xs = *IntArray(1) { 1 }) + + longVararg(*longArrayOf(1L)) + longVararg(*LongArray(1)) + longVararg(*LongArray(1) { 1L }) + longVararg(xs = *longArrayOf(1L)) + longVararg(xs = *LongArray(1)) + longVararg(xs = *LongArray(1) { 1L }) + + floatVararg(*floatArrayOf(1.0f)) + floatVararg(*FloatArray(1)) + floatVararg(*FloatArray(1) { 1.0f }) + floatVararg(xs = *floatArrayOf(1.0f)) + floatVararg(xs = *FloatArray(1)) + floatVararg(xs = *FloatArray(1) { 1.0f }) + + doubleVararg(*doubleArrayOf(1.0)) + doubleVararg(*DoubleArray(1)) + doubleVararg(*DoubleArray(1) { 1.0 }) + doubleVararg(xs = *doubleArrayOf(1.0)) + doubleVararg(xs = *DoubleArray(1)) + doubleVararg(xs = *DoubleArray(1) { 1.0 }) + + anyVararg(*arrayOf(1)) + anyVararg(*Array(1) { 1 }) + anyVararg(*arrayOfNulls(1)) + anyVararg(xs = *arrayOf(1)) + anyVararg(xs = *Array(1) { 1 }) + anyVararg(xs = *arrayOfNulls(1)) + + genericVararg(*arrayOf(1)) + genericVararg(*Array(1) { 1 }) + genericVararg(*arrayOfNulls(1)) + genericVararg(xs = *arrayOf(1)) + genericVararg(xs = *Array(1) { 1 }) + genericVararg(xs = *arrayOfNulls(1)) + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/varargs/doNotCopyImmediatelyCreatedArrays.kt b/compiler/testData/codegen/bytecodeText/varargs/doNotCopyImmediatelyCreatedArrays.kt new file mode 100644 index 00000000000..fece3a4b4b6 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/varargs/doNotCopyImmediatelyCreatedArrays.kt @@ -0,0 +1,77 @@ +fun booleanVararg(vararg xs: Boolean) {} +fun byteVararg(vararg xs: Byte) {} +fun shortVararg(vararg xs: Short) {} +fun intVararg(vararg xs: Int) {} +fun longVararg(vararg xs: Long) {} +fun floatVararg(vararg xs: Float) {} +fun doubleVararg(vararg xs: Double) {} +fun anyVararg(vararg xs: Any?) {} +fun genericVararg(vararg xs: T) {} + +fun test() { + booleanVararg(*booleanArrayOf(true)) + booleanVararg(*BooleanArray(1)) + booleanVararg(*BooleanArray(1) { true }) + booleanVararg(xs = *booleanArrayOf(true)) + booleanVararg(xs = *BooleanArray(1)) + booleanVararg(xs = *BooleanArray(1) { true }) + + byteVararg(*byteArrayOf(1)) + byteVararg(*ByteArray(1)) + byteVararg(*ByteArray(1) { 1 }) + byteVararg(xs = *byteArrayOf(1)) + byteVararg(xs = *ByteArray(1)) + byteVararg(xs = *ByteArray(1) { 1 }) + + shortVararg(*shortArrayOf(1)) + shortVararg(*ShortArray(1)) + shortVararg(*ShortArray(1) { 1 }) + shortVararg(xs = *shortArrayOf(1)) + shortVararg(xs = *ShortArray(1)) + shortVararg(xs = *ShortArray(1) { 1 }) + + intVararg(*intArrayOf(1)) + intVararg(*IntArray(1)) + intVararg(*IntArray(1) { 1 }) + intVararg(xs = *intArrayOf(1)) + intVararg(xs = *IntArray(1)) + intVararg(xs = *IntArray(1) { 1 }) + + longVararg(*longArrayOf(1L)) + longVararg(*LongArray(1)) + longVararg(*LongArray(1) { 1L }) + longVararg(xs = *longArrayOf(1L)) + longVararg(xs = *LongArray(1)) + longVararg(xs = *LongArray(1) { 1L }) + + floatVararg(*floatArrayOf(1.0f)) + floatVararg(*FloatArray(1)) + floatVararg(*FloatArray(1) { 1.0f }) + floatVararg(xs = *floatArrayOf(1.0f)) + floatVararg(xs = *FloatArray(1)) + floatVararg(xs = *FloatArray(1) { 1.0f }) + + doubleVararg(*doubleArrayOf(1.0)) + doubleVararg(*DoubleArray(1)) + doubleVararg(*DoubleArray(1) { 1.0 }) + doubleVararg(xs = *doubleArrayOf(1.0)) + doubleVararg(xs = *DoubleArray(1)) + doubleVararg(xs = *DoubleArray(1) { 1.0 }) + + anyVararg(*arrayOf(1)) + anyVararg(*Array(1) { 1 }) + anyVararg(*arrayOfNulls(1)) + anyVararg(xs = *arrayOf(1)) + anyVararg(xs = *Array(1) { 1 }) + anyVararg(xs = *arrayOfNulls(1)) + + genericVararg(*arrayOf(1)) + genericVararg(*Array(1) { 1 }) + genericVararg(*arrayOfNulls(1)) + genericVararg(xs = *arrayOf(1)) + genericVararg(xs = *Array(1) { 1 }) + genericVararg(xs = *arrayOfNulls(1)) +} + +// 0 copyOf +// 0 clone \ No newline at end of file diff --git a/compiler/testData/compileKotlinAgainstKotlin/multifileClassWithTypealias.kt b/compiler/testData/compileKotlinAgainstKotlin/multifileClassWithTypealias.kt new file mode 100644 index 00000000000..f7ed63a5c3f --- /dev/null +++ b/compiler/testData/compileKotlinAgainstKotlin/multifileClassWithTypealias.kt @@ -0,0 +1,16 @@ +// IGNORE_BACKEND: NATIVE +// FILE: A.kt + +@file:[JvmName("Test") JvmMultifileClass] + +typealias S = String +typealias LS = List + +// FILE: B.kt + +import java.util.Arrays + +fun box(): S { + val l: LS = Arrays.asList("OK") + return l[0] +} diff --git a/compiler/testData/diagnostics/tests/DefaultValuesCheckWithoutBody.kt b/compiler/testData/diagnostics/tests/DefaultValuesCheckWithoutBody.kt index ac90467340b..217b1790e5d 100644 --- a/compiler/testData/diagnostics/tests/DefaultValuesCheckWithoutBody.kt +++ b/compiler/testData/diagnostics/tests/DefaultValuesCheckWithoutBody.kt @@ -6,4 +6,4 @@ abstract class Abst { abstract fun foo(x: Int = y, y: Int = x) } -fun extraDiagnostics(x: Int = y, y: Int) \ No newline at end of file +fun extraDiagnostics(x: Int = y, y: Int) diff --git a/compiler/testData/diagnostics/tests/DefaultValuesTypechecking.kt b/compiler/testData/diagnostics/tests/DefaultValuesTypechecking.kt index a6be46b2654..2ab8a0dbbbf 100644 --- a/compiler/testData/diagnostics/tests/DefaultValuesTypechecking.kt +++ b/compiler/testData/diagnostics/tests/DefaultValuesTypechecking.kt @@ -6,10 +6,10 @@ fun bar(x : Int = "", y : Int = x, z // KT-371 Resolve default parameters for constructors -class A(x : Int = y, y : Int = x) { // None of the references is resolved, no types checked - fun foo(bool: Boolean, a: Int = b, b: String = a) {} +class A(x : Int = y, y : Int = x) { // None of the references is resolved, no types checked + fun foo(bool: Boolean, a: Int = b, b: String = a) {} } val z = 3 -fun foo(x: Int = y, y: Int = x, i : Int = z): Int = x + y \ No newline at end of file +fun foo(x: Int = y, y: Int = x, i : Int = z): Int = x + y diff --git a/compiler/testData/diagnostics/tests/LValueAssignment.kt b/compiler/testData/diagnostics/tests/LValueAssignment.kt index 20f4baeea06..b98be9fd2e9 100644 --- a/compiler/testData/diagnostics/tests/LValueAssignment.kt +++ b/compiler/testData/diagnostics/tests/LValueAssignment.kt @@ -51,7 +51,7 @@ fun cannotBe() { 5 = 34 } -fun canBe(i0: Int, j: Int) { +fun canBe(i0: Int, j: Int) { var i = i0 (label@ i) = 34 @@ -61,7 +61,7 @@ fun canBe(i0: Int, j: Int) { (l@ a.a) = 3894 } -fun canBe2(j: Int) { +fun canBe2(j: Int) { (label@ j) = 34 } @@ -140,4 +140,4 @@ fun Array.checkThis() { abstract class Ab { abstract fun getArray() : Array -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/UninitializedOrReassignedVariables.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/UninitializedOrReassignedVariables.kt index 996e2b017c6..a0c29641d42 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/UninitializedOrReassignedVariables.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/UninitializedOrReassignedVariables.kt @@ -53,7 +53,7 @@ fun t2() { class A() {} -fun t4(a: A) { +fun t4(a: A) { a = A() } @@ -61,7 +61,7 @@ fun t4(a: A) { // reassigned vals fun t1() { - val a : Int = 1 + val a : Int = 1 a = 2 var b : Int = 1 @@ -83,7 +83,7 @@ enum class ProtocolState { fun t3() { val x: ProtocolState = ProtocolState.WAITING x = x.signal() - x = x.signal() //repeat for x + x = x.signal() //repeat for x } fun t4() { @@ -187,7 +187,7 @@ class AnonymousInitializers(var a: String, val b: String) { } } -fun reassignFunParams(a: Int) { +fun reassignFunParams(a: Int) { a = 1 } @@ -345,4 +345,4 @@ fun test(m : M) { fun test1(m : M) { m.x++ m.y-- -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInMultiDeclInFor.kt b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInMultiDeclInFor.kt index 1feb317b1f0..0911d17433c 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInMultiDeclInFor.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInMultiDeclInFor.kt @@ -8,7 +8,7 @@ class A { } fun foo(list: List) { - for (var (c1, c2, c3) in list) { + for (var (c1, c2, c3) in list) { c1 = 1 c3 + 1 } diff --git a/compiler/testData/diagnostics/tests/multiplatform/enum/constructorInHeaderEnum.kt b/compiler/testData/diagnostics/tests/multiplatform/enum/constructorInHeaderEnum.kt index 174d3d7af62..c45a1bbf519 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/enum/constructorInHeaderEnum.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/enum/constructorInHeaderEnum.kt @@ -4,12 +4,12 @@ expect enum class En(x: Int) { E1, - E2(42), + E2(42), ; constructor(s: String) } expect enum class En2 { - E1() + E1() } diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDefaultValuesInAnnotationViaTypealias.kt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDefaultValuesInAnnotationViaTypealias.kt new file mode 100644 index 00000000000..5d861a8e0fa --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDefaultValuesInAnnotationViaTypealias.kt @@ -0,0 +1,33 @@ +// !LANGUAGE: +MultiPlatformProjects +// MODULE: m1-common +// FILE: common.kt + +expect annotation class Foo1 +expect annotation class Foo2 +expect annotation class Foo3 +expect annotation class Foo4 + +// MODULE: m2-jvm(m1-common) + +// FILE: Bar1.java + +public @interface Bar1 { + String value() default ""; +} + +// FILE: Bar2.java + +public @interface Bar2 { + String value() default ""; + String path(); +} + +// FILE: jvm.kt + +actual typealias Foo1 = Bar1 + +actual typealias Foo4 = Bar2 + +actual annotation class Foo2(val p: String = "default") + +actual annotation class Foo3(val a: String = "a", val b: String = "b") \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDefaultValuesInAnnotationViaTypealias.txt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDefaultValuesInAnnotationViaTypealias.txt new file mode 100644 index 00000000000..048ecc935f6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDefaultValuesInAnnotationViaTypealias.txt @@ -0,0 +1,70 @@ +// -- Module: -- +package + +public final expect annotation class Foo1 : kotlin.Annotation { + public constructor Foo1() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final expect annotation class Foo2 : kotlin.Annotation { + public constructor Foo2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final expect annotation class Foo3 : kotlin.Annotation { + public constructor Foo3() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final expect annotation class Foo4 : kotlin.Annotation { + public constructor Foo4() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + + +// -- Module: -- +package + +public final annotation class Bar1 : kotlin.Annotation { + public constructor Bar1(/*0*/ value: kotlin.String = ...) + public final val value: kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final annotation class Bar2 : kotlin.Annotation { + public constructor Bar2(/*0*/ value: kotlin.String = ..., /*1*/ path: kotlin.String) + public final val path: kotlin.String + public final val value: kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final actual annotation class Foo2 : kotlin.Annotation { + public constructor Foo2(/*0*/ p: kotlin.String = ...) + public final val p: kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final actual annotation class Foo3 : kotlin.Annotation { + public constructor Foo3(/*0*/ a: kotlin.String = ..., /*1*/ b: kotlin.String = ...) + public final val a: kotlin.String + public final val b: kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} +public typealias Foo1 = Bar1 +public typealias Foo4 = Bar2 diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.kt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.kt new file mode 100644 index 00000000000..22c9574d25d --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.kt @@ -0,0 +1,14 @@ +// !LANGUAGE: +MultiPlatformProjects +// MODULE: m1-common +// FILE: common.kt + +expect class A { + fun foo() +} + +// MODULE: m1-jvm(m1-common) +// FILE: jvm.kt + +class A { + actual fun foo() {} +} diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.txt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.txt new file mode 100644 index 00000000000..8325a9782fb --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.txt @@ -0,0 +1,22 @@ +// -- Module: -- +package + +public final expect class A { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final expect fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + + +// -- Module: -- +package + +public final class A { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final actual fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/memberPropertyKinds.kt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/memberPropertyKinds.kt new file mode 100644 index 00000000000..74f469447a6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/memberPropertyKinds.kt @@ -0,0 +1,31 @@ +// !LANGUAGE: +MultiPlatformProjects +// MODULE: m1-common +// FILE: common.kt + +expect class Foo { + val justVal: String + var justVar: String + + val String.extensionVal: Unit + var T.genericExtensionVar: T + + val valWithGet: String + get + var varWithGetSet: String + get set + + val backingFieldVal: String = "no" + var backingFieldVar: String = "no" + + val customAccessorVal: String + get() = "no" + var customAccessorVar: String + get() = "no" + set(value) {} + + lateinit var lateinitVar: String + + val delegated: String by Delegate +} + +object Delegate { operator fun getValue(x: Any?, y: Any?): String = "" } diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/memberPropertyKinds.txt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/memberPropertyKinds.txt new file mode 100644 index 00000000000..e0c37021e86 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/memberPropertyKinds.txt @@ -0,0 +1,28 @@ +package + +public object Delegate { + private constructor Delegate() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final operator fun getValue(/*0*/ x: kotlin.Any?, /*1*/ y: kotlin.Any?): kotlin.String + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final expect class Foo { + public constructor Foo() + public expect final val backingFieldVal: kotlin.String = "no" + public expect final var backingFieldVar: kotlin.String + public expect final val customAccessorVal: kotlin.String + public expect final var customAccessorVar: kotlin.String + public expect final val delegated: kotlin.String + public expect final val justVal: kotlin.String + public expect final var justVar: kotlin.String + public expect final lateinit var lateinitVar: kotlin.String + public expect final val valWithGet: kotlin.String + public expect final var varWithGetSet: kotlin.String + public expect final val kotlin.String.extensionVal: kotlin.Unit + public expect final var T.genericExtensionVar: T + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/superClass.kt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/superClass.kt index 53929912f48..a43351ba9b3 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/headerClass/superClass.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/superClass.kt @@ -8,10 +8,16 @@ interface J expect class Foo : I, C, J +expect class Bar : C() + // MODULE: m2-jvm(m1-common) // FILE: jvm.kt actual class Foo : I, C(), J +actual class Bar + // MODULE: m3-js(m1-common) // FILE: js.kt actual class Foo : I, J, C() + +actual class Bar : C() diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/superClass.txt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/superClass.txt index 266507319ac..dabb0b756ca 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/headerClass/superClass.txt +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/superClass.txt @@ -1,6 +1,13 @@ // -- Module: -- package +public final expect class Bar : C { + public constructor Bar() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + public open class C { public constructor C() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -31,6 +38,13 @@ public interface J { // -- Module: -- package +public final actual class Bar { + public constructor Bar() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + public open class C { public constructor C() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -61,6 +75,13 @@ public interface J { // -- Module: -- package +public final actual class Bar : C { + public constructor Bar() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + public open class C { public constructor C() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/multiplatform/topLevelProperty/differentKindsOfProperties.kt b/compiler/testData/diagnostics/tests/multiplatform/topLevelProperty/differentKindsOfProperties.kt index 2183b91383f..e73e201c4b4 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/topLevelProperty/differentKindsOfProperties.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/topLevelProperty/differentKindsOfProperties.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +MultiPlatformProjects +// !LANGUAGE: +MultiPlatformProjects +LateinitTopLevelProperties // MODULE: m1-common // FILE: common.kt @@ -28,9 +28,9 @@ expect var customAccessorVar: String expect const val constVal: Int -expect lateinit var lateinitVar: String +expect lateinit var lateinitVar: String -expect val delegated: String by Delegate +expect val delegated: String by Delegate object Delegate { operator fun getValue(x: Any?, y: Any?): String = "" } fun test(): String { diff --git a/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormAnnDeprecation.kt b/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormAnnDeprecation.kt index eabb5fc4add..ed5bb6d1dd7 100644 --- a/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormAnnDeprecation.kt +++ b/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormAnnDeprecation.kt @@ -11,16 +11,16 @@ annotation class Ann(vararg val s: String) -@Ann(s = "value") +@Ann(s = "value") fun test1() {} -@Ann(s = *arrayOf("value")) +@Ann(s = *arrayOf("value")) fun test2() {} -@Ann(s = *["value"]) +@Ann(s = *["value"]) fun test3() {} -@JavaAnn(value = "value") +@JavaAnn(value = "value") fun test4() {} @JavaAnn("value", path = arrayOf("path")) diff --git a/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormFunDeprecation.kt b/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormFunDeprecation.kt index 1c3fca774c4..08784b1b5ef 100644 --- a/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormFunDeprecation.kt +++ b/compiler/testData/diagnostics/tests/varargs/assigningSingleElementsInNamedFormFunDeprecation.kt @@ -6,41 +6,41 @@ fun foo(vararg s: Int) {} open class Cls(vararg p: Long) fun test(i: IntArray) { - foo(s = 1) - foo(s = i) + foo(s = 1) + foo(s = i) foo(s = *i) - foo(s = intArrayOf(1)) + foo(s = intArrayOf(1)) foo(s = *intArrayOf(1)) foo(1) - Cls(p = 1) + Cls(p = 1) - class Sub : Cls(p = 1) + class Sub : Cls(p = 1) - val c = object : Cls(p = 1) {} + val c = object : Cls(p = 1) {} - foo(s = *intArrayOf(elements = 1)) + foo(s = *intArrayOf(elements = 1)) } fun anyFoo(vararg a: Any) {} fun testAny() { - anyFoo(a = "") - anyFoo(a = arrayOf("")) + anyFoo(a = "") + anyFoo(a = arrayOf("")) anyFoo(a = *arrayOf("")) } fun genFoo(vararg t: T) {} fun testGen() { - genFoo(t = 1) - genFoo(t = null) - genFoo>(t = arrayOf()) + genFoo(t = 1) + genFoo(t = null) + genFoo>(t = arrayOf()) genFoo>(t = *arrayOf(arrayOf())) - genFoo(t = "") - genFoo(t = arrayOf("")) + genFoo(t = "") + genFoo(t = arrayOf("")) genFoo(t = *arrayOf("")) } @@ -48,12 +48,12 @@ fun manyFoo(vararg v: Int) {} fun manyFoo(vararg s: String) {} fun testMany(a: Any) { - manyFoo(v = 1) - manyFoo(s = "") + manyFoo(v = 1) + manyFoo(s = "") manyFoo(a) - manyFoo(v = a) - manyFoo(s = a) - manyFoo(v = a as Int) - manyFoo(s = a as String) + manyFoo(v = a) + manyFoo(s = a) + manyFoo(v = a as Int) + manyFoo(s = a as String) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/jsCode/deleteOperation.kt b/compiler/testData/diagnostics/testsWithJsStdLib/jsCode/deleteOperation.kt new file mode 100644 index 00000000000..0d63a37f396 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/jsCode/deleteOperation.kt @@ -0,0 +1,8 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun foo(x: Any) { + js("delete x.foo;") + js("delete x['bar'];") + js("delete x.baz();") + js("delete this;") +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/jsCode/deleteOperation.txt b/compiler/testData/diagnostics/testsWithJsStdLib/jsCode/deleteOperation.txt new file mode 100644 index 00000000000..199e30b63e6 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/jsCode/deleteOperation.txt @@ -0,0 +1,3 @@ +package + +public fun foo(/*0*/ x: kotlin.Any): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/bridgeClash.kt b/compiler/testData/diagnostics/testsWithJsStdLib/name/bridgeClash.kt new file mode 100644 index 00000000000..6a9fb53452e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/name/bridgeClash.kt @@ -0,0 +1,18 @@ +interface I { + fun foo() +} + +interface J { + @JsName("bar") + fun foo() +} + +interface K : I, J { + override fun foo() +} + +interface L : K { + override fun foo() + + fun bar() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/bridgeClash.txt b/compiler/testData/diagnostics/testsWithJsStdLib/name/bridgeClash.txt new file mode 100644 index 00000000000..4d495cbd2d1 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/name/bridgeClash.txt @@ -0,0 +1,30 @@ +package + +public interface I { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface J { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @kotlin.js.JsName(name = "bar") public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface K : I, J { + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*2*/ fun foo(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface L : K { + public abstract fun bar(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/nameSwapInOverride.kt b/compiler/testData/diagnostics/testsWithJsStdLib/name/nameSwapInOverride.kt new file mode 100644 index 00000000000..6de82abc7aa --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/name/nameSwapInOverride.kt @@ -0,0 +1,21 @@ +interface I { + @JsName("bar") + fun foo() + + @JsName("foo") + fun bar() +} + +interface J { + fun foo() + + fun bar() +} + +class A : I, J { + // Duplicate diagnostics are expected here, since `bar()` function gets both `foo` and `bar` names and clashes with both + // names of `foo()` function. + override fun bar() {} + + override fun foo() {} +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/nameSwapInOverride.txt b/compiler/testData/diagnostics/testsWithJsStdLib/name/nameSwapInOverride.txt new file mode 100644 index 00000000000..d5ac7be2757 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/name/nameSwapInOverride.txt @@ -0,0 +1,26 @@ +package + +public final class A : I, J { + public constructor A() + public open override /*2*/ fun bar(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ fun foo(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface I { + @kotlin.js.JsName(name = "foo") public abstract fun bar(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @kotlin.js.JsName(name = "bar") public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface J { + public abstract fun bar(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/foreignAnnotations/testAnnotations/MyMigrationNonnull.java b/compiler/testData/foreignAnnotations/testAnnotations/MyMigrationNonnull.java new file mode 100644 index 00000000000..a328b21f353 --- /dev/null +++ b/compiler/testData/foreignAnnotations/testAnnotations/MyMigrationNonnull.java @@ -0,0 +1,18 @@ +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +import kotlin.annotations.jvm.*; + +@Documented +@TypeQualifierNickname +@Nonnull(when = When.ALWAYS) +@Retention(RetentionPolicy.RUNTIME) +@UnderMigration(status = MigrationStatus.WARN) +public @interface MyMigrationNonnull { + +} diff --git a/compiler/testData/foreignAnnotations/testAnnotations/MyMigrationNullable.java b/compiler/testData/foreignAnnotations/testAnnotations/MyMigrationNullable.java new file mode 100644 index 00000000000..421896ba05a --- /dev/null +++ b/compiler/testData/foreignAnnotations/testAnnotations/MyMigrationNullable.java @@ -0,0 +1,18 @@ +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +import kotlin.annotations.jvm.*; + +@Documented +@TypeQualifierNickname +@Nonnull(when = When.MAYBE) +@Retention(RetentionPolicy.RUNTIME) +@UnderMigration(status = MigrationStatus.WARN) +public @interface MyMigrationNullable { + +} \ No newline at end of file diff --git a/compiler/testData/foreignAnnotations/tests/irrelevantQualifierNicknames.kt b/compiler/testData/foreignAnnotations/tests/irrelevantQualifierNicknames.kt new file mode 100644 index 00000000000..dd7406c28c8 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/irrelevantQualifierNicknames.kt @@ -0,0 +1,85 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER + +// FILE: UnknownQualifier.java +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifier; +import javax.annotation.meta.When; + +@Documented +@TypeQualifier +@Retention(RetentionPolicy.RUNTIME) +public @interface UnknownQualifier { +} + +// FILE: UnknownQualifierNickname.java +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +@Documented +@TypeQualifierNickname +@UnknownQualifier +@Retention(RetentionPolicy.RUNTIME) +public @interface UnknownQualifierNickname { +} + +// FILE: UnknownQualifierDefault.java +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.ElementType; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierDefault; +import javax.annotation.meta.When; + +@Documented +@TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER}) +@UnknownQualifier +@Retention(RetentionPolicy.RUNTIME) +public @interface UnknownQualifierDefault { +} + +// FILE: UnknownQualifierNicknameDefault.java +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.ElementType; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierDefault; +import javax.annotation.meta.When; + +@Documented +@TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER}) +@UnknownQualifierNickname +@Retention(RetentionPolicy.RUNTIME) +public @interface UnknownQualifierNicknameDefault { +} + +// FILE: A.java + +import javax.annotation.*; + +@UnknownQualifierDefault +public class A { + @UnknownQualifierNicknameDefault + public static class B { + @UnknownQualifier + public static String foo(@UnknownQualifierNickname String x) { return null; } + } +} + +// FILE: main.kt + +fun main() { + A.B.foo(null).hashCode() +} diff --git a/compiler/testData/foreignAnnotations/tests/irrelevantQualifierNicknames.txt b/compiler/testData/foreignAnnotations/tests/irrelevantQualifierNicknames.txt new file mode 100644 index 00000000000..586eefba1c4 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/irrelevantQualifierNicknames.txt @@ -0,0 +1,48 @@ +package + +public fun main(): kotlin.Unit + +@UnknownQualifierDefault public open class A { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + @UnknownQualifierNicknameDefault public open class B { + public constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + @UnknownQualifier public open fun foo(/*0*/ @UnknownQualifierNickname x: kotlin.String!): kotlin.String! + } +} + +@kotlin.annotation.MustBeDocumented @javax.annotation.meta.TypeQualifier @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class UnknownQualifier : kotlin.Annotation { + public constructor UnknownQualifier() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@kotlin.annotation.MustBeDocumented @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.METHOD, ElementType.PARAMETER}) @UnknownQualifier @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class UnknownQualifierDefault : kotlin.Annotation { + public constructor UnknownQualifierDefault() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@kotlin.annotation.MustBeDocumented @javax.annotation.meta.TypeQualifierNickname @UnknownQualifier @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class UnknownQualifierNickname : kotlin.Annotation { + public constructor UnknownQualifierNickname() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@kotlin.annotation.MustBeDocumented @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.METHOD, ElementType.PARAMETER}) @UnknownQualifierNickname @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class UnknownQualifierNicknameDefault : kotlin.Annotation { + public constructor UnknownQualifierNicknameDefault() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305Ignore/parametersAreNonnullByDefault.kt b/compiler/testData/foreignAnnotations/tests/jsr305/ignore/parametersAreNonnullByDefault.kt similarity index 95% rename from compiler/testData/foreignAnnotations/tests/jsr305Ignore/parametersAreNonnullByDefault.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/ignore/parametersAreNonnullByDefault.kt index 177944fe363..88e688729da 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305Ignore/parametersAreNonnullByDefault.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/ignore/parametersAreNonnullByDefault.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// JSR305_ANNOTATIONS_IGNORE +// JSR305_GLOBAL_REPORT ignore // FILE: A.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305Ignore/parametersAreNonnullByDefault.txt b/compiler/testData/foreignAnnotations/tests/jsr305/ignore/parametersAreNonnullByDefault.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305Ignore/parametersAreNonnullByDefault.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/ignore/parametersAreNonnullByDefault.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305/nonNullNever.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nonNullNever.kt new file mode 100644 index 00000000000..a9b585a3f0e --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nonNullNever.kt @@ -0,0 +1,41 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// FILE: MyNullable.java +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +@Documented +@TypeQualifierNickname +@Nonnull(when = When.NEVER) +@Retention(RetentionPolicy.RUNTIME) +public @interface MyNullable { + +} + +// FILE: A.java + +import javax.annotation.*; +import javax.annotation.meta.When; + +public class A { + @Nonnull(when = When.NEVER) public String field = null; + + @MyNullable + public String foo(@Nonnull(when = When.NEVER) String x, @MyNullable CharSequence y) { + return ""; + } +} +// FILE: main.kt + +fun main(a: A) { + a.foo("", null)?.length + a.foo("", null).length + a.foo(null, "").length + + a.field?.length + a.field.length +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305/nonNullNever.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nonNullNever.txt new file mode 100644 index 00000000000..6b5bc77a4ea --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nonNullNever.txt @@ -0,0 +1,19 @@ +package + +public fun main(/*0*/ a: A): kotlin.Unit + +public open class A { + public constructor A() + @javax.annotation.Nonnull(when = When.NEVER) public final var field: kotlin.String? + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @MyNullable public open fun foo(/*0*/ @javax.annotation.Nonnull(when = When.NEVER) x: kotlin.String?, /*1*/ @MyNullable y: kotlin.CharSequence?): kotlin.String? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@kotlin.annotation.MustBeDocumented @javax.annotation.meta.TypeQualifierNickname @javax.annotation.Nonnull(when = When.NEVER) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class MyNullable : kotlin.Annotation { + public constructor MyNullable() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityNicknames.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityNicknames.kt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityNicknames.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityNicknames.kt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityNicknames.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityNicknames.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityNicknames.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityNicknames.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/arithmetic.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.kt similarity index 97% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/arithmetic.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.kt index 041b909cdb9..2d459415d0c 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/arithmetic.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.kt @@ -1,4 +1,4 @@ -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/arithmetic.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/arithmetic.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/array.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.kt similarity index 93% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/array.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.kt index 1d3361208c6..2b6861b617f 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/array.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.kt @@ -1,4 +1,4 @@ -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/array.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/array.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/assignToVar.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.kt similarity index 91% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/assignToVar.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.kt index 26c91535bb9..ac2604e3d0a 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/assignToVar.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.kt @@ -1,4 +1,4 @@ -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/assignToVar.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/assignToVar.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/conditions.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/conditions.kt similarity index 97% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/conditions.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/conditions.kt index 9ee6fa645c1..81ba1f1f6a7 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/conditions.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/conditions.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/conditions.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/conditions.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/conditions.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/conditions.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt similarity index 94% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt index 374049db81c..e605d9401e2 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/dataFlowInfo.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/dataFlowInfo.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/defaultParameters.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.kt similarity index 93% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/defaultParameters.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.kt index 37b66ea2d42..ae0230cd4fe 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/defaultParameters.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/defaultParameters.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/defaultParameters.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegatedProperties.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.kt similarity index 93% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegatedProperties.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.kt index f37c6ed2e3e..0858a0ea375 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegatedProperties.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.kt @@ -1,4 +1,4 @@ -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegatedProperties.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegatedProperties.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegation.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegation.kt similarity index 91% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegation.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegation.kt index 6d3dbab8f44..d530aaa8e1f 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegation.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegation.kt @@ -1,4 +1,4 @@ -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegation.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegation.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegation.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegation.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceExtension.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceExtension.kt similarity index 95% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceExtension.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceExtension.kt index 50bdaf91f28..9fdfd52376b 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceExtension.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceExtension.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceExtension.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceExtension.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceExtension.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceExtension.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceMember.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceMember.kt similarity index 95% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceMember.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceMember.kt index 1ab42f14d16..67d082641fa 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceMember.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceMember.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceMember.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceMember.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceMember.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceMember.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/expectedType.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.kt similarity index 94% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/expectedType.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.kt index f1bb7fd09a4..fe78c4c18d6 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/expectedType.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.kt @@ -1,5 +1,5 @@ // !CHECK_TYPE -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/expectedType.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/expectedType.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/for.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.kt similarity index 93% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/for.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.kt index 21ca16afebe..622494e0f05 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/for.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.kt @@ -1,4 +1,4 @@ -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/for.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/for.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/functionArguments.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.kt similarity index 92% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/functionArguments.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.kt index 00c4f82f7cf..3b88e1a4faa 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/functionArguments.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/functionArguments.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/functionArguments.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/invoke.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.kt similarity index 91% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/invoke.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.kt index 914ab0171b4..2386c379e53 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/invoke.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.kt @@ -1,4 +1,4 @@ -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/invoke.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/invoke.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/kt6829.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.kt similarity index 92% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/kt6829.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.kt index 35bc895674e..665a2b7add2 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/kt6829.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // KT-6829 False warning on map to @Nullable diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/kt6829.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/kt6829.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/multiDeclaration.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/multiDeclaration.kt similarity index 94% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/multiDeclaration.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/multiDeclaration.kt index c643824a033..e68c2d6dcca 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/multiDeclaration.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/multiDeclaration.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/multiDeclaration.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/multiDeclaration.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/multiDeclaration.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/multiDeclaration.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/passToJava.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.kt similarity index 98% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/passToJava.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.kt index 2003f670f16..1be98d46514 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/passToJava.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.kt @@ -1,4 +1,4 @@ -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/passToJava.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/passToJava.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/primitiveArray.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.kt similarity index 93% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/primitiveArray.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.kt index 6de9449f8e0..bf1d07fc73c 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/primitiveArray.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.kt @@ -1,4 +1,4 @@ -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/primitiveArray.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/primitiveArray.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/throw.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.kt similarity index 91% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/throw.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.kt index cc60fb811b1..063d5a8040a 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/throw.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.kt @@ -1,4 +1,4 @@ -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/throw.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/throw.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt similarity index 93% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt index 8faa1bfb467..6f14996b996 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: J.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityGenerics.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityGenerics.kt similarity index 96% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityGenerics.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityGenerics.kt index a59375b2c0f..1833cedee0b 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityGenerics.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityGenerics.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: A.java public class A { diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityGenerics.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityGenerics.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityGenerics.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityGenerics.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityNicknames.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityNicknames.kt similarity index 98% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityNicknames.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityNicknames.kt index 5d6b9b4f5b8..0f9894dc652 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityNicknames.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityNicknames.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: MyNullable.java import javax.annotation.*; diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityNicknames.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityNicknames.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityNicknames.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityNicknames.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Simple.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/simple.kt similarity index 95% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Simple.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/simple.kt index c3cc81520f1..08ad56c2509 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Simple.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/simple.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: A.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Simple.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/simple.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Simple.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/simple.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Strange.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/strange.kt similarity index 95% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Strange.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/strange.kt index 23065ff7876..4d523713f40 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Strange.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/strange.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: A.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Strange.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/strange.txt similarity index 94% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Strange.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/strange.txt index 25bdaa38663..988a1586884 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Strange.txt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/strange.txt @@ -7,7 +7,7 @@ public open class A { @javax.annotation.Nonnull(when = When.UNKNOWN) public final var field: kotlin.String! @javax.annotation.Nonnull public open fun bar(): kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - @javax.annotation.Nonnull(when = When.MAYBE) public open fun foo(/*0*/ @javax.annotation.Nonnull(when = When.ALWAYS) x: kotlin.String, /*1*/ @javax.annotation.Nonnull(when = When.NEVER) y: kotlin.CharSequence!): kotlin.String? + @javax.annotation.Nonnull(when = When.MAYBE) public open fun foo(/*0*/ @javax.annotation.Nonnull(when = When.ALWAYS) x: kotlin.String, /*1*/ @javax.annotation.Nonnull(when = When.NEVER) y: kotlin.CharSequence?): kotlin.String? public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt similarity index 97% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt index a8c2968b543..e23b1adc3ff 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: FieldsAreNullable.java import java.lang.annotation.Documented; diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/fieldsAreNullable.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/fieldsAreNullable.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt similarity index 99% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt index a35ab08afe4..68e1be1e1bd 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: NonNullApi.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt similarity index 99% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt index 2ffba618cda..0783c21b5a9 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: NonNullApi.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt similarity index 95% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt index 759c1c721ce..e84522ab81f 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: A.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt similarity index 97% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt index 5288a594012..82bdb9efe2f 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: test/package-info.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullable.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullable.kt similarity index 98% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullable.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullable.kt index 15b11bd142e..215943844f7 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullable.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullable.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: spr/Nullable.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullable.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullable.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullable.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullable.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullablePackage.kt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullablePackage.kt similarity index 98% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullablePackage.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullablePackage.kt index 425d0aa7d9b..08aca8a3b15 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullablePackage.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullablePackage.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// WARNING_FOR_JSR305_ANNOTATIONS +// JSR305_GLOBAL_REPORT warn // FILE: spr/Nullable.java diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullablePackage.txt b/compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullablePackage.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullablePackage.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullablePackage.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305Simple.kt b/compiler/testData/foreignAnnotations/tests/jsr305/simple.kt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305Simple.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/simple.kt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305Simple.txt b/compiler/testData/foreignAnnotations/tests/jsr305/simple.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305Simple.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/simple.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305Strange.kt b/compiler/testData/foreignAnnotations/tests/jsr305/strange.kt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/jsr305Strange.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/strange.kt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305Strange.txt b/compiler/testData/foreignAnnotations/tests/jsr305/strange.txt similarity index 94% rename from compiler/testData/foreignAnnotations/tests/jsr305Strange.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/strange.txt index 25bdaa38663..988a1586884 100644 --- a/compiler/testData/foreignAnnotations/tests/jsr305Strange.txt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/strange.txt @@ -7,7 +7,7 @@ public open class A { @javax.annotation.Nonnull(when = When.UNKNOWN) public final var field: kotlin.String! @javax.annotation.Nonnull public open fun bar(): kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - @javax.annotation.Nonnull(when = When.MAYBE) public open fun foo(/*0*/ @javax.annotation.Nonnull(when = When.ALWAYS) x: kotlin.String, /*1*/ @javax.annotation.Nonnull(when = When.NEVER) y: kotlin.CharSequence!): kotlin.String? + @javax.annotation.Nonnull(when = When.MAYBE) public open fun foo(/*0*/ @javax.annotation.Nonnull(when = When.ALWAYS) x: kotlin.String, /*1*/ @javax.annotation.Nonnull(when = When.NEVER) y: kotlin.CharSequence?): kotlin.String? public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/fieldsAreNullable.kt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/fieldsAreNullable.kt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/fieldsAreNullable.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/fieldsAreNullable.kt diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/fieldsAreNullable.txt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/fieldsAreNullable.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/fieldsAreNullable.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/fieldsAreNullable.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibility.kt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibility.kt new file mode 100644 index 00000000000..cc35f977206 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibility.kt @@ -0,0 +1,110 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER + +// FILE: spr/Nullable.java + +package spr; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +@Target({ElementType.METHOD, ElementType.PARAMETER}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Nonnull(when = When.MAYBE) +@TypeQualifierNickname +public @interface Nullable { +} + +// FILE: spr/NonNullApi.java + +package spr; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierDefault; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Nonnull +@TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER}) +public @interface NonNullApi { +} + +// FILE: spr/UnknownNullability.java +package spr; + +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +@Documented +@TypeQualifierNickname +@Nonnull(when = When.UNKNOWN) +@Retention(RetentionPolicy.RUNTIME) +public @interface UnknownNullability { + +} + +// FILE: spr/ForceFlexibility.java + +package spr; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierDefault; +import javax.annotation.meta.When; + +@Retention(RetentionPolicy.RUNTIME) +@Documented +@UnknownNullability +@TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER}) +public @interface ForceFlexibility { +} + +// FILE: A.java + +import spr.*; + +@NonNullApi +public class A { + public String foo(String x, @Nullable CharSequence y) { + return ""; + } + + + @ForceFlexibility + public String bar(String x, @javax.annotation.Nonnull CharSequence y) { + return ""; + } +} + +// FILE: main.kt + +fun main(a: A) { + a.foo("", null)?.length + a.foo("", null).length + a.foo(null, "").length + + a.bar("", "")?.length + a.bar("", "").length + a.bar(null, null).length +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibility.txt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibility.txt new file mode 100644 index 00000000000..7fc761c52bd --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibility.txt @@ -0,0 +1,43 @@ +package + +public fun main(/*0*/ a: A): kotlin.Unit + +@spr.NonNullApi public open class A { + public constructor A() + @spr.ForceFlexibility public open fun bar(/*0*/ x: kotlin.String!, /*1*/ @javax.annotation.Nonnull y: kotlin.CharSequence): kotlin.String! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.String, /*1*/ @spr.Nullable y: kotlin.CharSequence?): kotlin.String + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +package spr { + + @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @spr.UnknownNullability @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.METHOD, ElementType.PARAMETER}) public final annotation class ForceFlexibility : kotlin.Annotation { + public constructor ForceFlexibility() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FILE}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @javax.annotation.Nonnull @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.METHOD, ElementType.PARAMETER}) public final annotation class NonNullApi : kotlin.Annotation { + public constructor NonNullApi() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.VALUE_PARAMETER}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @javax.annotation.Nonnull(when = When.MAYBE) @javax.annotation.meta.TypeQualifierNickname public final annotation class Nullable : kotlin.Annotation { + public constructor Nullable() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + @kotlin.annotation.MustBeDocumented @javax.annotation.meta.TypeQualifierNickname @javax.annotation.Nonnull(when = When.UNKNOWN) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class UnknownNullability : kotlin.Annotation { + public constructor UnknownNullability() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibleOverOverrides.kt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibleOverOverrides.kt new file mode 100644 index 00000000000..903343ae2b0 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibleOverOverrides.kt @@ -0,0 +1,95 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER + +// FILE: spr/NonNullApi.java + +package spr; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierDefault; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Nonnull +@TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER}) +public @interface NonNullApi { +} + +// FILE: spr/UnknownNullability.java +package spr; + +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +@Documented +@TypeQualifierNickname +@Nonnull(when = When.UNKNOWN) +@Retention(RetentionPolicy.RUNTIME) +public @interface UnknownNullability { + +} + +// FILE: spr/ForceFlexibility.java + +package spr; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierDefault; +import javax.annotation.meta.When; + +@Retention(RetentionPolicy.RUNTIME) +@Documented +@UnknownNullability +@TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER}) +public @interface ForceFlexibility { +} + +// FILE: B.java +public interface B { + public void foo(@javax.annotation.Nonnull String x); + public void bar(@javax.annotation.Nonnull String x); + public void baz(@javax.annotation.Nonnull String x); + public void foobar(@javax.annotation.Nonnull String x); +} + +// FILE: A.java + +import spr.*; + +@NonNullApi +public class A implements B { + @ForceFlexibility + public void foo(String x) {} + public void bar(@ForceFlexibility String x) {} + public void baz(@UnknownNullability String x) {} + public void foobar(@javax.annotation.Nonnull(when = javax.annotation.meta.When.UNKNOWN) String x) {} +} + +// FILE: main.kt + +fun main(a: A, b: B) { + b.foo(null) + b.bar(null) + b.baz(null) + b.foobar(null) + + a.foo(null) + a.bar(null) + a.baz(null) + a.foobar(null) +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibleOverOverrides.txt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibleOverOverrides.txt new file mode 100644 index 00000000000..063ab835574 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibleOverOverrides.txt @@ -0,0 +1,48 @@ +package + +public fun main(/*0*/ a: A, /*1*/ b: B): kotlin.Unit + +@spr.NonNullApi public open class A : B { + public constructor A() + public open override /*1*/ fun bar(/*0*/ @spr.ForceFlexibility x: kotlin.String!): kotlin.Unit + public open override /*1*/ fun baz(/*0*/ @spr.UnknownNullability x: kotlin.String!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @spr.ForceFlexibility public open override /*1*/ fun foo(/*0*/ x: kotlin.String!): kotlin.Unit + public open override /*1*/ fun foobar(/*0*/ @javax.annotation.Nonnull(when = When.UNKNOWN) x: kotlin.String!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface B { + public abstract fun bar(/*0*/ @javax.annotation.Nonnull x: kotlin.String): kotlin.Unit + public abstract fun baz(/*0*/ @javax.annotation.Nonnull x: kotlin.String): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(/*0*/ @javax.annotation.Nonnull x: kotlin.String): kotlin.Unit + public abstract fun foobar(/*0*/ @javax.annotation.Nonnull x: kotlin.String): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +package spr { + + @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @spr.UnknownNullability @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.METHOD, ElementType.PARAMETER}) public final annotation class ForceFlexibility : kotlin.Annotation { + public constructor ForceFlexibility() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FILE}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @javax.annotation.Nonnull @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.METHOD, ElementType.PARAMETER}) public final annotation class NonNullApi : kotlin.Annotation { + public constructor NonNullApi() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + @kotlin.annotation.MustBeDocumented @javax.annotation.meta.TypeQualifierNickname @javax.annotation.Nonnull(when = When.UNKNOWN) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class UnknownNullability : kotlin.Annotation { + public constructor UnknownNullability() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/nullabilityFromOverridden.kt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/nullabilityFromOverridden.kt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/nullabilityFromOverridden.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/nullabilityFromOverridden.kt diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/nullabilityFromOverridden.txt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/nullabilityFromOverridden.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/nullabilityFromOverridden.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/nullabilityFromOverridden.txt diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/overridingDefaultQualifier.kt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/overridingDefaultQualifier.kt similarity index 97% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/overridingDefaultQualifier.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/overridingDefaultQualifier.kt index bc428b45795..b5d805b0721 100644 --- a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/overridingDefaultQualifier.kt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/overridingDefaultQualifier.kt @@ -66,7 +66,7 @@ public class A { } @NullableApi - public String foobar(String x, @Nonnull CharSequence y) { + public String foobar(String x, @NonNullApi CharSequence y) { return ""; } @@ -88,7 +88,7 @@ public class A { } @NonNullApi - public String foobar(String x, @Nullable CharSequence y) { + public String foobar(String x, @NullableApi CharSequence y) { return ""; } diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/overridingDefaultQualifier.txt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/overridingDefaultQualifier.txt similarity index 96% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/overridingDefaultQualifier.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/overridingDefaultQualifier.txt index e6626057009..ec030f0c25f 100644 --- a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/overridingDefaultQualifier.txt +++ b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/overridingDefaultQualifier.txt @@ -9,7 +9,7 @@ public fun main(/*0*/ a: A, /*1*/ b: A.B, /*2*/ c: A.C): kotlin.Unit @javax.annotation.Nullable public open fun baz(): kotlin.collections.(Mutable)List? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open fun foo(/*0*/ x: kotlin.String, /*1*/ @javax.annotation.CheckForNull y: kotlin.CharSequence?): kotlin.String - @NullableApi public open fun foobar(/*0*/ x: kotlin.String?, /*1*/ @javax.annotation.Nonnull y: kotlin.CharSequence): kotlin.String? + @NullableApi public open fun foobar(/*0*/ x: kotlin.String?, /*1*/ @NonNullApi y: kotlin.CharSequence): kotlin.String? public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String @@ -20,7 +20,7 @@ public fun main(/*0*/ a: A, /*1*/ b: A.B, /*2*/ c: A.C): kotlin.Unit @javax.annotation.Nullable public open fun baz(): kotlin.collections.(Mutable)List? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open fun foo(/*0*/ x: kotlin.String?, /*1*/ @javax.annotation.Nonnull y: kotlin.CharSequence): kotlin.String? - @NonNullApi public open fun foobar(/*0*/ x: kotlin.String, /*1*/ @javax.annotation.Nullable y: kotlin.CharSequence?): kotlin.String + @NonNullApi public open fun foobar(/*0*/ x: kotlin.String, /*1*/ @NullableApi y: kotlin.CharSequence?): kotlin.String public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefault.kt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefault.kt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefault.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefault.kt diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefault.txt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefault.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefault.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefault.txt diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefaultPackage.txt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefaultPackage.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefaultPackage.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefaultPackage.txt diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullable.kt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullable.kt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullable.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullable.kt diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullable.txt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullable.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullable.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullable.txt diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullablePackage.kt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullablePackage.kt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullablePackage.kt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullablePackage.kt diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullablePackage.txt b/compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullablePackage.txt similarity index 100% rename from compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullablePackage.txt rename to compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullablePackage.txt diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/customMigration.kt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/customMigration.kt new file mode 100644 index 00000000000..901f060308d --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/customMigration.kt @@ -0,0 +1,84 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// JSR305_GLOBAL_REPORT ignore + +// FILE: MyErrorNonnull.java +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +import kotlin.annotations.jvm.*; + +@Documented +@TypeQualifierNickname +@Nonnull(when = When.ALWAYS) +@Retention(RetentionPolicy.RUNTIME) +@UnderMigration(status = MigrationStatus.STRICT) +public @interface MyErrorNonnull { +} + +// FILE: MyWarnNonnull.java +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +import kotlin.annotations.jvm.*; + +@Documented +@TypeQualifierNickname +@Nonnull(when = When.ALWAYS) +@Retention(RetentionPolicy.RUNTIME) +@UnderMigration(status = MigrationStatus.WARN) +public @interface MyWarnNonnull { +} + +// FILE: MyIgnoreNonnull.java +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +import kotlin.annotations.jvm.*; + +@Documented +@TypeQualifierNickname +@Nonnull(when = When.ALWAYS) +@Retention(RetentionPolicy.RUNTIME) +@UnderMigration(status = MigrationStatus.IGNORE) +public @interface MyIgnoreNonnull { +} + +// FILE: A.java + +public class A { + public void foo(@MyErrorNonnull String bar) {} + public void foo2(@MyWarnNonnull String bar) {} + public void foo3(@MyIgnoreNonnull String bar) {} + public void foo4(@MyMigrationNonnull String bar) {} +} + +// FILE: main.kt + +fun main(a: A) { + a.foo("") + a.foo(null) + + a.foo2("") + a.foo2(null) + + a.foo3("") + a.foo3(null) + + a.foo4("") + a.foo4(null) +} \ No newline at end of file diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/customMigration.txt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/customMigration.txt new file mode 100644 index 00000000000..83842aaa6d0 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/customMigration.txt @@ -0,0 +1,35 @@ +package + +public fun main(/*0*/ a: A): kotlin.Unit + +public open class A { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ @MyErrorNonnull bar: kotlin.String): kotlin.Unit + public open fun foo2(/*0*/ @MyWarnNonnull bar: kotlin.String!): kotlin.Unit + public open fun foo3(/*0*/ @MyIgnoreNonnull bar: kotlin.String!): kotlin.Unit + public open fun foo4(/*0*/ @MyMigrationNonnull bar: kotlin.String!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@kotlin.annotation.MustBeDocumented @javax.annotation.meta.TypeQualifierNickname @javax.annotation.Nonnull(when = When.ALWAYS) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotations.jvm.UnderMigration(status = MigrationStatus.STRICT) public final annotation class MyErrorNonnull : kotlin.Annotation { + public constructor MyErrorNonnull() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@kotlin.annotation.MustBeDocumented @javax.annotation.meta.TypeQualifierNickname @javax.annotation.Nonnull(when = When.ALWAYS) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotations.jvm.UnderMigration(status = MigrationStatus.IGNORE) public final annotation class MyIgnoreNonnull : kotlin.Annotation { + public constructor MyIgnoreNonnull() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@kotlin.annotation.MustBeDocumented @javax.annotation.meta.TypeQualifierNickname @javax.annotation.Nonnull(when = When.ALWAYS) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotations.jvm.UnderMigration(status = MigrationStatus.WARN) public final annotation class MyWarnNonnull : kotlin.Annotation { + public constructor MyWarnNonnull() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalIgnore.kt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalIgnore.kt new file mode 100644 index 00000000000..72245c8be03 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalIgnore.kt @@ -0,0 +1,57 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// JSR305_GLOBAL_REPORT ignore +// JSR305_MIGRATION_REPORT strict +// JSR305_SPECIAL_REPORT MyNonnull:warn + +// FILE: A.java + +import javax.annotation.*; + +public class A { + @MyMigrationNullable public String field = null; + + @MyMigrationNullable + public String foo(@MyMigrationNonnull String x, CharSequence y) { + return ""; + } + + @MyMigrationNonnull + public String bar() { + return ""; + } + + @MyNullable public String field2 = null; + @MyNullable + public String foo2(@MyNonnull String x, CharSequence y) { + return ""; + } + + @MyNonnull + public String bar2() { + return ""; + } +} + +// FILE: main.kt + +fun main(a: A) { + a.foo("", null)?.length + a.foo("", null).length + a.foo(null, "").length + + a.bar().length + a.bar()!!.length + + a.field?.length + a.field.length + + a.foo2("", null)?.length + a.foo2("", null).length + a.foo2(null, "").length + + a.bar2().length + a.bar2()!!.length + + a.field2?.length + a.field2.length +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalIgnore.txt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalIgnore.txt new file mode 100644 index 00000000000..243af6b409b --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalIgnore.txt @@ -0,0 +1,16 @@ +package + +public fun main(/*0*/ a: A): kotlin.Unit + +public open class A { + public constructor A() + @MyMigrationNullable public final var field: kotlin.String? + @MyNullable public final var field2: kotlin.String! + @MyMigrationNonnull public open fun bar(): kotlin.String + @MyNonnull public open fun bar2(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @MyMigrationNullable public open fun foo(/*0*/ @MyMigrationNonnull x: kotlin.String, /*1*/ y: kotlin.CharSequence!): kotlin.String? + @MyNullable public open fun foo2(/*0*/ @MyNonnull x: kotlin.String!, /*1*/ y: kotlin.CharSequence!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.kt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.kt new file mode 100644 index 00000000000..571c247ac0a --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.kt @@ -0,0 +1,57 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// JSR305_GLOBAL_REPORT warn +// JSR305_MIGRATION_REPORT ignore +// JSR305_SPECIAL_REPORT MyNullable:strict, MyMigrationNonnull:strict + +// FILE: A.java + +import javax.annotation.*; + +public class A { + @MyMigrationNullable public String field = null; + + @MyMigrationNullable + public String foo(@MyMigrationNonnull String x, CharSequence y) { + return ""; + } + + @MyMigrationNonnull + public String bar() { + return ""; + } + + @MyNullable public String field2 = null; + @MyNullable + public String foo2(@MyNonnull String x, CharSequence y) { + return ""; + } + + @MyNonnull + public String bar2() { + return ""; + } +} + +// FILE: main.kt + +fun main(a: A) { + a.foo("", null)?.length + a.foo("", null).length + a.foo(null, "").length + + a.bar().length + a.bar()!!.length + + a.field?.length + a.field.length + + a.foo2("", null)?.length + a.foo2("", null).length + a.foo2(null, "").length + + a.bar2().length + a.bar2()!!.length + + a.field2?.length + a.field2.length +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.txt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.txt new file mode 100644 index 00000000000..83343a807b1 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.txt @@ -0,0 +1,16 @@ +package + +public fun main(/*0*/ a: A): kotlin.Unit + +public open class A { + public constructor A() + @MyMigrationNullable public final var field: kotlin.String! + @MyNullable public final var field2: kotlin.String? + @MyMigrationNonnull public open fun bar(): kotlin.String + @MyNonnull public open fun bar2(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @MyMigrationNullable public open fun foo(/*0*/ @MyMigrationNonnull x: kotlin.String, /*1*/ y: kotlin.CharSequence!): kotlin.String! + @MyNullable public open fun foo2(/*0*/ @MyNonnull x: kotlin.String!, /*1*/ y: kotlin.CharSequence!): kotlin.String? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationError.kt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationError.kt new file mode 100644 index 00000000000..8e2c6cf5260 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationError.kt @@ -0,0 +1,78 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// JSR305_GLOBAL_REPORT warn +// JSR305_MIGRATION_REPORT strict +// JSR305_SPECIAL_REPORT MyNonnull:ignore, MySuperNull:strict + +// FILE: MySuperNull.java +import javax.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +@Documented +@TypeQualifierNickname +@Nonnull(when = When.MAYBE) +@Retention(RetentionPolicy.RUNTIME) +public @interface MySuperNull { +} + +// FILE: A.java + +import javax.annotation.*; + +public class A { + @MyMigrationNullable public String field = null; + + @MyMigrationNullable + public String foo(@MyMigrationNonnull String x, CharSequence y) { + return ""; + } + + @MyMigrationNonnull + public String bar() { + return ""; + } + + @MyNullable public String field2 = null; + @MyNullable + public String foo2(@MyNonnull String x, CharSequence y) { + return ""; + } + + @MyNonnull + public String bar2() { + return ""; + } + + @MySuperNull public String field3 = null; +} + +// FILE: main.kt + +fun main(a: A) { + a.foo("", null)?.length + a.foo("", null).length + a.foo(null, "").length + + a.bar().length + a.bar()!!.length + + a.field?.length + a.field.length + + a.foo2("", null)?.length + a.foo2("", null).length + a.foo2(null, "").length + + a.bar2().length + a.bar2()!!.length + + a.field2?.length + a.field2.length + + a.field3?.length + a.field3.length +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationError.txt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationError.txt new file mode 100644 index 00000000000..e7bf6899f3f --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationError.txt @@ -0,0 +1,24 @@ +package + +public fun main(/*0*/ a: A): kotlin.Unit + +public open class A { + public constructor A() + @MyMigrationNullable public final var field: kotlin.String? + @MyNullable public final var field2: kotlin.String! + @MySuperNull public final var field3: kotlin.String? + @MyMigrationNonnull public open fun bar(): kotlin.String + @MyNonnull public open fun bar2(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @MyMigrationNullable public open fun foo(/*0*/ @MyMigrationNonnull x: kotlin.String, /*1*/ y: kotlin.CharSequence!): kotlin.String? + @MyNullable public open fun foo2(/*0*/ @MyNonnull x: kotlin.String!, /*1*/ y: kotlin.CharSequence!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@kotlin.annotation.MustBeDocumented @javax.annotation.meta.TypeQualifierNickname @javax.annotation.Nonnull(when = When.MAYBE) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class MySuperNull : kotlin.Annotation { + public constructor MySuperNull() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationIgnore.kt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationIgnore.kt new file mode 100644 index 00000000000..d3564fc12ea --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationIgnore.kt @@ -0,0 +1,57 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// JSR305_GLOBAL_REPORT strict +// JSR305_MIGRATION_REPORT ignore +// JSR305_SPECIAL_REPORT MyNullable:warn, MyMigrationNonnull:strict + +// FILE: A.java + +import javax.annotation.*; + +public class A { + @MyMigrationNullable public String field = null; + + @MyMigrationNullable + public String foo(@MyMigrationNonnull String x, CharSequence y) { + return ""; + } + + @MyMigrationNonnull + public String bar() { + return ""; + } + + @MyNullable public String field2 = null; + @MyNullable + public String foo2(@MyNonnull String x, CharSequence y) { + return ""; + } + + @MyNonnull + public String bar2() { + return ""; + } +} + +// FILE: main.kt + +fun main(a: A) { + a.foo("", null)?.length + a.foo("", null).length + a.foo(null, "").length + + a.bar().length + a.bar()!!.length + + a.field?.length + a.field.length + + a.foo2("", null)?.length + a.foo2("", null).length + a.foo2(null, "").length + + a.bar2().length + a.bar2()!!.length + + a.field2?.length + a.field2.length +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationIgnore.txt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationIgnore.txt new file mode 100644 index 00000000000..7bb17583fea --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationIgnore.txt @@ -0,0 +1,16 @@ +package + +public fun main(/*0*/ a: A): kotlin.Unit + +public open class A { + public constructor A() + @MyMigrationNullable public final var field: kotlin.String! + @MyNullable public final var field2: kotlin.String! + @MyMigrationNonnull public open fun bar(): kotlin.String + @MyNonnull public open fun bar2(): kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @MyMigrationNullable public open fun foo(/*0*/ @MyMigrationNonnull x: kotlin.String, /*1*/ y: kotlin.CharSequence!): kotlin.String! + @MyNullable public open fun foo2(/*0*/ @MyNonnull x: kotlin.String, /*1*/ y: kotlin.CharSequence!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationWarning.kt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationWarning.kt new file mode 100644 index 00000000000..8c636fbbd5a --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationWarning.kt @@ -0,0 +1,57 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// JSR305_GLOBAL_REPORT strict +// JSR305_MIGRATION_REPORT warn +// JSR305_SPECIAL_REPORT MyNullable:ignore, MyMigrationNullable:strict + +// FILE: A.java + +import javax.annotation.*; + +public class A { + @MyMigrationNullable public String field = null; + + @MyMigrationNullable + public String foo(@MyMigrationNonnull String x, CharSequence y) { + return ""; + } + + @MyMigrationNonnull + public String bar() { + return ""; + } + + @MyNullable public String field2 = null; + @MyNullable + public String foo2(@MyNonnull String x, CharSequence y) { + return ""; + } + + @MyNonnull + public String bar2() { + return ""; + } +} + +// FILE: main.kt + +fun main(a: A) { + a.foo("", null)?.length + a.foo("", null).length + a.foo(null, "").length + + a.bar().length + a.bar()!!.length + + a.field?.length + a.field.length + + a.foo2("", null)?.length + a.foo2("", null).length + a.foo2(null, "").length + + a.bar2().length + a.bar2()!!.length + + a.field2?.length + a.field2.length +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationWarning.txt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationWarning.txt new file mode 100644 index 00000000000..f36e6bc8da6 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationWarning.txt @@ -0,0 +1,16 @@ +package + +public fun main(/*0*/ a: A): kotlin.Unit + +public open class A { + public constructor A() + @MyMigrationNullable public final var field: kotlin.String? + @MyNullable public final var field2: kotlin.String! + @MyMigrationNonnull public open fun bar(): kotlin.String! + @MyNonnull public open fun bar2(): kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @MyMigrationNullable public open fun foo(/*0*/ @MyMigrationNonnull x: kotlin.String!, /*1*/ y: kotlin.CharSequence!): kotlin.String? + @MyNullable public open fun foo2(/*0*/ @MyNonnull x: kotlin.String, /*1*/ y: kotlin.CharSequence!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/overrideConflicts.kt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/overrideConflicts.kt new file mode 100644 index 00000000000..ef21f56308d --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/overrideConflicts.kt @@ -0,0 +1,85 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// JSR305_GLOBAL_REPORT warn +// JSR305_MIGRATION_REPORT strict + +// FILE: A.java +import javax.annotation.Nullable; +import javax.annotation.Nonnull; + +public class A { + @MyNullable + public String foo() { return ""; } + + @MyMigrationNullable + public String foo2() { return ""; } + + @Nullable + public String foo3() { return ""; } + + public String foo4() { return ""; } + + public void bar(@MyNonnull String baz) { } + + public void bar2(@MyMigrationNonnull String baz) { } + + public void bar3(@Nonnull String baz) {} + + public void bar4(String baz) {} +} + +// FILE: B.java +public class B extends A { + @MyMigrationNullable + public String foo() { return ""; } + + @MyNullable + public String foo2() { return ""; } + + @MyNullable + public String foo3() { return ""; } + + @MyNullable + public String foo4() { return ""; } + + public void bar(@MyMigrationNonnull String baz) { } + + public void bar2(@MyNonnull String baz) { } + + public void bar3(@MyNonnull String baz) {} + + public void bar4(@MyNonnull String baz) {} +} + +// FILE: C.java +public class C extends A { + @MyMigrationNullable + public String foo4() { return ""; } + + public void bar4(@MyMigrationNonnull String baz) {} +} + +// FILE: main.kt +fun main(b: B, c: C) { + b.foo().length + b.foo()?.length + b.foo2().length + b.foo2()?.length + b.foo3().length + b.foo3()?.length + b.foo4().length + b.foo4()?.length + + b.bar(null) + b.bar("") + b.bar2(null) + b.bar2("") + b.bar3(null) + b.bar3("") + b.bar4(null) + b.bar4("") + + c.foo4().length + c.foo4()?.length + c.bar4(null) + c.bar4("") +} \ No newline at end of file diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/overrideConflicts.txt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/overrideConflicts.txt new file mode 100644 index 00000000000..548f62b39d5 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/overrideConflicts.txt @@ -0,0 +1,48 @@ +package + +public fun main(/*0*/ b: B, /*1*/ c: C): kotlin.Unit + +public open class A { + public constructor A() + public open fun bar(/*0*/ @MyNonnull baz: kotlin.String!): kotlin.Unit + public open fun bar2(/*0*/ @MyMigrationNonnull baz: kotlin.String): kotlin.Unit + public open fun bar3(/*0*/ @javax.annotation.Nonnull baz: kotlin.String): kotlin.Unit + public open fun bar4(/*0*/ baz: kotlin.String!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @MyNullable public open fun foo(): kotlin.String! + @MyMigrationNullable public open fun foo2(): kotlin.String? + @javax.annotation.Nullable public open fun foo3(): kotlin.String? + public open fun foo4(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class B : A { + public constructor B() + public open override /*1*/ fun bar(/*0*/ @MyMigrationNonnull baz: kotlin.String): kotlin.Unit + public open override /*1*/ fun bar2(/*0*/ @MyNonnull baz: kotlin.String): kotlin.Unit + public open override /*1*/ fun bar3(/*0*/ @MyNonnull baz: kotlin.String): kotlin.Unit + public open override /*1*/ fun bar4(/*0*/ @MyNonnull baz: kotlin.String!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @MyMigrationNullable public open override /*1*/ fun foo(): kotlin.String? + @MyNullable public open override /*1*/ fun foo2(): kotlin.String? + @MyNullable public open override /*1*/ fun foo3(): kotlin.String? + @MyNullable public open override /*1*/ fun foo4(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class C : A { + public constructor C() + public open override /*1*/ /*fake_override*/ fun bar(/*0*/ @MyNonnull baz: kotlin.String!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun bar2(/*0*/ @MyMigrationNonnull baz: kotlin.String): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun bar3(/*0*/ @javax.annotation.Nonnull baz: kotlin.String): kotlin.Unit + public open override /*1*/ fun bar4(/*0*/ @MyMigrationNonnull baz: kotlin.String): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @MyNullable public open override /*1*/ /*fake_override*/ fun foo(): kotlin.String! + @MyMigrationNullable public open override /*1*/ /*fake_override*/ fun foo2(): kotlin.String? + @javax.annotation.Nullable public open override /*1*/ /*fake_override*/ fun foo3(): kotlin.String? + @MyMigrationNullable public open override /*1*/ fun foo4(): kotlin.String? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/specialCollision.kt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/specialCollision.kt new file mode 100644 index 00000000000..adb449454cb --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/specialCollision.kt @@ -0,0 +1,37 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// JSR305_GLOBAL_REPORT ignore +// JSR305_MIGRATION_REPORT ignore +// JSR305_SPECIAL_REPORT MyNonnull:warn, MyMigrationNonnull:strict + +// FILE: A.java + +import javax.annotation.*; + +public class A { + @MyMigrationNullable public String field = null; + + @MyMigrationNullable + public String foo(@MyMigrationNonnull String x, CharSequence y) { + return ""; + } + + @MyNonnull + @MyMigrationNonnull + public String bar() { + return ""; + } +} + +// FILE: main.kt + +fun main(a: A) { + a.foo("", null)?.length + a.foo("", null).length + a.foo(null, "").length + + a.bar().length + a.bar()!!.length + + a.field?.length + a.field.length +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/specialCollision.txt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/specialCollision.txt new file mode 100644 index 00000000000..9835fbefeee --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/specialCollision.txt @@ -0,0 +1,13 @@ +package + +public fun main(/*0*/ a: A): kotlin.Unit + +public open class A { + public constructor A() + @MyMigrationNullable public final var field: kotlin.String! + @MyNonnull @MyMigrationNonnull public open fun bar(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @MyMigrationNullable public open fun foo(/*0*/ @MyMigrationNonnull x: kotlin.String, /*1*/ y: kotlin.CharSequence!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/stateRefinement.kt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/stateRefinement.kt new file mode 100644 index 00000000000..284ae7f9ce4 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/stateRefinement.kt @@ -0,0 +1,57 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// JSR305_GLOBAL_REPORT ignore +// JSR305_MIGRATION_REPORT warn +// JSR305_SPECIAL_REPORT MyNonnull:strict + +// FILE: A.java + +import javax.annotation.*; + +public class A { + @MyMigrationNullable public String field = null; + + @MyMigrationNullable + public String foo(@MyMigrationNonnull String x, CharSequence y) { + return ""; + } + + @MyMigrationNonnull + public String bar() { + return ""; + } + + @MyNullable public String field2 = null; + @MyNullable + public String foo2(@MyNonnull String x, CharSequence y) { + return ""; + } + + @MyNonnull + public String bar2() { + return ""; + } +} + +// FILE: main.kt + +fun main(a: A) { + a.foo("", null)?.length + a.foo("", null).length + a.foo(null, "").length + + a.bar().length + a.bar()!!.length + + a.field?.length + a.field.length + + a.foo2("", null)?.length + a.foo2("", null).length + a.foo2(null, "").length + + a.bar2().length + a.bar2()!!.length + + a.field2?.length + a.field2.length +} diff --git a/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/stateRefinement.txt b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/stateRefinement.txt new file mode 100644 index 00000000000..a5b37edfe14 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/stateRefinement.txt @@ -0,0 +1,16 @@ +package + +public fun main(/*0*/ a: A): kotlin.Unit + +public open class A { + public constructor A() + @MyMigrationNullable public final var field: kotlin.String! + @MyNullable public final var field2: kotlin.String! + @MyMigrationNonnull public open fun bar(): kotlin.String! + @MyNonnull public open fun bar2(): kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @MyMigrationNullable public open fun foo(/*0*/ @MyMigrationNonnull x: kotlin.String!, /*1*/ y: kotlin.CharSequence!): kotlin.String! + @MyNullable public open fun foo2(/*0*/ @MyNonnull x: kotlin.String, /*1*/ y: kotlin.CharSequence!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.kt b/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.kt new file mode 100644 index 00000000000..15e8c92e4a9 --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.kt @@ -0,0 +1,69 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// JSR305_GLOBAL_REPORT warn + +// FILE: NonNullApi.java + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.meta.TypeQualifierDefault; + +@Retention(RetentionPolicy.RUNTIME) +@Documented +@MyNonnull +@TypeQualifierDefault({ ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD }) +public @interface NonNullApi { +} + +// FILE: MigrationNonNullApi.java + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.meta.TypeQualifierDefault; + +import kotlin.annotations.jvm.*; + +@Retention(RetentionPolicy.RUNTIME) +@Documented +@MyNonnull +@UnderMigration(status = MigrationStatus.STRICT) +@TypeQualifierDefault({ ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD }) +public @interface MigrationNonNullApi { +} + +// FILE: PolicyFromDefault.java + +@NonNullApi +public class PolicyFromDefault { + public String foo(String x) { + return x; + } + + public String bar = "bar"; +} + +// FILE: PolicyFromNickname.java + +@MigrationNonNullApi +public class PolicyFromNickname { + public String foo(String x) { + return x; + } + + public String bar = "bar"; +} + +// FILE: main.kt + +fun main(default: PolicyFromDefault, nickname: PolicyFromNickname) { + default.foo(null).length + default.foo("hello").length + + nickname.foo(null).length + nickname.foo("hello").length +} \ No newline at end of file diff --git a/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.txt b/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.txt new file mode 100644 index 00000000000..2effab74bfa --- /dev/null +++ b/compiler/testData/foreignAnnotations/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.txt @@ -0,0 +1,35 @@ +package + +public fun main(/*0*/ default: PolicyFromDefault, /*1*/ nickname: PolicyFromNickname): kotlin.Unit + +@kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @MyNonnull @kotlin.annotations.jvm.UnderMigration(status = MigrationStatus.STRICT) @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD}) public final annotation class MigrationNonNullApi : kotlin.Annotation { + public constructor MigrationNonNullApi() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @MyNonnull @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD}) public final annotation class NonNullApi : kotlin.Annotation { + public constructor NonNullApi() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@NonNullApi public open class PolicyFromDefault { + public constructor PolicyFromDefault() + public final var bar: kotlin.String! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.String!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@MigrationNonNullApi public open class PolicyFromNickname { + public constructor PolicyFromNickname() + public final var bar: kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.String): kotlin.String + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/foreignAnnotationsJava8/tests/checkerFramework.kt b/compiler/testData/foreignAnnotationsJava8/tests/checkerFramework.kt index c4d52161313..7c3d2276550 100644 --- a/compiler/testData/foreignAnnotationsJava8/tests/checkerFramework.kt +++ b/compiler/testData/foreignAnnotationsJava8/tests/checkerFramework.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// SKIP_COMPILED_JAVA // FILE: A.java import org.checkerframework.checker.nullness.qual.*; diff --git a/compiler/testData/foreignAnnotationsJava8/tests/eclipse.kt b/compiler/testData/foreignAnnotationsJava8/tests/eclipse.kt index 86c6c7bae33..400ea2b2db7 100644 --- a/compiler/testData/foreignAnnotationsJava8/tests/eclipse.kt +++ b/compiler/testData/foreignAnnotationsJava8/tests/eclipse.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// SKIP_COMPILED_JAVA // FILE: A.java import org.eclipse.jdt.annotation.*; diff --git a/compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToType.kt b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToType.kt new file mode 100644 index 00000000000..6dab460b47e --- /dev/null +++ b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToType.kt @@ -0,0 +1,80 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// SKIP_JAVAC +// SKIP_COMPILED_JAVA + +// FILE: spr/NonNullApi.java + +package spr; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierDefault; + +@Target({ElementType.TYPE, ElementType.TYPE_USE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Nonnull +@TypeQualifierDefault({ElementType.TYPE_USE}) +public @interface NonNullApi { +} + +// FILE: spr/NullableApi.java + +package spr; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierDefault; +import javax.annotation.meta.When; + +@Target({ElementType.TYPE_USE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Nonnull(when = When.MAYBE) +@TypeQualifierDefault({ElementType.TYPE_USE}) +public @interface NullableApi { +} + +// FILE: A.java + +import spr.*; +import java.util.*; + +@NonNullApi +public class A { + public String foo(String x) { return ""; } + public @NullableApi String bar(@NullableApi String y) { return ""; } + public @NullableApi List baz1() { return null; } + public List<@NullableApi String> baz2() { return null; } + public @NullableApi List<@NonNullApi String> baz3() { return null; } +} + +// FILE: main.kt + +fun main(a: A) { + a.foo("").length + a.foo(null)?.length + + a.bar("").length + a.bar(null)?.length + + a.baz1().get(0).length + a.baz1()!!.get(0).length + a.baz1()!!.get(0)?.length + + a.baz2().get(0).length + a.baz2()!!.get(0).length + a.baz2()!!.get(0)?.length + + a.baz3().get(0).length + a.baz3()!!.get(0).length + a.baz3()!!.get(0)?.length +} diff --git a/compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToType.txt b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToType.txt new file mode 100644 index 00000000000..26732bde6fe --- /dev/null +++ b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToType.txt @@ -0,0 +1,32 @@ +package + +public fun main(/*0*/ a: A): kotlin.Unit + +@spr.NonNullApi public open class A { + public constructor A() + @spr.NullableApi public open fun bar(/*0*/ @spr.NullableApi y: @spr.NullableApi kotlin.String?): @spr.NullableApi kotlin.String? + @spr.NullableApi public open fun baz1(): (@spr.NullableApi kotlin.collections.MutableList?..@spr.NullableApi kotlin.collections.List?) + public open fun baz2(): kotlin.collections.(Mutable)List<@spr.NullableApi kotlin.String?> + @spr.NullableApi public open fun baz3(): (@spr.NullableApi kotlin.collections.MutableList<@spr.NonNullApi kotlin.String>?..@spr.NullableApi kotlin.collections.List<@spr.NonNullApi kotlin.String>?) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.String): kotlin.String + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +package spr { + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FILE, AnnotationTarget.TYPE}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @javax.annotation.Nonnull @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.TYPE_USE}) public final annotation class NonNullApi : kotlin.Annotation { + public constructor NonNullApi() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @javax.annotation.Nonnull(when = When.MAYBE) @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.TYPE_USE}) public final annotation class NullableApi : kotlin.Annotation { + public constructor NullableApi() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToTypeForCompiledJava.kt b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToTypeForCompiledJava.kt new file mode 100644 index 00000000000..f42f4703406 --- /dev/null +++ b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToTypeForCompiledJava.kt @@ -0,0 +1,70 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// SKIP_JAVAC +// SKIP_COMPILED_JAVA + +// FILE: spr/NonNullApi.java + +package spr; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierDefault; + +@Target({ElementType.TYPE_USE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Nonnull +@TypeQualifierDefault({ElementType.TYPE_USE}) +public @interface NonNullApi { +} + +// FILE: spr/NullableApi.java + +package spr; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierDefault; +import javax.annotation.meta.When; + +@Target({ElementType.TYPE, ElementType.TYPE_USE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Nonnull(when = When.MAYBE) +@TypeQualifierDefault({ElementType.TYPE_USE}) +public @interface NullableApi { +} + +// FILE: A.java + +import spr.*; +import java.util.*; + +@NonNullApi +public class A { + public String foo(String x) { return ""; } + public @NullableApi String bar(@NullableApi String y) { return ""; } + public @NullableApi List baz1() { return null; } +} + +// FILE: main.kt + +fun main(a: A) { + a.foo("").length + a.foo(null)?.length + + a.bar("").length + a.bar(null)?.length + + a.baz1().get(0).length + a.baz1()!!.get(0).length + a.baz1()!!.get(0)?.length +} diff --git a/compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToTypeForCompiledJava.txt b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToTypeForCompiledJava.txt new file mode 100644 index 00000000000..464ab11573e --- /dev/null +++ b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToTypeForCompiledJava.txt @@ -0,0 +1,30 @@ +package + +public fun main(/*0*/ a: A): kotlin.Unit + +@spr.NonNullApi public open class A { + public constructor A() + @spr.NullableApi public open fun bar(/*0*/ @spr.NullableApi y: @spr.NullableApi kotlin.String?): @spr.NullableApi kotlin.String? + @spr.NullableApi public open fun baz1(): (@spr.NullableApi kotlin.collections.MutableList?..@spr.NullableApi kotlin.collections.List?) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.String): kotlin.String + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +package spr { + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @javax.annotation.Nonnull @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.TYPE_USE}) public final annotation class NonNullApi : kotlin.Annotation { + public constructor NonNullApi() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FILE, AnnotationTarget.TYPE}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @javax.annotation.Nonnull(when = When.MAYBE) @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.TYPE_USE}) public final annotation class NullableApi : kotlin.Annotation { + public constructor NullableApi() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/foreignAnnotationsJava8/tests/springNullableWithTypeUse.kt b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/springNullableWithTypeUse.kt similarity index 95% rename from compiler/testData/foreignAnnotationsJava8/tests/springNullableWithTypeUse.kt rename to compiler/testData/foreignAnnotationsJava8/tests/jsr305/springNullableWithTypeUse.kt index c400c6ed766..b6053f12fd8 100644 --- a/compiler/testData/foreignAnnotationsJava8/tests/springNullableWithTypeUse.kt +++ b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/springNullableWithTypeUse.kt @@ -33,7 +33,7 @@ import java.lang.annotation.Target; import javax.annotation.Nonnull; import javax.annotation.meta.TypeQualifierDefault; -@Target(ElementType.CLASS) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Nonnull @@ -78,5 +78,5 @@ fun main(a: A) { a.baz().get(0) a.baz()!!.get(0).get(0) - a.baz()!!.get(0)?.get(0) + a.baz()!!.get(0)?.get(0) } diff --git a/compiler/testData/foreignAnnotationsJava8/tests/springNullableWithTypeUse.txt b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/springNullableWithTypeUse.txt similarity index 81% rename from compiler/testData/foreignAnnotationsJava8/tests/springNullableWithTypeUse.txt rename to compiler/testData/foreignAnnotationsJava8/tests/jsr305/springNullableWithTypeUse.txt index 5dae5b01230..3721c8d8cdc 100644 --- a/compiler/testData/foreignAnnotationsJava8/tests/springNullableWithTypeUse.txt +++ b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/springNullableWithTypeUse.txt @@ -6,7 +6,7 @@ public fun main(/*0*/ a: A): kotlin.Unit public constructor A() public final var field: kotlin.String public open fun bar(): kotlin.String - @spr.Nullable public open fun baz(): kotlin.collections.(Mutable)List? + @spr.Nullable public open fun baz(): kotlin.collections.(Mutable)List? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open fun foo(/*0*/ x: kotlin.String, /*1*/ @spr.Nullable y: kotlin.CharSequence?): kotlin.String public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -15,7 +15,7 @@ public fun main(/*0*/ a: A): kotlin.Unit package spr { - @kotlin.annotation.Target(allowedTargets = {}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @javax.annotation.Nonnull @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.TYPE_USE}) public final annotation class NonNullApi : kotlin.Annotation { + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FILE}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @javax.annotation.Nonnull @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.TYPE_USE}) public final annotation class NonNullApi : kotlin.Annotation { public constructor NonNullApi() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeArguments.kt b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeArguments.kt new file mode 100644 index 00000000000..16c24caa4fb --- /dev/null +++ b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeArguments.kt @@ -0,0 +1,111 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// RENDER_PACKAGE: test +// SKIP_COMPILED_JAVA + +// FILE: spr/Nullable.java + +package spr; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierNickname; +import javax.annotation.meta.When; + +@Target({ElementType.TYPE_USE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Nonnull(when = When.MAYBE) +@TypeQualifierNickname +public @interface Nullable { +} + +// FILE: spr/NonNullApi.java + +package spr; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierDefault; + +@Target(ElementType.PACKAGE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Nonnull +@TypeQualifierDefault({ElementType.TYPE_USE}) +public @interface NonNullApi { +} + +// FILE: test/package-info.java + +@spr.NonNullApi() +package test; + +// FILE: test/L.java + +package test; + +public class L, S> { + public T t() { return null; } + public S s() { return null; } + + public void setT(@spr.Nullable T t) {} + public void setS(S s) {} +} + +// FILE: test/A.java + +package test; + +import spr.*; +import java.util.*; + +public class A { + public void foo(L, @Nullable Integer> l) {} + public void bar(L l) {} + public L, @Nullable Integer> baz1() { return null; } + public L baz2() { return null; } + public L, Integer> baz3() { return null; } +} + +// FILE: main.kt + +import test.L + +fun main(a: test.A, l: L, Int?>, l1: L, Int>) { + a.foo(l) + a.foo(l as L, Int>) + a.foo(l as L, Int?>) + + a.bar(l1) + a.bar(l1 as L, Int?>) + + a.baz1().t().containsKey("") + a.baz1().t().containsKey(null) + a.baz1().t().containsValue(1) + a.baz1().t().containsValue(null) + a.baz1().s().hashCode() + + a.baz1().setT(l.t()) + a.baz1().setT(l.t() as L, Int>) + a.baz1().setT(null) + + a.baz2().t().containsKey("") + a.baz2().t().containsKey(null) + a.baz2().t().containsValue(1) + a.baz2().t().containsValue(null) + a.baz2().s().hashCode() + + a.baz3().t().containsKey("") + a.baz3().t().containsKey(null) + a.baz3().t().containsValue(1) + a.baz3().t().containsValue(null) + a.baz3().s().hashCode() +} diff --git a/compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeArguments.txt b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeArguments.txt new file mode 100644 index 00000000000..57825cbb44e --- /dev/null +++ b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeArguments.txt @@ -0,0 +1,71 @@ +package test + +public open class A { + public constructor A() + public open fun bar(/*0*/ l: test.L<*, kotlin.Int>): kotlin.Unit + public open fun baz1(): test.L, @spr.Nullable kotlin.Int?> + public open fun baz2(): test.L<*, kotlin.Int> + public open fun baz3(): test.L, kotlin.Int> + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ l: test.L, @spr.Nullable kotlin.Int?>): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class L!, /*1*/ S : kotlin.Any!> { + public constructor L!, /*1*/ S : kotlin.Any!>() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun s(): S + public open fun setS(/*0*/ s: S): kotlin.Unit + public open fun setT(/*0*/ @spr.Nullable t: @spr.Nullable T?): kotlin.Unit + public open fun t(): T + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +package + +public fun main(/*0*/ a: test.A, /*1*/ l: test.L, kotlin.Int?>, /*2*/ l1: test.L, kotlin.Int>): kotlin.Unit + +package spr { + + @kotlin.annotation.Target(allowedTargets = {}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @javax.annotation.Nonnull @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.TYPE_USE}) public final annotation class NonNullApi : kotlin.Annotation { + public constructor NonNullApi() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @javax.annotation.Nonnull(when = When.MAYBE) @javax.annotation.meta.TypeQualifierNickname public final annotation class Nullable : kotlin.Annotation { + public constructor Nullable() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +package test { + + public open class A { + public constructor A() + public open fun bar(/*0*/ l: test.L<*, kotlin.Int>): kotlin.Unit + public open fun baz1(): test.L, @spr.Nullable kotlin.Int?> + public open fun baz2(): test.L<*, kotlin.Int> + public open fun baz3(): test.L, kotlin.Int> + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ l: test.L, @spr.Nullable kotlin.Int?>): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open class L!, /*1*/ S : kotlin.Any!> { + public constructor L!, /*1*/ S : kotlin.Any!>() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun s(): S + public open fun setS(/*0*/ s: S): kotlin.Unit + public open fun setT(/*0*/ @spr.Nullable t: @spr.Nullable T?): kotlin.Unit + public open fun t(): T + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeUseVsMethodConflict.kt b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeUseVsMethodConflict.kt new file mode 100644 index 00000000000..d9931c5c933 --- /dev/null +++ b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeUseVsMethodConflict.kt @@ -0,0 +1,80 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// SKIP_JAVAC +// SKIP_COMPILED_JAVA + +// FILE: spr/NonNullApi.java + +package spr; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierDefault; + +@Target({ElementType.TYPE, ElementType.TYPE_USE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Nonnull +@TypeQualifierDefault({ElementType.TYPE_USE, ElementType.METHOD}) +public @interface NonNullApi { +} + +// FILE: spr/NullableApi.java + +package spr; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.Nonnull; +import javax.annotation.meta.TypeQualifierDefault; +import javax.annotation.meta.When; + +@Target({ElementType.TYPE_USE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Nonnull(when = When.MAYBE) +@TypeQualifierDefault({ElementType.TYPE_USE}) +public @interface NullableApi { +} + +// FILE: A.java + +import spr.*; +import java.util.*; + +@NonNullApi +public class A { + public String foo(String x) { return ""; } + public @NullableApi String bar(@NullableApi String y) { return ""; } + public @NullableApi List baz1() { return null; } + public List<@NullableApi String> baz2() { return null; } + public @NullableApi List<@NonNullApi String> baz3() { return null; } +} + +// FILE: main.kt + +fun main(a: A) { + a.foo("").length + a.foo(null)?.length + + a.bar("").length + a.bar(null)?.length + + a.baz1().get(0).length + a.baz1()!!.get(0).length + a.baz1()!!.get(0)?.length + + a.baz2().get(0).length + a.baz2()!!.get(0).length + a.baz2()!!.get(0)?.length + + a.baz3().get(0).length + a.baz3()!!.get(0).length + a.baz3()!!.get(0)?.length +} diff --git a/compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeUseVsMethodConflict.txt b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeUseVsMethodConflict.txt new file mode 100644 index 00000000000..2cf8d4c01fb --- /dev/null +++ b/compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeUseVsMethodConflict.txt @@ -0,0 +1,32 @@ +package + +public fun main(/*0*/ a: A): kotlin.Unit + +@spr.NonNullApi public open class A { + public constructor A() + @spr.NullableApi public open fun bar(/*0*/ @spr.NullableApi y: @spr.NullableApi kotlin.String?): @spr.NullableApi kotlin.String? + @spr.NullableApi public open fun baz1(): (@spr.NullableApi kotlin.collections.MutableList?..@spr.NullableApi kotlin.collections.List?) + public open fun baz2(): kotlin.collections.(Mutable)List<@spr.NullableApi kotlin.String?> + @spr.NullableApi public open fun baz3(): (@spr.NullableApi kotlin.collections.MutableList<@spr.NonNullApi kotlin.String>?..@spr.NullableApi kotlin.collections.List<@spr.NonNullApi kotlin.String>?) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ x: kotlin.String): kotlin.String + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +package spr { + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FILE, AnnotationTarget.TYPE}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @javax.annotation.Nonnull @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.TYPE_USE, ElementType.METHOD}) public final annotation class NonNullApi : kotlin.Annotation { + public constructor NonNullApi() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) @kotlin.annotation.MustBeDocumented @javax.annotation.Nonnull(when = When.MAYBE) @javax.annotation.meta.TypeQualifierDefault(value = {ElementType.TYPE_USE}) public final annotation class NullableApi : kotlin.Annotation { + public constructor NullableApi() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeDifferentConstructor.kt b/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeDifferentConstructor.kt index a590777d855..0ba8da1dd1e 100644 --- a/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeDifferentConstructor.kt +++ b/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeDifferentConstructor.kt @@ -13,26 +13,26 @@ class Outer { class B extends A { @Override - Base foo() {} + Base foo() { return null; } } class C extends A { @Override - @NonNull Base foo() {} + @NonNull Base foo() { return null; } } class D extends A { @Override - Derived foo() {} + Derived foo() { return null; } } class E extends A { @Override - @NonNull Derived foo() {} + @NonNull Derived foo() { return null; } } class F extends A { @Override - @NonNull Derived<@NonNull String> foo() {} + @NonNull Derived<@NonNull String> foo() { return null; } } } diff --git a/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeOverrideInKotlin.kt b/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeOverrideInKotlin.kt index ae567c9733d..f9b0196f55b 100644 --- a/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeOverrideInKotlin.kt +++ b/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeOverrideInKotlin.kt @@ -1,3 +1,6 @@ +// SKIP_COMPILED_JAVA +// FILE: Base.java +public interface Base {} // FILE: A.java import org.checkerframework.checker.nullness.qual.*; @@ -8,7 +11,6 @@ public class A { // FILE: a.kt -interface Base {} interface Derived : Base {} fun bar1(): Derived = null!! diff --git a/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeOverrideInKotlin.txt b/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeOverrideInKotlin.txt index eb9e30f2cc0..bedd264fb31 100644 --- a/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeOverrideInKotlin.txt +++ b/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeOverrideInKotlin.txt @@ -19,7 +19,7 @@ public final class B : A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -public interface Base { +public interface Base { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/simple.kt b/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/simple.kt index 46bded8f1d4..4b52e7f51b2 100644 --- a/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/simple.kt +++ b/compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/simple.kt @@ -4,5 +4,5 @@ import org.checkerframework.checker.nullness.qual.*; import java.util.*; class A { - List<@NonNull String> foo() {} + List<@NonNull String> foo() { return null; } } diff --git a/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.fast.txt b/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.fast.txt new file mode 100644 index 00000000000..5e4ceb48ec3 --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.fast.txt @@ -0,0 +1,14 @@ +package test + +public open class InnerClassTypeAnnotation { + public constructor InnerClassTypeAnnotation() + + @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Foo : kotlin.Annotation { + public constructor Foo() + } + + public open inner class Inner { + public constructor Inner(/*0*/ p0: @test.InnerClassTypeAnnotation.Foo kotlin.String!) + public open fun bar(/*0*/ p0: kotlin.String!, /*1*/ p1: @test.InnerClassTypeAnnotation.Foo kotlin.String!): @test.InnerClassTypeAnnotation.Foo kotlin.String! + } +} diff --git a/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.java b/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.java index 0b9078dcbf8..c507c591e03 100644 --- a/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.java +++ b/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.java @@ -13,6 +13,8 @@ public class InnerClassTypeAnnotation { public class Inner { public Inner(@Foo String foo) { } + + public @Foo String bar(String x, @Foo String y) { return null; } } @Retention(RetentionPolicy.CLASS) diff --git a/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.javac.txt b/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.javac.txt index 88a9361ce8d..d4e98cddc31 100644 --- a/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.javac.txt +++ b/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.javac.txt @@ -9,5 +9,6 @@ public open class InnerClassTypeAnnotation { public open inner class Inner { public constructor Inner(/*0*/ p0: kotlin.String!) + public open fun bar(/*0*/ p0: kotlin.String!, /*1*/ p1: kotlin.String!): kotlin.String! } } diff --git a/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.txt b/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.txt index 0a331d40030..a0cb256777a 100644 --- a/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.txt +++ b/compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.txt @@ -9,5 +9,6 @@ public open class InnerClassTypeAnnotation { public open inner class Inner { public constructor Inner(/*0*/ @test.InnerClassTypeAnnotation.Foo p0: @test.InnerClassTypeAnnotation.Foo kotlin.String!) + @test.InnerClassTypeAnnotation.Foo public open fun bar(/*0*/ p0: kotlin.String!, /*1*/ @test.InnerClassTypeAnnotation.Foo p1: @test.InnerClassTypeAnnotation.Foo kotlin.String!): @test.InnerClassTypeAnnotation.Foo kotlin.String! } } diff --git a/compiler/testData/mockJDK9/jre/lib/annotations.jar b/compiler/testData/mockJDK9/jre/lib/annotations.jar new file mode 100644 index 00000000000..b78e2de180d Binary files /dev/null and b/compiler/testData/mockJDK9/jre/lib/annotations.jar differ diff --git a/compiler/testData/mockJDK9/jre/lib/rt.jar b/compiler/testData/mockJDK9/jre/lib/rt.jar new file mode 100644 index 00000000000..e5ffffef95b Binary files /dev/null and b/compiler/testData/mockJDK9/jre/lib/rt.jar differ diff --git a/compiler/testData/multiplatform/jvmMultifileClass/common.kt b/compiler/testData/multiplatform/jvmMultifileClass/common.kt new file mode 100644 index 00000000000..b3fd69adec3 --- /dev/null +++ b/compiler/testData/multiplatform/jvmMultifileClass/common.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME + +@file:kotlin.jvm.JvmMultifileClass +@file:kotlin.jvm.JvmName("CommonKt") + +expect fun foo() diff --git a/compiler/testData/multiplatform/jvmMultifileClass/jvm.kt b/compiler/testData/multiplatform/jvmMultifileClass/jvm.kt new file mode 100644 index 00000000000..05007b3dc69 --- /dev/null +++ b/compiler/testData/multiplatform/jvmMultifileClass/jvm.kt @@ -0,0 +1,5 @@ +actual fun foo() {} + +fun test() { + foo() +} diff --git a/compiler/testData/multiplatform/jvmMultifileClass/output.txt b/compiler/testData/multiplatform/jvmMultifileClass/output.txt new file mode 100644 index 00000000000..b08950d503d --- /dev/null +++ b/compiler/testData/multiplatform/jvmMultifileClass/output.txt @@ -0,0 +1,7 @@ +-- Common -- +Exit code: OK +Output: + +-- JVM -- +Exit code: OK +Output: diff --git a/compiler/testData/multiplatform/missingOverload/output.txt b/compiler/testData/multiplatform/missingOverload/output.txt index ce4a8d9d137..748fa5fda2e 100644 --- a/compiler/testData/multiplatform/missingOverload/output.txt +++ b/compiler/testData/multiplatform/missingOverload/output.txt @@ -5,7 +5,7 @@ Output: -- JVM -- Exit code: COMPILATION_ERROR Output: -compiler/testData/multiplatform/missingOverload/common.kt:7:1: error: expected function 'g' has no actual in module +compiler/testData/multiplatform/missingOverload/common.kt:7:1: error: expected function 'g' has no actual declaration in module The following declaration is incompatible because parameter types are different: public actual fun g(a: Any): Unit diff --git a/compiler/tests-common-jvm6/src/org/jetbrains/kotlin/test/clientserver/TestProcessServer.kt b/compiler/tests-common-jvm6/src/org/jetbrains/kotlin/test/clientserver/TestProcessServer.kt index 86aa3c50a40..5033a1cf23e 100644 --- a/compiler/tests-common-jvm6/src/org/jetbrains/kotlin/test/clientserver/TestProcessServer.kt +++ b/compiler/tests-common-jvm6/src/org/jetbrains/kotlin/test/clientserver/TestProcessServer.kt @@ -25,6 +25,8 @@ import java.net.Socket import java.net.URL import java.net.URLClassLoader import java.util.concurrent.Executors +import java.util.concurrent.ScheduledFuture +import java.util.concurrent.TimeUnit fun getGeneratedClass(classLoader: ClassLoader, className: String): Class<*> { try { @@ -47,7 +49,19 @@ fun getBoxMethodOrNull(aClass: Class<*>): Method? { //Use only JDK 1.6 compatible api object TestProcessServer { - val executor = Executors.newFixedThreadPool(1)!! + private val executor = Executors.newFixedThreadPool(1)!! + + @Volatile + private var isProcessingTask = true + + @Volatile + private var lastTime = System.currentTimeMillis() + + private val scheduler = Executors.newScheduledThreadPool(1) + + private lateinit var handler: ScheduledFuture<*> + + private lateinit var serverSocket: ServerSocket @JvmStatic fun main(args: Array) { @@ -55,17 +69,34 @@ object TestProcessServer { println("Starting server on port $portNumber...") val serverSocket = ServerSocket(portNumber) + sheduleShutdownProcess() + try { while (true) { + lastTime = System.currentTimeMillis() + isProcessingTask = false val clientSocket = serverSocket.accept() + isProcessingTask = true println("Socket established...") executor.execute(ServerTest(clientSocket)) } } finally { + handler.cancel(false) + scheduler.shutdown() serverSocket.close() + println("Server stopped!") } } + + private fun sheduleShutdownProcess() { + handler = scheduler.scheduleAtFixedRate({ + if (!isProcessingTask && (System.currentTimeMillis() - lastTime) >= 60 * 1000 /*60 sec*/) { + println("Stopping server...") + serverSocket.close() + } + }, 60, 60, TimeUnit.SECONDS) + } } private class ServerTest(val clientSocket: Socket) : Runnable { diff --git a/compiler/tests-common/org/jetbrains/kotlin/checkers/KotlinMultiFileTestWithJava.java b/compiler/tests-common/org/jetbrains/kotlin/checkers/KotlinMultiFileTestWithJava.java index 895270b059d..c6836bb44af 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/checkers/KotlinMultiFileTestWithJava.java +++ b/compiler/tests-common/org/jetbrains/kotlin/checkers/KotlinMultiFileTestWithJava.java @@ -86,20 +86,15 @@ public abstract class KotlinMultiFileTestWithJava extends KtUsefulTestCase ContentRootsKt.addKotlinSourceRoot(configuration, kotlinSourceRoot.getPath()); } - KotlinCoreEnvironment environment = - KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, getEnvironmentConfigFiles()); - performCustomConfiguration( - environment - ); - - return environment; + performCustomConfiguration(configuration); + return KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, getEnvironmentConfigFiles()); } protected boolean isJavaSourceRootNeeded() { return true; } - protected void performCustomConfiguration(@NotNull KotlinCoreEnvironment environment) { + protected void performCustomConfiguration(@NotNull CompilerConfiguration configuration) { } diff --git a/compiler/tests-common/org/jetbrains/kotlin/codegen/forTestCompile/ForTestCompileRuntime.java b/compiler/tests-common/org/jetbrains/kotlin/codegen/forTestCompile/ForTestCompileRuntime.java index 9253f4ab78a..98e2e6f4d3e 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/codegen/forTestCompile/ForTestCompileRuntime.java +++ b/compiler/tests-common/org/jetbrains/kotlin/codegen/forTestCompile/ForTestCompileRuntime.java @@ -71,6 +71,11 @@ public class ForTestCompileRuntime { return assertExists(new File("dist/kotlinc/lib/kotlin-stdlib-js.jar")); } + @NotNull + public static File jvmAnnotationsForTests() { + return assertExists(new File("dist/kotlinc/lib/kotlin-annotations-jvm.jar")); + } + // TODO: Do not use these classes, remove them after stdlib tests are merged in the same build as the compiler @NotNull @Deprecated diff --git a/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java index 00164f1d785..324f4a42ad5 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -90,6 +90,7 @@ import org.junit.Assert; import javax.tools.*; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.StringWriter; import java.lang.reflect.Method; @@ -438,7 +439,21 @@ public class KotlinTestUtils { } public static String doLoadFile(@NotNull File file) throws IOException { - return FileUtil.loadFile(file, CharsetToolkit.UTF8, true); + try { + return FileUtil.loadFile(file, CharsetToolkit.UTF8, true); + } + catch (FileNotFoundException fileNotFoundException) { + /* + * Unfortunately, the FileNotFoundException will only show the relative path in it's exception message. + * This clarifies the exception by showing the full path. + */ + String messageWithFullPath = file.getAbsolutePath() + " (No such file or directory)"; + throw new IOException( + "Ensure you have your 'Working Directory' configured correctly as the root " + + "Kotlin project directory in your test configuration\n\t" + + messageWithFullPath, + fileNotFoundException); + } } public static String getFilePath(File file) { diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 0607d17ad88..4584c79d688 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -4275,6 +4275,45 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @TestMetadata("compiler/testData/codegen/box/constructorCall") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConstructorCall extends AbstractIrBlackBoxCodegenTest { + public void testAllFilesPresentInConstructorCall() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/constructorCall"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("inlineFunInConstructorCallEvaluationOrder.kt") + public void testInlineFunInConstructorCallEvaluationOrder() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/inlineFunInConstructorCallEvaluationOrder.kt"); + doTest(fileName); + } + + @TestMetadata("inlineFunInInnerClassConstructorCall.kt") + public void testInlineFunInInnerClassConstructorCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/inlineFunInInnerClassConstructorCall.kt"); + doTest(fileName); + } + + @TestMetadata("inlineFunInLocalClassConstructorCall.kt") + public void testInlineFunInLocalClassConstructorCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/inlineFunInLocalClassConstructorCall.kt"); + doTest(fileName); + } + + @TestMetadata("regularConstructorCallEvaluationOrder.kt") + public void testRegularConstructorCallEvaluationOrder() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/regularConstructorCallEvaluationOrder.kt"); + doTest(fileName); + } + + @TestMetadata("tryCatchInConstructorCallEvaluationOrder.kt") + public void testTryCatchInConstructorCallEvaluationOrder() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/tryCatchInConstructorCallEvaluationOrder.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/codegen/box/controlStructures") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -5749,6 +5788,30 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } + @TestMetadata("inlineMultiModule.kt") + public void testInlineMultiModule() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModule.kt"); + doTest(fileName); + } + + @TestMetadata("inlineMultiModuleOverride.kt") + public void testInlineMultiModuleOverride() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleOverride.kt"); + try { + doTest(fileName); + } + catch (Throwable ignore) { + return; + } + throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + } + + @TestMetadata("inlineMultiModuleWithController.kt") + public void testInlineMultiModuleWithController() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithController.kt"); + doTest(fileName); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/simple.kt"); @@ -6440,6 +6503,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); } + @TestMetadata("inheritedFromInterfaceViaAbstractSuperclass.kt") + public void testInheritedFromInterfaceViaAbstractSuperclass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/inheritedFromInterfaceViaAbstractSuperclass.kt"); + doTest(fileName); + } + @TestMetadata("kt6382.kt") public void testKt6382() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/kt6382.kt"); @@ -6884,6 +6953,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); } + @TestMetadata("genericSetValueViaSyntheticAccessor.kt") + public void testGenericSetValueViaSyntheticAccessor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/genericSetValueViaSyntheticAccessor.kt"); + doTest(fileName); + } + @TestMetadata("getAsExtensionFun.kt") public void testGetAsExtensionFun() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/getAsExtensionFun.kt"); @@ -12155,6 +12230,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } + @TestMetadata("kt20387.kt") + public void testKt20387() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt20387.kt"); + doTest(fileName); + } + @TestMetadata("kt4152.kt") public void testKt4152() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); @@ -13739,6 +13820,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } + @TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt") + public void testForInRangeLiteralWithMixedTypeBounds() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt"); + doTest(fileName); + } + @TestMetadata("forInRangeToConstWithOverflow.kt") public void testForInRangeToConstWithOverflow() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInRangeToConstWithOverflow.kt"); @@ -18922,6 +19009,24 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class SyntheticAccessors extends AbstractIrBlackBoxCodegenTest { + @TestMetadata("accessorForGenericConstructor.kt") + public void testAccessorForGenericConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethod.kt") + public void testAccessorForGenericMethod() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethodWithDefaults.kt") + public void testAccessorForGenericMethodWithDefaults() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt"); + doTest(fileName); + } + @TestMetadata("accessorForProtected.kt") public void testAccessorForProtected() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForProtected.kt"); @@ -19643,6 +19748,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } + @TestMetadata("doNotCopyImmediatelyCreatedArrays.kt") + public void testDoNotCopyImmediatelyCreatedArrays() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/vararg/doNotCopyImmediatelyCreatedArrays.kt"); + doTest(fileName); + } + @TestMetadata("kt1978.kt") public void testKt1978() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/vararg/kt1978.kt"); diff --git a/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/ForeignJava8AnnotationsNoAnnotationInClasspathTestGenerated.java b/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/ForeignJava8AnnotationsNoAnnotationInClasspathTestGenerated.java new file mode 100644 index 00000000000..4e59e622e7b --- /dev/null +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/ForeignJava8AnnotationsNoAnnotationInClasspathTestGenerated.java @@ -0,0 +1,128 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.checkers; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class ForeignJava8AnnotationsNoAnnotationInClasspathTestGenerated extends AbstractForeignJava8AnnotationsNoAnnotationInClasspathTest { + public void testAllFilesPresentInTests() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("checkerFramework.kt") + public void testCheckerFramework() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/checkerFramework.kt"); + doTest(fileName); + } + + @TestMetadata("eclipse.kt") + public void testEclipse() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/eclipse.kt"); + doTest(fileName); + } + + @TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jsr305 extends AbstractForeignJava8AnnotationsNoAnnotationInClasspathTest { + public void testAllFilesPresentInJsr305() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jsr305"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("defaultAnnotationAppliedToType.kt") + public void testDefaultAnnotationAppliedToType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToType.kt"); + doTest(fileName); + } + + @TestMetadata("defaultAnnotationAppliedToTypeForCompiledJava.kt") + public void testDefaultAnnotationAppliedToTypeForCompiledJava() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToTypeForCompiledJava.kt"); + doTest(fileName); + } + + @TestMetadata("springNullableWithTypeUse.kt") + public void testSpringNullableWithTypeUse() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/springNullableWithTypeUse.kt"); + doTest(fileName); + } + + @TestMetadata("typeArguments.kt") + public void testTypeArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeArguments.kt"); + doTest(fileName); + } + + @TestMetadata("typeUseVsMethodConflict.kt") + public void testTypeUseVsMethodConflict() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeUseVsMethodConflict.kt"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeEnhancement extends AbstractForeignJava8AnnotationsNoAnnotationInClasspathTest { + public void testAllFilesPresentInTypeEnhancement() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("annotatedTypeArguments.kt") + public void testAnnotatedTypeArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/annotatedTypeArguments.kt"); + doTest(fileName); + } + + @TestMetadata("methodWithTypeParameter.kt") + public void testMethodWithTypeParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/methodWithTypeParameter.kt"); + doTest(fileName); + } + + @TestMetadata("returnTypeDifferentConstructor.kt") + public void testReturnTypeDifferentConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeDifferentConstructor.kt"); + doTest(fileName); + } + + @TestMetadata("returnTypeOverrideInKotlin.kt") + public void testReturnTypeOverrideInKotlin() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeOverrideInKotlin.kt"); + doTest(fileName); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/simple.kt"); + doTest(fileName); + } + } +} diff --git a/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/ForeignJava8AnnotationsNoAnnotationInClasspathWithFastClassReadingTestGenerated.java b/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/ForeignJava8AnnotationsNoAnnotationInClasspathWithFastClassReadingTestGenerated.java new file mode 100644 index 00000000000..33ac4d93fbf --- /dev/null +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/ForeignJava8AnnotationsNoAnnotationInClasspathWithFastClassReadingTestGenerated.java @@ -0,0 +1,128 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.checkers; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class ForeignJava8AnnotationsNoAnnotationInClasspathWithFastClassReadingTestGenerated extends AbstractForeignJava8AnnotationsNoAnnotationInClasspathWithFastClassReadingTest { + public void testAllFilesPresentInTests() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("checkerFramework.kt") + public void testCheckerFramework() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/checkerFramework.kt"); + doTest(fileName); + } + + @TestMetadata("eclipse.kt") + public void testEclipse() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/eclipse.kt"); + doTest(fileName); + } + + @TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jsr305 extends AbstractForeignJava8AnnotationsNoAnnotationInClasspathWithFastClassReadingTest { + public void testAllFilesPresentInJsr305() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jsr305"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("defaultAnnotationAppliedToType.kt") + public void testDefaultAnnotationAppliedToType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToType.kt"); + doTest(fileName); + } + + @TestMetadata("defaultAnnotationAppliedToTypeForCompiledJava.kt") + public void testDefaultAnnotationAppliedToTypeForCompiledJava() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToTypeForCompiledJava.kt"); + doTest(fileName); + } + + @TestMetadata("springNullableWithTypeUse.kt") + public void testSpringNullableWithTypeUse() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/springNullableWithTypeUse.kt"); + doTest(fileName); + } + + @TestMetadata("typeArguments.kt") + public void testTypeArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeArguments.kt"); + doTest(fileName); + } + + @TestMetadata("typeUseVsMethodConflict.kt") + public void testTypeUseVsMethodConflict() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeUseVsMethodConflict.kt"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeEnhancement extends AbstractForeignJava8AnnotationsNoAnnotationInClasspathWithFastClassReadingTest { + public void testAllFilesPresentInTypeEnhancement() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("annotatedTypeArguments.kt") + public void testAnnotatedTypeArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/annotatedTypeArguments.kt"); + doTest(fileName); + } + + @TestMetadata("methodWithTypeParameter.kt") + public void testMethodWithTypeParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/methodWithTypeParameter.kt"); + doTest(fileName); + } + + @TestMetadata("returnTypeDifferentConstructor.kt") + public void testReturnTypeDifferentConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeDifferentConstructor.kt"); + doTest(fileName); + } + + @TestMetadata("returnTypeOverrideInKotlin.kt") + public void testReturnTypeOverrideInKotlin() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeOverrideInKotlin.kt"); + doTest(fileName); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/simple.kt"); + doTest(fileName); + } + } +} diff --git a/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/ForeignJava8AnnotationsTestGenerated.java b/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/ForeignJava8AnnotationsTestGenerated.java index a4ec796498a..5822c98f8e3 100644 --- a/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/ForeignJava8AnnotationsTestGenerated.java +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/ForeignJava8AnnotationsTestGenerated.java @@ -48,10 +48,43 @@ public class ForeignJava8AnnotationsTestGenerated extends AbstractForeignJava8An doTest(fileName); } - @TestMetadata("springNullableWithTypeUse.kt") - public void testSpringNullableWithTypeUse() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/springNullableWithTypeUse.kt"); - doTest(fileName); + @TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jsr305 extends AbstractForeignJava8AnnotationsTest { + public void testAllFilesPresentInJsr305() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jsr305"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("defaultAnnotationAppliedToType.kt") + public void testDefaultAnnotationAppliedToType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToType.kt"); + doTest(fileName); + } + + @TestMetadata("defaultAnnotationAppliedToTypeForCompiledJava.kt") + public void testDefaultAnnotationAppliedToTypeForCompiledJava() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToTypeForCompiledJava.kt"); + doTest(fileName); + } + + @TestMetadata("springNullableWithTypeUse.kt") + public void testSpringNullableWithTypeUse() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/springNullableWithTypeUse.kt"); + doTest(fileName); + } + + @TestMetadata("typeArguments.kt") + public void testTypeArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeArguments.kt"); + doTest(fileName); + } + + @TestMetadata("typeUseVsMethodConflict.kt") + public void testTypeUseVsMethodConflict() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeUseVsMethodConflict.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement") diff --git a/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/javac/JavacForeignJava8AnnotationsTestGenerated.java b/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/javac/JavacForeignJava8AnnotationsTestGenerated.java index 20436052572..ab8fa8f1b6d 100644 --- a/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/javac/JavacForeignJava8AnnotationsTestGenerated.java +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/javac/JavacForeignJava8AnnotationsTestGenerated.java @@ -48,10 +48,43 @@ public class JavacForeignJava8AnnotationsTestGenerated extends AbstractJavacFore doTest(fileName); } - @TestMetadata("springNullableWithTypeUse.kt") - public void testSpringNullableWithTypeUse() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/springNullableWithTypeUse.kt"); - doTest(fileName); + @TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Jsr305 extends AbstractJavacForeignJava8AnnotationsTest { + public void testAllFilesPresentInJsr305() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jsr305"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("defaultAnnotationAppliedToType.kt") + public void testDefaultAnnotationAppliedToType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToType.kt"); + doTest(fileName); + } + + @TestMetadata("defaultAnnotationAppliedToTypeForCompiledJava.kt") + public void testDefaultAnnotationAppliedToTypeForCompiledJava() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/defaultAnnotationAppliedToTypeForCompiledJava.kt"); + doTest(fileName); + } + + @TestMetadata("springNullableWithTypeUse.kt") + public void testSpringNullableWithTypeUse() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/springNullableWithTypeUse.kt"); + doTest(fileName); + } + + @TestMetadata("typeArguments.kt") + public void testTypeArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeArguments.kt"); + doTest(fileName); + } + + @TestMetadata("typeUseVsMethodConflict.kt") + public void testTypeUseVsMethodConflict() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305/typeUseVsMethodConflict.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement") diff --git a/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/AbstractLoadJava8WithFastClassReadingTest.kt b/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/AbstractLoadJava8WithFastClassReadingTest.kt new file mode 100644 index 00000000000..5d46c979330 --- /dev/null +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/AbstractLoadJava8WithFastClassReadingTest.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jvm.compiler + +import org.jetbrains.kotlin.test.TestJdkKind + +abstract class AbstractLoadJava8WithFastClassReadingTest : AbstractLoadJavaWithFastClassReadingTest() { + override fun getJdkKind() = TestJdkKind.FULL_JDK +} diff --git a/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/LoadJava8WithFastClassReadingTestGenerated.java b/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/LoadJava8WithFastClassReadingTestGenerated.java new file mode 100644 index 00000000000..fb492074da9 --- /dev/null +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/LoadJava8WithFastClassReadingTestGenerated.java @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jvm.compiler; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/loadJava8/compiledJava") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class LoadJava8WithFastClassReadingTestGenerated extends AbstractLoadJava8WithFastClassReadingTest { + public void testAllFilesPresentInCompiledJava() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/loadJava8/compiledJava"), Pattern.compile("^(.+)\\.java$"), TargetBackend.ANY, true); + } + + @TestMetadata("InnerClassTypeAnnotation.java") + public void testInnerClassTypeAnnotation() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava8/compiledJava/InnerClassTypeAnnotation.java"); + doTestCompiledJava(fileName); + } + + @TestMetadata("MapRemove.java") + public void testMapRemove() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava8/compiledJava/MapRemove.java"); + doTestCompiledJava(fileName); + } + + @TestMetadata("TypeAnnotations.java") + public void testTypeAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava8/compiledJava/TypeAnnotations.java"); + doTestCompiledJava(fileName); + } + + @TestMetadata("TypeParameterAnnotations.java") + public void testTypeParameterAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.java"); + doTestCompiledJava(fileName); + } +} diff --git a/compiler/tests/org/jetbrains/kotlin/cfg/AbstractDataFlowTest.java b/compiler/tests/org/jetbrains/kotlin/cfg/AbstractDataFlowTest.java index 949087bd872..58380e00b6e 100644 --- a/compiler/tests/org/jetbrains/kotlin/cfg/AbstractDataFlowTest.java +++ b/compiler/tests/org/jetbrains/kotlin/cfg/AbstractDataFlowTest.java @@ -39,28 +39,29 @@ public abstract class AbstractDataFlowTest extends AbstractPseudocodeTest { @NotNull BindingContext bindingContext ) { PseudocodeVariablesData pseudocodeVariablesData = new PseudocodeVariablesData(pseudocode.getRootPseudocode(), bindingContext); - Map> variableInitializers = + Map> variableInitializers = pseudocodeVariablesData.getVariableInitializers(); - Map> useStatusData = + Map>> useStatusData = pseudocodeVariablesData.getVariableUseStatusData(); String initPrefix = " INIT:"; String usePrefix = " USE:"; - int initializersColumnWidth = countDataColumnWidth(initPrefix, pseudocode.getInstructionsIncludingDeadCode(), variableInitializers); + int initializersColumnWidth = countDataColumnWidth(initPrefix, pseudocode.getInstructionsIncludingDeadCode(), variableInitializers, + pseudocodeVariablesData); dumpInstructions(pseudocode, out, (instruction, next, prev) -> { StringBuilder result = new StringBuilder(); - Edges initializersEdges = variableInitializers.get(instruction); - Edges previousInitializersEdges = variableInitializers.get(prev); + Edges initializersEdges = variableInitializers.get(instruction); + Edges previousInitializersEdges = variableInitializers.get(prev); String initializersData = ""; if (initializersEdges != null && !initializersEdges.equals(previousInitializersEdges)) { - initializersData = dumpEdgesData(initPrefix, initializersEdges); + initializersData = dumpEdgesData(initPrefix, initializersEdges, pseudocodeVariablesData); } result.append(String.format("%1$-" + initializersColumnWidth + "s", initializersData)); - Edges useStatusEdges = useStatusData.get(instruction); - Edges nextUseStatusEdges = useStatusData.get(next); + Edges> useStatusEdges = useStatusData.get(instruction); + Edges> nextUseStatusEdges = useStatusData.get(next); if (useStatusEdges != null && !useStatusEdges.equals(nextUseStatusEdges)) { - result.append(dumpEdgesData(usePrefix, useStatusEdges)); + result.append(dumpEdgesData(usePrefix, useStatusEdges, pseudocodeVariablesData)); } return result.toString(); }); @@ -69,13 +70,14 @@ public abstract class AbstractDataFlowTest extends AbstractPseudocodeTest { private static int countDataColumnWidth( @NotNull String prefix, @NotNull List instructions, - @NotNull Map> data + @NotNull Map> data, + @NotNull PseudocodeVariablesData variablesData ) { int maxWidth = 0; for (Instruction instruction : instructions) { - Edges edges = data.get(instruction); + Edges edges = data.get(instruction); if (edges == null) continue; - int length = dumpEdgesData(prefix, edges).length(); + int length = dumpEdgesData(prefix, edges, variablesData).length(); if (maxWidth < length) { maxWidth = length; } @@ -85,17 +87,27 @@ public abstract class AbstractDataFlowTest extends AbstractPseudocodeTest { } @NotNull - private static > String dumpEdgesData(String prefix, @NotNull Edges edges) { + private static > String dumpEdgesData( + String prefix, + @NotNull Edges edges, + @NotNull PseudocodeVariablesData variablesData + ) { return prefix + - " in: " + renderVariableMap(edges.getIncoming()) + - " out: " + renderVariableMap(edges.getOutgoing()); + " in: " + renderVariableMap(edges.getIncoming().asMap(), variablesData) + + " out: " + renderVariableMap(edges.getOutgoing().asMap(), variablesData); } - private static String renderVariableMap(javaslang.collection.Map map) { + private static String renderVariableMap( + javaslang.collection.Map map, + PseudocodeVariablesData variablesData + ) { List result = Lists.newArrayList(); for (Tuple2 entry : map) { VariableDescriptor variable = entry._1; S state = entry._2; + + if (variablesData.isVariableWithTrivialInitializer(variable)) continue; + result.add(variable.getName() + "=" + state); } Collections.sort(result); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignAnnotationsNoAnnotationInClasspathTest.kt b/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignAnnotationsNoAnnotationInClasspathTest.kt index 0328196f3e4..cbbc9e92e47 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignAnnotationsNoAnnotationInClasspathTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignAnnotationsNoAnnotationInClasspathTest.kt @@ -19,11 +19,11 @@ package org.jetbrains.kotlin.checkers import org.jetbrains.kotlin.codegen.CodegenTestUtil import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.KotlinTestUtils -import org.jetbrains.kotlin.test.MockLibraryUtil import java.io.File abstract class AbstractForeignAnnotationsNoAnnotationInClasspathTest : AbstractForeignAnnotationsTest() { private val compiledJavaPath = KotlinTestUtils.tmpDir("java-compiled-files") + override fun getExtraClasspath(): List { val foreignAnnotations = createJarWithForeignAnnotations() val testAnnotations = compileTestAnnotations(foreignAnnotations) @@ -45,7 +45,4 @@ abstract class AbstractForeignAnnotationsNoAnnotationInClasspathTest : AbstractF override fun isJavaSourceRootNeeded() = false override fun skipDescriptorsValidation() = true - - private fun createJarWithForeignAnnotations(): List = - listOf(MockLibraryUtil.compileJvmLibraryToJar(annotationsPath, "foreign-annotations")) } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest.kt b/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest.kt index 8a5bef70263..475529e2a9b 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest.kt @@ -16,12 +16,12 @@ package org.jetbrains.kotlin.checkers -import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment +import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.JVMConfigurationKeys abstract class AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest : AbstractForeignAnnotationsNoAnnotationInClasspathTest() { - override fun performCustomConfiguration(environment: KotlinCoreEnvironment) { - super.performCustomConfiguration(environment) - environment.configuration.put(JVMConfigurationKeys.USE_FAST_CLASS_FILES_READING, true) + override fun performCustomConfiguration(configuration: CompilerConfiguration) { + super.performCustomConfiguration(configuration) + configuration.put(JVMConfigurationKeys.USE_FAST_CLASS_FILES_READING, true) } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignAnnotationsTest.kt b/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignAnnotationsTest.kt index 8325ae758f7..702f757c01c 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignAnnotationsTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignAnnotationsTest.kt @@ -16,23 +16,26 @@ package org.jetbrains.kotlin.checkers +import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime import org.jetbrains.kotlin.config.* import org.jetbrains.kotlin.test.ConfigurationKind import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.MockLibraryUtil import org.jetbrains.kotlin.test.TestJdkKind import org.jetbrains.kotlin.utils.Jsr305State +import org.jetbrains.kotlin.utils.ReportLevel import java.io.File val FOREIGN_ANNOTATIONS_SOURCES_PATH = "third-party/annotations" val TEST_ANNOTATIONS_SOURCE_PATH = "compiler/testData/foreignAnnotations/testAnnotations" abstract class AbstractForeignAnnotationsTest : AbstractDiagnosticsTest() { - private val WARNING_FOR_JSR305_ANNOTATIONS_DIRECTIVE = "WARNING_FOR_JSR305_ANNOTATIONS" - private val JSR305_ANNOTATIONS_IGNORE_DIRECTIVE = "JSR305_ANNOTATIONS_IGNORE" + private val JSR305_GLOBAL_DIRECTIVE = "JSR305_GLOBAL_REPORT" + private val JSR305_MIGRATION_DIRECTIVE = "JSR305_MIGRATION_REPORT" + private val JSR305_SPECIAL_DIRECTIVE = "JSR305_SPECIAL_REPORT" override fun getExtraClasspath(): List { - val foreignAnnotations = listOf(MockLibraryUtil.compileJvmLibraryToJar(annotationsPath, "foreign-annotations")) + val foreignAnnotations = createJarWithForeignAnnotations() return foreignAnnotations + compileTestAnnotations(foreignAnnotations) } @@ -40,9 +43,15 @@ abstract class AbstractForeignAnnotationsTest : AbstractDiagnosticsTest() { listOf(MockLibraryUtil.compileJvmLibraryToJar( TEST_ANNOTATIONS_SOURCE_PATH, "test-foreign-annotations", + extraOptions = listOf("-Xallow-kotlin-package"), extraClasspath = extraClassPath.map { it.path } )) + protected fun createJarWithForeignAnnotations(): List = listOf( + MockLibraryUtil.compileJvmLibraryToJar(annotationsPath, "foreign-annotations"), + ForTestCompileRuntime.jvmAnnotationsForTests() + ) + override fun getConfigurationKind(): ConfigurationKind = ConfigurationKind.ALL override fun getTestJdkKind(file: File): TestJdkKind = TestJdkKind.FULL_JDK @@ -51,22 +60,27 @@ abstract class AbstractForeignAnnotationsTest : AbstractDiagnosticsTest() { get() = FOREIGN_ANNOTATIONS_SOURCES_PATH override fun loadLanguageVersionSettings(module: List): LanguageVersionSettings { - val hasWarningDirective = module.any { - InTextDirectivesUtils.isDirectiveDefined(it.expectedText, WARNING_FOR_JSR305_ANNOTATIONS_DIRECTIVE) - } - - val hasIgnoreDirective = module.any { - InTextDirectivesUtils.isDirectiveDefined(it.expectedText, JSR305_ANNOTATIONS_IGNORE_DIRECTIVE) - } - - val jsr305State = when { - hasIgnoreDirective -> Jsr305State.IGNORE - hasWarningDirective -> Jsr305State.WARN - else -> Jsr305State.STRICT - } - - return LanguageVersionSettingsImpl(LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE, - mapOf(AnalysisFlag.jsr305 to jsr305State) - ) + val analysisFlags = loadAnalysisFlags(module) + return LanguageVersionSettingsImpl(LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE, analysisFlags) } + + private fun loadAnalysisFlags(module: List): Map, Any?> { + val globalState = module.getDirectiveValue(JSR305_GLOBAL_DIRECTIVE) ?: ReportLevel.STRICT + val migrationState = module.getDirectiveValue(JSR305_MIGRATION_DIRECTIVE) + + val userAnnotationsState = module.flatMap { + InTextDirectivesUtils.findListWithPrefixes(it.expectedText, JSR305_SPECIAL_DIRECTIVE) + }.mapNotNull { + val (name, stateDescription) = it.split(":").takeIf { it.size == 2 } ?: return@mapNotNull null + val state = ReportLevel.findByDescription(stateDescription) ?: return@mapNotNull null + + name to state + }.toMap() + + return mapOf(AnalysisFlag.jsr305 to Jsr305State(globalState, migrationState, userAnnotationsState)) + } + + private fun List.getDirectiveValue(directive: String): ReportLevel? = mapNotNull { + InTextDirectivesUtils.findLinesWithPrefixesRemoved(it.expectedText, directive).firstOrNull() + }.firstOrNull().let { ReportLevel.findByDescription(it) } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignJava8AnnotationsTest.kt b/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignJava8AnnotationsTest.kt index 8556fbc5059..edc620bf577 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignJava8AnnotationsTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/checkers/AbstractForeignJava8AnnotationsTest.kt @@ -16,7 +16,36 @@ package org.jetbrains.kotlin.checkers +import org.jetbrains.kotlin.test.InTextDirectivesUtils +import java.io.File + abstract class AbstractForeignJava8AnnotationsTest : AbstractForeignAnnotationsTest() { override val annotationsPath: String - get() = "third-party/jdk8-annotations" + get() = JAVA8_ANNOTATION_SOURCES_PATH } + +abstract class AbstractForeignJava8AnnotationsNoAnnotationInClasspathTest : AbstractForeignAnnotationsNoAnnotationInClasspathTest() { + override val annotationsPath: String + get() = JAVA8_ANNOTATION_SOURCES_PATH + + override fun analyzeAndCheck(testDataFile: File, files: List) { + if (skipForCompiledVersion(files)) return + super.analyzeAndCheck(testDataFile, files) + } +} + +abstract class AbstractForeignJava8AnnotationsNoAnnotationInClasspathWithFastClassReadingTest : AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest() { + override val annotationsPath: String + get() = JAVA8_ANNOTATION_SOURCES_PATH + + override fun analyzeAndCheck(testDataFile: File, files: List) { + if (skipForCompiledVersion(files)) return + super.analyzeAndCheck(testDataFile, files) + } +} + +private fun skipForCompiledVersion(files: List) = + files.any { file -> InTextDirectivesUtils.isDirectiveDefined(file.expectedText, "// SKIP_COMPILED_JAVA") } + + +private const val JAVA8_ANNOTATION_SOURCES_PATH = "third-party/jdk8-annotations" diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 283319ea36e..c85c0289ea4 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -13934,6 +13934,18 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class HeaderClass extends AbstractDiagnosticsTest { + @TestMetadata("actualClassWithDefaultValuesInAnnotationViaTypealias.kt") + public void testActualClassWithDefaultValuesInAnnotationViaTypealias() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDefaultValuesInAnnotationViaTypealias.kt"); + doTest(fileName); + } + + @TestMetadata("actualMissing.kt") + public void testActualMissing() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.kt"); + doTest(fileName); + } + public void testAllFilesPresentInHeaderClass() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/headerClass"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } @@ -13986,6 +13998,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("memberPropertyKinds.kt") + public void testMemberPropertyKinds() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/memberPropertyKinds.kt"); + doTest(fileName); + } + @TestMetadata("nestedClasses.kt") public void testNestedClasses() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/nestedClasses.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJsStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJsStdLibGenerated.java index 8a92d12fac9..dd2b81ba1da 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJsStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJsStdLibGenerated.java @@ -368,6 +368,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes doTest(fileName); } + @TestMetadata("deleteOperation.kt") + public void testDeleteOperation() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/jsCode/deleteOperation.kt"); + doTest(fileName); + } + @TestMetadata("error.kt") public void testError() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/jsCode/error.kt"); @@ -467,6 +473,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLib/name"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("bridgeClash.kt") + public void testBridgeClash() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/bridgeClash.kt"); + doTest(fileName); + } + @TestMetadata("classAndFunction.kt") public void testClassAndFunction() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/classAndFunction.kt"); @@ -587,6 +599,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes doTest(fileName); } + @TestMetadata("nameSwapInOverride.kt") + public void testNameSwapInOverride() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/nameSwapInOverride.kt"); + doTest(fileName); + } + @TestMetadata("overrideOverloadedNativeFunction.kt") public void testOverrideOverloadedNativeFunction() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/overrideOverloadedNativeFunction.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/ForeignAnnotationsNoAnnotationInClasspathTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/ForeignAnnotationsNoAnnotationInClasspathTestGenerated.java index 3c305f8be1e..e97b4b1e3dc 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/ForeignAnnotationsNoAnnotationInClasspathTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/ForeignAnnotationsNoAnnotationInClasspathTestGenerated.java @@ -60,21 +60,9 @@ public class ForeignAnnotationsNoAnnotationInClasspathTestGenerated extends Abst doTest(fileName); } - @TestMetadata("jsr305NullabilityNicknames.kt") - public void testJsr305NullabilityNicknames() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityNicknames.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Simple.kt") - public void testJsr305Simple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305Simple.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Strange.kt") - public void testJsr305Strange() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305Strange.kt"); + @TestMetadata("irrelevantQualifierNicknames.kt") + public void testIrrelevantQualifierNicknames() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/irrelevantQualifierNicknames.kt"); doTest(fileName); } @@ -90,19 +78,328 @@ public class ForeignAnnotationsNoAnnotationInClasspathTestGenerated extends Abst doTest(fileName); } - @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305Ignore") + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class Jsr305Ignore extends AbstractForeignAnnotationsNoAnnotationInClasspathTest { - public void testAllFilesPresentInJsr305Ignore() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305Ignore"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + public static class Jsr305 extends AbstractForeignAnnotationsNoAnnotationInClasspathTest { + public void testAllFilesPresentInJsr305() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("parametersAreNonnullByDefault.kt") - public void testParametersAreNonnullByDefault() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305Ignore/parametersAreNonnullByDefault.kt"); + @TestMetadata("nonNullNever.kt") + public void testNonNullNever() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nonNullNever.kt"); doTest(fileName); } + + @TestMetadata("nullabilityNicknames.kt") + public void testNullabilityNicknames() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityNicknames.kt"); + doTest(fileName); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/simple.kt"); + doTest(fileName); + } + + @TestMetadata("strange.kt") + public void testStrange() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/strange.kt"); + doTest(fileName); + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/ignore") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Ignore extends AbstractForeignAnnotationsNoAnnotationInClasspathTest { + public void testAllFilesPresentInIgnore() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/ignore"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("parametersAreNonnullByDefault.kt") + public void testParametersAreNonnullByDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/ignore/parametersAreNonnullByDefault.kt"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullabilityWarnings extends AbstractForeignAnnotationsNoAnnotationInClasspathTest { + public void testAllFilesPresentInNullabilityWarnings() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("nullabilityGenerics.kt") + public void testNullabilityGenerics() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityGenerics.kt"); + doTest(fileName); + } + + @TestMetadata("nullabilityNicknames.kt") + public void testNullabilityNicknames() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityNicknames.kt"); + doTest(fileName); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/simple.kt"); + doTest(fileName); + } + + @TestMetadata("strange.kt") + public void testStrange() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/strange.kt"); + doTest(fileName); + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FromPlatformTypes extends AbstractForeignAnnotationsNoAnnotationInClasspathTest { + public void testAllFilesPresentInFromPlatformTypes() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("arithmetic.kt") + public void testArithmetic() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.kt"); + doTest(fileName); + } + + @TestMetadata("array.kt") + public void testArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.kt"); + doTest(fileName); + } + + @TestMetadata("assignToVar.kt") + public void testAssignToVar() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.kt"); + doTest(fileName); + } + + @TestMetadata("conditions.kt") + public void testConditions() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/conditions.kt"); + doTest(fileName); + } + + @TestMetadata("dataFlowInfo.kt") + public void testDataFlowInfo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt"); + doTest(fileName); + } + + @TestMetadata("defaultParameters.kt") + public void testDefaultParameters() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.kt"); + doTest(fileName); + } + + @TestMetadata("delegatedProperties.kt") + public void testDelegatedProperties() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.kt"); + doTest(fileName); + } + + @TestMetadata("delegation.kt") + public void testDelegation() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegation.kt"); + doTest(fileName); + } + + @TestMetadata("derefenceExtension.kt") + public void testDerefenceExtension() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceExtension.kt"); + doTest(fileName); + } + + @TestMetadata("derefenceMember.kt") + public void testDerefenceMember() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceMember.kt"); + doTest(fileName); + } + + @TestMetadata("expectedType.kt") + public void testExpectedType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.kt"); + doTest(fileName); + } + + @TestMetadata("for.kt") + public void testFor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.kt"); + doTest(fileName); + } + + @TestMetadata("functionArguments.kt") + public void testFunctionArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.kt"); + doTest(fileName); + } + + @TestMetadata("invoke.kt") + public void testInvoke() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.kt"); + doTest(fileName); + } + + @TestMetadata("kt6829.kt") + public void testKt6829() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.kt"); + doTest(fileName); + } + + @TestMetadata("multiDeclaration.kt") + public void testMultiDeclaration() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/multiDeclaration.kt"); + doTest(fileName); + } + + @TestMetadata("passToJava.kt") + public void testPassToJava() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.kt"); + doTest(fileName); + } + + @TestMetadata("primitiveArray.kt") + public void testPrimitiveArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.kt"); + doTest(fileName); + } + + @TestMetadata("throw.kt") + public void testThrow() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.kt"); + doTest(fileName); + } + + @TestMetadata("uselessElvisRightIsNull.kt") + public void testUselessElvisRightIsNull() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeQualifierDefault extends AbstractForeignAnnotationsNoAnnotationInClasspathTest { + public void testAllFilesPresentInTypeQualifierDefault() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("fieldsAreNullable.kt") + public void testFieldsAreNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt"); + doTest(fileName); + } + + @TestMetadata("nullabilityFromOverridden.kt") + public void testNullabilityFromOverridden() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt"); + doTest(fileName); + } + + @TestMetadata("overridingDefaultQualifier.kt") + public void testOverridingDefaultQualifier() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefault.kt") + public void testParametersAreNonnullByDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefaultPackage.kt") + public void testParametersAreNonnullByDefaultPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); + doTest(fileName); + } + + @TestMetadata("springNullable.kt") + public void testSpringNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullable.kt"); + doTest(fileName); + } + + @TestMetadata("springNullablePackage.kt") + public void testSpringNullablePackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullablePackage.kt"); + doTest(fileName); + } + } + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeQualifierDefault extends AbstractForeignAnnotationsNoAnnotationInClasspathTest { + public void testAllFilesPresentInTypeQualifierDefault() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("fieldsAreNullable.kt") + public void testFieldsAreNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/fieldsAreNullable.kt"); + doTest(fileName); + } + + @TestMetadata("forceFlexibility.kt") + public void testForceFlexibility() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibility.kt"); + doTest(fileName); + } + + @TestMetadata("forceFlexibleOverOverrides.kt") + public void testForceFlexibleOverOverrides() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibleOverOverrides.kt"); + doTest(fileName); + } + + @TestMetadata("nullabilityFromOverridden.kt") + public void testNullabilityFromOverridden() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/nullabilityFromOverridden.kt"); + doTest(fileName); + } + + @TestMetadata("overridingDefaultQualifier.kt") + public void testOverridingDefaultQualifier() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/overridingDefaultQualifier.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefault.kt") + public void testParametersAreNonnullByDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefault.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefaultPackage.kt") + public void testParametersAreNonnullByDefaultPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); + doTest(fileName); + } + + @TestMetadata("springNullable.kt") + public void testSpringNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullable.kt"); + doTest(fileName); + } + + @TestMetadata("springNullablePackage.kt") + public void testSpringNullablePackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullablePackage.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings") @@ -113,206 +410,65 @@ public class ForeignAnnotationsNoAnnotationInClasspathTestGenerated extends Abst KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("jsr305NullabilityGenerics.kt") - public void testJsr305NullabilityGenerics() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityGenerics.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305NullabilityNicknames.kt") - public void testJsr305NullabilityNicknames() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityNicknames.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Simple.kt") - public void testJsr305Simple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Simple.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Strange.kt") - public void testJsr305Strange() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Strange.kt"); - doTest(fileName); - } - - @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes") + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class FromPlatformTypes extends AbstractForeignAnnotationsNoAnnotationInClasspathTest { - public void testAllFilesPresentInFromPlatformTypes() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + public static class Migration extends AbstractForeignAnnotationsNoAnnotationInClasspathTest { + public void testAllFilesPresentInMigration() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("arithmetic.kt") - public void testArithmetic() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/arithmetic.kt"); + @TestMetadata("customMigration.kt") + public void testCustomMigration() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/customMigration.kt"); doTest(fileName); } - @TestMetadata("array.kt") - public void testArray() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/array.kt"); + @TestMetadata("globalIgnore.kt") + public void testGlobalIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalIgnore.kt"); doTest(fileName); } - @TestMetadata("assignToVar.kt") - public void testAssignToVar() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/assignToVar.kt"); + @TestMetadata("globalWarningMigrationIgnore.kt") + public void testGlobalWarningMigrationIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.kt"); doTest(fileName); } - @TestMetadata("conditions.kt") - public void testConditions() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/conditions.kt"); + @TestMetadata("migrationError.kt") + public void testMigrationError() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationError.kt"); doTest(fileName); } - @TestMetadata("dataFlowInfo.kt") - public void testDataFlowInfo() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt"); + @TestMetadata("migrationIgnore.kt") + public void testMigrationIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationIgnore.kt"); doTest(fileName); } - @TestMetadata("defaultParameters.kt") - public void testDefaultParameters() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/defaultParameters.kt"); + @TestMetadata("migrationWarning.kt") + public void testMigrationWarning() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationWarning.kt"); doTest(fileName); } - @TestMetadata("delegatedProperties.kt") - public void testDelegatedProperties() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegatedProperties.kt"); + @TestMetadata("overrideConflicts.kt") + public void testOverrideConflicts() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/overrideConflicts.kt"); doTest(fileName); } - @TestMetadata("delegation.kt") - public void testDelegation() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegation.kt"); + @TestMetadata("specialCollision.kt") + public void testSpecialCollision() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/specialCollision.kt"); doTest(fileName); } - @TestMetadata("derefenceExtension.kt") - public void testDerefenceExtension() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceExtension.kt"); - doTest(fileName); - } - - @TestMetadata("derefenceMember.kt") - public void testDerefenceMember() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceMember.kt"); - doTest(fileName); - } - - @TestMetadata("expectedType.kt") - public void testExpectedType() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/expectedType.kt"); - doTest(fileName); - } - - @TestMetadata("for.kt") - public void testFor() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/for.kt"); - doTest(fileName); - } - - @TestMetadata("functionArguments.kt") - public void testFunctionArguments() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/functionArguments.kt"); - doTest(fileName); - } - - @TestMetadata("invoke.kt") - public void testInvoke() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/invoke.kt"); - doTest(fileName); - } - - @TestMetadata("kt6829.kt") - public void testKt6829() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/kt6829.kt"); - doTest(fileName); - } - - @TestMetadata("multiDeclaration.kt") - public void testMultiDeclaration() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/multiDeclaration.kt"); - doTest(fileName); - } - - @TestMetadata("passToJava.kt") - public void testPassToJava() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/passToJava.kt"); - doTest(fileName); - } - - @TestMetadata("primitiveArray.kt") - public void testPrimitiveArray() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/primitiveArray.kt"); - doTest(fileName); - } - - @TestMetadata("throw.kt") - public void testThrow() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/throw.kt"); - doTest(fileName); - } - - @TestMetadata("uselessElvisRightIsNull.kt") - public void testUselessElvisRightIsNull() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt"); - doTest(fileName); - } - } - - @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class TypeQualifierDefault extends AbstractForeignAnnotationsNoAnnotationInClasspathTest { - public void testAllFilesPresentInTypeQualifierDefault() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); - } - - @TestMetadata("fieldsAreNullable.kt") - public void testFieldsAreNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt"); - doTest(fileName); - } - - @TestMetadata("nullabilityFromOverridden.kt") - public void testNullabilityFromOverridden() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt"); - doTest(fileName); - } - - @TestMetadata("overridingDefaultQualifier.kt") - public void testOverridingDefaultQualifier() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefault.kt") - public void testParametersAreNonnullByDefault() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefaultPackage.kt") - public void testParametersAreNonnullByDefaultPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); - doTest(fileName); - } - - @TestMetadata("springNullable.kt") - public void testSpringNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullable.kt"); - doTest(fileName); - } - - @TestMetadata("springNullablePackage.kt") - public void testSpringNullablePackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullablePackage.kt"); + @TestMetadata("stateRefinement.kt") + public void testStateRefinement() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/stateRefinement.kt"); doTest(fileName); } } @@ -326,45 +482,9 @@ public class ForeignAnnotationsNoAnnotationInClasspathTestGenerated extends Abst KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("fieldsAreNullable.kt") - public void testFieldsAreNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/fieldsAreNullable.kt"); - doTest(fileName); - } - - @TestMetadata("nullabilityFromOverridden.kt") - public void testNullabilityFromOverridden() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/nullabilityFromOverridden.kt"); - doTest(fileName); - } - - @TestMetadata("overridingDefaultQualifier.kt") - public void testOverridingDefaultQualifier() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/overridingDefaultQualifier.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefault.kt") - public void testParametersAreNonnullByDefault() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefault.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefaultPackage.kt") - public void testParametersAreNonnullByDefaultPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); - doTest(fileName); - } - - @TestMetadata("springNullable.kt") - public void testSpringNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullable.kt"); - doTest(fileName); - } - - @TestMetadata("springNullablePackage.kt") - public void testSpringNullablePackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullablePackage.kt"); + @TestMetadata("defaultAndNicknameMigrationPolicy.kt") + public void testDefaultAndNicknameMigrationPolicy() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.kt"); doTest(fileName); } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/ForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/ForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTestGenerated.java index 7d431287543..61f8851a3de 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/ForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/ForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTestGenerated.java @@ -60,21 +60,9 @@ public class ForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTestGe doTest(fileName); } - @TestMetadata("jsr305NullabilityNicknames.kt") - public void testJsr305NullabilityNicknames() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityNicknames.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Simple.kt") - public void testJsr305Simple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305Simple.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Strange.kt") - public void testJsr305Strange() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305Strange.kt"); + @TestMetadata("irrelevantQualifierNicknames.kt") + public void testIrrelevantQualifierNicknames() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/irrelevantQualifierNicknames.kt"); doTest(fileName); } @@ -90,19 +78,328 @@ public class ForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTestGe doTest(fileName); } - @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305Ignore") + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class Jsr305Ignore extends AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest { - public void testAllFilesPresentInJsr305Ignore() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305Ignore"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + public static class Jsr305 extends AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest { + public void testAllFilesPresentInJsr305() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("parametersAreNonnullByDefault.kt") - public void testParametersAreNonnullByDefault() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305Ignore/parametersAreNonnullByDefault.kt"); + @TestMetadata("nonNullNever.kt") + public void testNonNullNever() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nonNullNever.kt"); doTest(fileName); } + + @TestMetadata("nullabilityNicknames.kt") + public void testNullabilityNicknames() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityNicknames.kt"); + doTest(fileName); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/simple.kt"); + doTest(fileName); + } + + @TestMetadata("strange.kt") + public void testStrange() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/strange.kt"); + doTest(fileName); + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/ignore") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Ignore extends AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest { + public void testAllFilesPresentInIgnore() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/ignore"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("parametersAreNonnullByDefault.kt") + public void testParametersAreNonnullByDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/ignore/parametersAreNonnullByDefault.kt"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullabilityWarnings extends AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest { + public void testAllFilesPresentInNullabilityWarnings() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("nullabilityGenerics.kt") + public void testNullabilityGenerics() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityGenerics.kt"); + doTest(fileName); + } + + @TestMetadata("nullabilityNicknames.kt") + public void testNullabilityNicknames() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityNicknames.kt"); + doTest(fileName); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/simple.kt"); + doTest(fileName); + } + + @TestMetadata("strange.kt") + public void testStrange() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/strange.kt"); + doTest(fileName); + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FromPlatformTypes extends AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest { + public void testAllFilesPresentInFromPlatformTypes() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("arithmetic.kt") + public void testArithmetic() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.kt"); + doTest(fileName); + } + + @TestMetadata("array.kt") + public void testArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.kt"); + doTest(fileName); + } + + @TestMetadata("assignToVar.kt") + public void testAssignToVar() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.kt"); + doTest(fileName); + } + + @TestMetadata("conditions.kt") + public void testConditions() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/conditions.kt"); + doTest(fileName); + } + + @TestMetadata("dataFlowInfo.kt") + public void testDataFlowInfo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt"); + doTest(fileName); + } + + @TestMetadata("defaultParameters.kt") + public void testDefaultParameters() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.kt"); + doTest(fileName); + } + + @TestMetadata("delegatedProperties.kt") + public void testDelegatedProperties() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.kt"); + doTest(fileName); + } + + @TestMetadata("delegation.kt") + public void testDelegation() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegation.kt"); + doTest(fileName); + } + + @TestMetadata("derefenceExtension.kt") + public void testDerefenceExtension() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceExtension.kt"); + doTest(fileName); + } + + @TestMetadata("derefenceMember.kt") + public void testDerefenceMember() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceMember.kt"); + doTest(fileName); + } + + @TestMetadata("expectedType.kt") + public void testExpectedType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.kt"); + doTest(fileName); + } + + @TestMetadata("for.kt") + public void testFor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.kt"); + doTest(fileName); + } + + @TestMetadata("functionArguments.kt") + public void testFunctionArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.kt"); + doTest(fileName); + } + + @TestMetadata("invoke.kt") + public void testInvoke() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.kt"); + doTest(fileName); + } + + @TestMetadata("kt6829.kt") + public void testKt6829() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.kt"); + doTest(fileName); + } + + @TestMetadata("multiDeclaration.kt") + public void testMultiDeclaration() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/multiDeclaration.kt"); + doTest(fileName); + } + + @TestMetadata("passToJava.kt") + public void testPassToJava() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.kt"); + doTest(fileName); + } + + @TestMetadata("primitiveArray.kt") + public void testPrimitiveArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.kt"); + doTest(fileName); + } + + @TestMetadata("throw.kt") + public void testThrow() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.kt"); + doTest(fileName); + } + + @TestMetadata("uselessElvisRightIsNull.kt") + public void testUselessElvisRightIsNull() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeQualifierDefault extends AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest { + public void testAllFilesPresentInTypeQualifierDefault() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("fieldsAreNullable.kt") + public void testFieldsAreNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt"); + doTest(fileName); + } + + @TestMetadata("nullabilityFromOverridden.kt") + public void testNullabilityFromOverridden() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt"); + doTest(fileName); + } + + @TestMetadata("overridingDefaultQualifier.kt") + public void testOverridingDefaultQualifier() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefault.kt") + public void testParametersAreNonnullByDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefaultPackage.kt") + public void testParametersAreNonnullByDefaultPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); + doTest(fileName); + } + + @TestMetadata("springNullable.kt") + public void testSpringNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullable.kt"); + doTest(fileName); + } + + @TestMetadata("springNullablePackage.kt") + public void testSpringNullablePackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullablePackage.kt"); + doTest(fileName); + } + } + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeQualifierDefault extends AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest { + public void testAllFilesPresentInTypeQualifierDefault() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("fieldsAreNullable.kt") + public void testFieldsAreNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/fieldsAreNullable.kt"); + doTest(fileName); + } + + @TestMetadata("forceFlexibility.kt") + public void testForceFlexibility() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibility.kt"); + doTest(fileName); + } + + @TestMetadata("forceFlexibleOverOverrides.kt") + public void testForceFlexibleOverOverrides() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibleOverOverrides.kt"); + doTest(fileName); + } + + @TestMetadata("nullabilityFromOverridden.kt") + public void testNullabilityFromOverridden() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/nullabilityFromOverridden.kt"); + doTest(fileName); + } + + @TestMetadata("overridingDefaultQualifier.kt") + public void testOverridingDefaultQualifier() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/overridingDefaultQualifier.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefault.kt") + public void testParametersAreNonnullByDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefault.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefaultPackage.kt") + public void testParametersAreNonnullByDefaultPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); + doTest(fileName); + } + + @TestMetadata("springNullable.kt") + public void testSpringNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullable.kt"); + doTest(fileName); + } + + @TestMetadata("springNullablePackage.kt") + public void testSpringNullablePackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullablePackage.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings") @@ -113,206 +410,65 @@ public class ForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTestGe KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("jsr305NullabilityGenerics.kt") - public void testJsr305NullabilityGenerics() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityGenerics.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305NullabilityNicknames.kt") - public void testJsr305NullabilityNicknames() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityNicknames.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Simple.kt") - public void testJsr305Simple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Simple.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Strange.kt") - public void testJsr305Strange() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Strange.kt"); - doTest(fileName); - } - - @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes") + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class FromPlatformTypes extends AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest { - public void testAllFilesPresentInFromPlatformTypes() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + public static class Migration extends AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest { + public void testAllFilesPresentInMigration() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("arithmetic.kt") - public void testArithmetic() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/arithmetic.kt"); + @TestMetadata("customMigration.kt") + public void testCustomMigration() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/customMigration.kt"); doTest(fileName); } - @TestMetadata("array.kt") - public void testArray() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/array.kt"); + @TestMetadata("globalIgnore.kt") + public void testGlobalIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalIgnore.kt"); doTest(fileName); } - @TestMetadata("assignToVar.kt") - public void testAssignToVar() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/assignToVar.kt"); + @TestMetadata("globalWarningMigrationIgnore.kt") + public void testGlobalWarningMigrationIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.kt"); doTest(fileName); } - @TestMetadata("conditions.kt") - public void testConditions() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/conditions.kt"); + @TestMetadata("migrationError.kt") + public void testMigrationError() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationError.kt"); doTest(fileName); } - @TestMetadata("dataFlowInfo.kt") - public void testDataFlowInfo() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt"); + @TestMetadata("migrationIgnore.kt") + public void testMigrationIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationIgnore.kt"); doTest(fileName); } - @TestMetadata("defaultParameters.kt") - public void testDefaultParameters() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/defaultParameters.kt"); + @TestMetadata("migrationWarning.kt") + public void testMigrationWarning() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationWarning.kt"); doTest(fileName); } - @TestMetadata("delegatedProperties.kt") - public void testDelegatedProperties() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegatedProperties.kt"); + @TestMetadata("overrideConflicts.kt") + public void testOverrideConflicts() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/overrideConflicts.kt"); doTest(fileName); } - @TestMetadata("delegation.kt") - public void testDelegation() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegation.kt"); + @TestMetadata("specialCollision.kt") + public void testSpecialCollision() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/specialCollision.kt"); doTest(fileName); } - @TestMetadata("derefenceExtension.kt") - public void testDerefenceExtension() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceExtension.kt"); - doTest(fileName); - } - - @TestMetadata("derefenceMember.kt") - public void testDerefenceMember() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceMember.kt"); - doTest(fileName); - } - - @TestMetadata("expectedType.kt") - public void testExpectedType() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/expectedType.kt"); - doTest(fileName); - } - - @TestMetadata("for.kt") - public void testFor() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/for.kt"); - doTest(fileName); - } - - @TestMetadata("functionArguments.kt") - public void testFunctionArguments() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/functionArguments.kt"); - doTest(fileName); - } - - @TestMetadata("invoke.kt") - public void testInvoke() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/invoke.kt"); - doTest(fileName); - } - - @TestMetadata("kt6829.kt") - public void testKt6829() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/kt6829.kt"); - doTest(fileName); - } - - @TestMetadata("multiDeclaration.kt") - public void testMultiDeclaration() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/multiDeclaration.kt"); - doTest(fileName); - } - - @TestMetadata("passToJava.kt") - public void testPassToJava() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/passToJava.kt"); - doTest(fileName); - } - - @TestMetadata("primitiveArray.kt") - public void testPrimitiveArray() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/primitiveArray.kt"); - doTest(fileName); - } - - @TestMetadata("throw.kt") - public void testThrow() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/throw.kt"); - doTest(fileName); - } - - @TestMetadata("uselessElvisRightIsNull.kt") - public void testUselessElvisRightIsNull() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt"); - doTest(fileName); - } - } - - @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class TypeQualifierDefault extends AbstractForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTest { - public void testAllFilesPresentInTypeQualifierDefault() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); - } - - @TestMetadata("fieldsAreNullable.kt") - public void testFieldsAreNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt"); - doTest(fileName); - } - - @TestMetadata("nullabilityFromOverridden.kt") - public void testNullabilityFromOverridden() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt"); - doTest(fileName); - } - - @TestMetadata("overridingDefaultQualifier.kt") - public void testOverridingDefaultQualifier() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefault.kt") - public void testParametersAreNonnullByDefault() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefaultPackage.kt") - public void testParametersAreNonnullByDefaultPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); - doTest(fileName); - } - - @TestMetadata("springNullable.kt") - public void testSpringNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullable.kt"); - doTest(fileName); - } - - @TestMetadata("springNullablePackage.kt") - public void testSpringNullablePackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullablePackage.kt"); + @TestMetadata("stateRefinement.kt") + public void testStateRefinement() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/stateRefinement.kt"); doTest(fileName); } } @@ -326,45 +482,9 @@ public class ForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTestGe KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("fieldsAreNullable.kt") - public void testFieldsAreNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/fieldsAreNullable.kt"); - doTest(fileName); - } - - @TestMetadata("nullabilityFromOverridden.kt") - public void testNullabilityFromOverridden() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/nullabilityFromOverridden.kt"); - doTest(fileName); - } - - @TestMetadata("overridingDefaultQualifier.kt") - public void testOverridingDefaultQualifier() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/overridingDefaultQualifier.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefault.kt") - public void testParametersAreNonnullByDefault() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefault.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefaultPackage.kt") - public void testParametersAreNonnullByDefaultPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); - doTest(fileName); - } - - @TestMetadata("springNullable.kt") - public void testSpringNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullable.kt"); - doTest(fileName); - } - - @TestMetadata("springNullablePackage.kt") - public void testSpringNullablePackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullablePackage.kt"); + @TestMetadata("defaultAndNicknameMigrationPolicy.kt") + public void testDefaultAndNicknameMigrationPolicy() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.kt"); doTest(fileName); } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/ForeignAnnotationsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/ForeignAnnotationsTestGenerated.java index 3314f7217a4..0389aed9adb 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/ForeignAnnotationsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/ForeignAnnotationsTestGenerated.java @@ -60,21 +60,9 @@ public class ForeignAnnotationsTestGenerated extends AbstractForeignAnnotationsT doTest(fileName); } - @TestMetadata("jsr305NullabilityNicknames.kt") - public void testJsr305NullabilityNicknames() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityNicknames.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Simple.kt") - public void testJsr305Simple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305Simple.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Strange.kt") - public void testJsr305Strange() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305Strange.kt"); + @TestMetadata("irrelevantQualifierNicknames.kt") + public void testIrrelevantQualifierNicknames() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/irrelevantQualifierNicknames.kt"); doTest(fileName); } @@ -90,19 +78,328 @@ public class ForeignAnnotationsTestGenerated extends AbstractForeignAnnotationsT doTest(fileName); } - @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305Ignore") + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class Jsr305Ignore extends AbstractForeignAnnotationsTest { - public void testAllFilesPresentInJsr305Ignore() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305Ignore"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + public static class Jsr305 extends AbstractForeignAnnotationsTest { + public void testAllFilesPresentInJsr305() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("parametersAreNonnullByDefault.kt") - public void testParametersAreNonnullByDefault() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305Ignore/parametersAreNonnullByDefault.kt"); + @TestMetadata("nonNullNever.kt") + public void testNonNullNever() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nonNullNever.kt"); doTest(fileName); } + + @TestMetadata("nullabilityNicknames.kt") + public void testNullabilityNicknames() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityNicknames.kt"); + doTest(fileName); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/simple.kt"); + doTest(fileName); + } + + @TestMetadata("strange.kt") + public void testStrange() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/strange.kt"); + doTest(fileName); + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/ignore") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Ignore extends AbstractForeignAnnotationsTest { + public void testAllFilesPresentInIgnore() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/ignore"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("parametersAreNonnullByDefault.kt") + public void testParametersAreNonnullByDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/ignore/parametersAreNonnullByDefault.kt"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullabilityWarnings extends AbstractForeignAnnotationsTest { + public void testAllFilesPresentInNullabilityWarnings() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("nullabilityGenerics.kt") + public void testNullabilityGenerics() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityGenerics.kt"); + doTest(fileName); + } + + @TestMetadata("nullabilityNicknames.kt") + public void testNullabilityNicknames() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityNicknames.kt"); + doTest(fileName); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/simple.kt"); + doTest(fileName); + } + + @TestMetadata("strange.kt") + public void testStrange() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/strange.kt"); + doTest(fileName); + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FromPlatformTypes extends AbstractForeignAnnotationsTest { + public void testAllFilesPresentInFromPlatformTypes() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("arithmetic.kt") + public void testArithmetic() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.kt"); + doTest(fileName); + } + + @TestMetadata("array.kt") + public void testArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.kt"); + doTest(fileName); + } + + @TestMetadata("assignToVar.kt") + public void testAssignToVar() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.kt"); + doTest(fileName); + } + + @TestMetadata("conditions.kt") + public void testConditions() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/conditions.kt"); + doTest(fileName); + } + + @TestMetadata("dataFlowInfo.kt") + public void testDataFlowInfo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt"); + doTest(fileName); + } + + @TestMetadata("defaultParameters.kt") + public void testDefaultParameters() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.kt"); + doTest(fileName); + } + + @TestMetadata("delegatedProperties.kt") + public void testDelegatedProperties() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.kt"); + doTest(fileName); + } + + @TestMetadata("delegation.kt") + public void testDelegation() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegation.kt"); + doTest(fileName); + } + + @TestMetadata("derefenceExtension.kt") + public void testDerefenceExtension() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceExtension.kt"); + doTest(fileName); + } + + @TestMetadata("derefenceMember.kt") + public void testDerefenceMember() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceMember.kt"); + doTest(fileName); + } + + @TestMetadata("expectedType.kt") + public void testExpectedType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.kt"); + doTest(fileName); + } + + @TestMetadata("for.kt") + public void testFor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.kt"); + doTest(fileName); + } + + @TestMetadata("functionArguments.kt") + public void testFunctionArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.kt"); + doTest(fileName); + } + + @TestMetadata("invoke.kt") + public void testInvoke() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.kt"); + doTest(fileName); + } + + @TestMetadata("kt6829.kt") + public void testKt6829() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.kt"); + doTest(fileName); + } + + @TestMetadata("multiDeclaration.kt") + public void testMultiDeclaration() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/multiDeclaration.kt"); + doTest(fileName); + } + + @TestMetadata("passToJava.kt") + public void testPassToJava() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.kt"); + doTest(fileName); + } + + @TestMetadata("primitiveArray.kt") + public void testPrimitiveArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.kt"); + doTest(fileName); + } + + @TestMetadata("throw.kt") + public void testThrow() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.kt"); + doTest(fileName); + } + + @TestMetadata("uselessElvisRightIsNull.kt") + public void testUselessElvisRightIsNull() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeQualifierDefault extends AbstractForeignAnnotationsTest { + public void testAllFilesPresentInTypeQualifierDefault() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("fieldsAreNullable.kt") + public void testFieldsAreNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt"); + doTest(fileName); + } + + @TestMetadata("nullabilityFromOverridden.kt") + public void testNullabilityFromOverridden() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt"); + doTest(fileName); + } + + @TestMetadata("overridingDefaultQualifier.kt") + public void testOverridingDefaultQualifier() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefault.kt") + public void testParametersAreNonnullByDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefaultPackage.kt") + public void testParametersAreNonnullByDefaultPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); + doTest(fileName); + } + + @TestMetadata("springNullable.kt") + public void testSpringNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullable.kt"); + doTest(fileName); + } + + @TestMetadata("springNullablePackage.kt") + public void testSpringNullablePackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullablePackage.kt"); + doTest(fileName); + } + } + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeQualifierDefault extends AbstractForeignAnnotationsTest { + public void testAllFilesPresentInTypeQualifierDefault() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("fieldsAreNullable.kt") + public void testFieldsAreNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/fieldsAreNullable.kt"); + doTest(fileName); + } + + @TestMetadata("forceFlexibility.kt") + public void testForceFlexibility() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibility.kt"); + doTest(fileName); + } + + @TestMetadata("forceFlexibleOverOverrides.kt") + public void testForceFlexibleOverOverrides() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibleOverOverrides.kt"); + doTest(fileName); + } + + @TestMetadata("nullabilityFromOverridden.kt") + public void testNullabilityFromOverridden() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/nullabilityFromOverridden.kt"); + doTest(fileName); + } + + @TestMetadata("overridingDefaultQualifier.kt") + public void testOverridingDefaultQualifier() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/overridingDefaultQualifier.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefault.kt") + public void testParametersAreNonnullByDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefault.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefaultPackage.kt") + public void testParametersAreNonnullByDefaultPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); + doTest(fileName); + } + + @TestMetadata("springNullable.kt") + public void testSpringNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullable.kt"); + doTest(fileName); + } + + @TestMetadata("springNullablePackage.kt") + public void testSpringNullablePackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullablePackage.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings") @@ -113,206 +410,65 @@ public class ForeignAnnotationsTestGenerated extends AbstractForeignAnnotationsT KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("jsr305NullabilityGenerics.kt") - public void testJsr305NullabilityGenerics() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityGenerics.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305NullabilityNicknames.kt") - public void testJsr305NullabilityNicknames() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityNicknames.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Simple.kt") - public void testJsr305Simple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Simple.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Strange.kt") - public void testJsr305Strange() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Strange.kt"); - doTest(fileName); - } - - @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes") + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class FromPlatformTypes extends AbstractForeignAnnotationsTest { - public void testAllFilesPresentInFromPlatformTypes() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + public static class Migration extends AbstractForeignAnnotationsTest { + public void testAllFilesPresentInMigration() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("arithmetic.kt") - public void testArithmetic() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/arithmetic.kt"); + @TestMetadata("customMigration.kt") + public void testCustomMigration() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/customMigration.kt"); doTest(fileName); } - @TestMetadata("array.kt") - public void testArray() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/array.kt"); + @TestMetadata("globalIgnore.kt") + public void testGlobalIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalIgnore.kt"); doTest(fileName); } - @TestMetadata("assignToVar.kt") - public void testAssignToVar() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/assignToVar.kt"); + @TestMetadata("globalWarningMigrationIgnore.kt") + public void testGlobalWarningMigrationIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.kt"); doTest(fileName); } - @TestMetadata("conditions.kt") - public void testConditions() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/conditions.kt"); + @TestMetadata("migrationError.kt") + public void testMigrationError() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationError.kt"); doTest(fileName); } - @TestMetadata("dataFlowInfo.kt") - public void testDataFlowInfo() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt"); + @TestMetadata("migrationIgnore.kt") + public void testMigrationIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationIgnore.kt"); doTest(fileName); } - @TestMetadata("defaultParameters.kt") - public void testDefaultParameters() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/defaultParameters.kt"); + @TestMetadata("migrationWarning.kt") + public void testMigrationWarning() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationWarning.kt"); doTest(fileName); } - @TestMetadata("delegatedProperties.kt") - public void testDelegatedProperties() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegatedProperties.kt"); + @TestMetadata("overrideConflicts.kt") + public void testOverrideConflicts() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/overrideConflicts.kt"); doTest(fileName); } - @TestMetadata("delegation.kt") - public void testDelegation() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegation.kt"); + @TestMetadata("specialCollision.kt") + public void testSpecialCollision() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/specialCollision.kt"); doTest(fileName); } - @TestMetadata("derefenceExtension.kt") - public void testDerefenceExtension() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceExtension.kt"); - doTest(fileName); - } - - @TestMetadata("derefenceMember.kt") - public void testDerefenceMember() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceMember.kt"); - doTest(fileName); - } - - @TestMetadata("expectedType.kt") - public void testExpectedType() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/expectedType.kt"); - doTest(fileName); - } - - @TestMetadata("for.kt") - public void testFor() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/for.kt"); - doTest(fileName); - } - - @TestMetadata("functionArguments.kt") - public void testFunctionArguments() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/functionArguments.kt"); - doTest(fileName); - } - - @TestMetadata("invoke.kt") - public void testInvoke() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/invoke.kt"); - doTest(fileName); - } - - @TestMetadata("kt6829.kt") - public void testKt6829() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/kt6829.kt"); - doTest(fileName); - } - - @TestMetadata("multiDeclaration.kt") - public void testMultiDeclaration() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/multiDeclaration.kt"); - doTest(fileName); - } - - @TestMetadata("passToJava.kt") - public void testPassToJava() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/passToJava.kt"); - doTest(fileName); - } - - @TestMetadata("primitiveArray.kt") - public void testPrimitiveArray() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/primitiveArray.kt"); - doTest(fileName); - } - - @TestMetadata("throw.kt") - public void testThrow() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/throw.kt"); - doTest(fileName); - } - - @TestMetadata("uselessElvisRightIsNull.kt") - public void testUselessElvisRightIsNull() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt"); - doTest(fileName); - } - } - - @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class TypeQualifierDefault extends AbstractForeignAnnotationsTest { - public void testAllFilesPresentInTypeQualifierDefault() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); - } - - @TestMetadata("fieldsAreNullable.kt") - public void testFieldsAreNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt"); - doTest(fileName); - } - - @TestMetadata("nullabilityFromOverridden.kt") - public void testNullabilityFromOverridden() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt"); - doTest(fileName); - } - - @TestMetadata("overridingDefaultQualifier.kt") - public void testOverridingDefaultQualifier() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefault.kt") - public void testParametersAreNonnullByDefault() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefaultPackage.kt") - public void testParametersAreNonnullByDefaultPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); - doTest(fileName); - } - - @TestMetadata("springNullable.kt") - public void testSpringNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullable.kt"); - doTest(fileName); - } - - @TestMetadata("springNullablePackage.kt") - public void testSpringNullablePackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullablePackage.kt"); + @TestMetadata("stateRefinement.kt") + public void testStateRefinement() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/stateRefinement.kt"); doTest(fileName); } } @@ -326,45 +482,9 @@ public class ForeignAnnotationsTestGenerated extends AbstractForeignAnnotationsT KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("fieldsAreNullable.kt") - public void testFieldsAreNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/fieldsAreNullable.kt"); - doTest(fileName); - } - - @TestMetadata("nullabilityFromOverridden.kt") - public void testNullabilityFromOverridden() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/nullabilityFromOverridden.kt"); - doTest(fileName); - } - - @TestMetadata("overridingDefaultQualifier.kt") - public void testOverridingDefaultQualifier() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/overridingDefaultQualifier.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefault.kt") - public void testParametersAreNonnullByDefault() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefault.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefaultPackage.kt") - public void testParametersAreNonnullByDefaultPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); - doTest(fileName); - } - - @TestMetadata("springNullable.kt") - public void testSpringNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullable.kt"); - doTest(fileName); - } - - @TestMetadata("springNullablePackage.kt") - public void testSpringNullablePackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullablePackage.kt"); + @TestMetadata("defaultAndNicknameMigrationPolicy.kt") + public void testDefaultAndNicknameMigrationPolicy() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.kt"); doTest(fileName); } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/AbstractJavacForeignJava8AnnotationsTest.kt b/compiler/tests/org/jetbrains/kotlin/checkers/javac/AbstractJavacForeignJava8AnnotationsTest.kt index a4ec046a3b4..7a2180f4b48 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/AbstractJavacForeignJava8AnnotationsTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/AbstractJavacForeignJava8AnnotationsTest.kt @@ -18,11 +18,14 @@ package org.jetbrains.kotlin.checkers.javac import org.jetbrains.kotlin.checkers.AbstractForeignJava8AnnotationsTest import org.jetbrains.kotlin.config.JVMConfigurationKeys +import org.jetbrains.kotlin.test.InTextDirectivesUtils import java.io.File abstract class AbstractJavacForeignJava8AnnotationsTest : AbstractForeignJava8AnnotationsTest() { override fun analyzeAndCheck(testDataFile: File, files: List) { + if (files.any { file -> InTextDirectivesUtils.isDirectiveDefined(file.expectedText, "// SKIP_JAVAC") }) return + val groupedByModule = files.groupBy(TestFile::module) val allKtFiles = groupedByModule.values.flatMap { getKtFiles(it, true) } environment.registerJavac(kotlinFiles = allKtFiles) @@ -31,4 +34,4 @@ abstract class AbstractJavacForeignJava8AnnotationsTest : AbstractForeignJava8An super.analyzeAndCheck(testDataFile, files) } -} \ No newline at end of file +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 5897434f96a..77099caf3b9 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -13934,6 +13934,18 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class HeaderClass extends AbstractDiagnosticsUsingJavacTest { + @TestMetadata("actualClassWithDefaultValuesInAnnotationViaTypealias.kt") + public void testActualClassWithDefaultValuesInAnnotationViaTypealias() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualClassWithDefaultValuesInAnnotationViaTypealias.kt"); + doTest(fileName); + } + + @TestMetadata("actualMissing.kt") + public void testActualMissing() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/actualMissing.kt"); + doTest(fileName); + } + public void testAllFilesPresentInHeaderClass() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/headerClass"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } @@ -13986,6 +13998,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing doTest(fileName); } + @TestMetadata("memberPropertyKinds.kt") + public void testMemberPropertyKinds() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/memberPropertyKinds.kt"); + doTest(fileName); + } + @TestMetadata("nestedClasses.kt") public void testNestedClasses() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/headerClass/nestedClasses.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/JavacForeignAnnotationsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/JavacForeignAnnotationsTestGenerated.java index 286b208e856..107975b9c13 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/JavacForeignAnnotationsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/JavacForeignAnnotationsTestGenerated.java @@ -60,21 +60,9 @@ public class JavacForeignAnnotationsTestGenerated extends AbstractJavacForeignAn doTest(fileName); } - @TestMetadata("jsr305NullabilityNicknames.kt") - public void testJsr305NullabilityNicknames() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityNicknames.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Simple.kt") - public void testJsr305Simple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305Simple.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Strange.kt") - public void testJsr305Strange() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305Strange.kt"); + @TestMetadata("irrelevantQualifierNicknames.kt") + public void testIrrelevantQualifierNicknames() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/irrelevantQualifierNicknames.kt"); doTest(fileName); } @@ -90,19 +78,328 @@ public class JavacForeignAnnotationsTestGenerated extends AbstractJavacForeignAn doTest(fileName); } - @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305Ignore") + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class Jsr305Ignore extends AbstractJavacForeignAnnotationsTest { - public void testAllFilesPresentInJsr305Ignore() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305Ignore"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + public static class Jsr305 extends AbstractJavacForeignAnnotationsTest { + public void testAllFilesPresentInJsr305() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("parametersAreNonnullByDefault.kt") - public void testParametersAreNonnullByDefault() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305Ignore/parametersAreNonnullByDefault.kt"); + @TestMetadata("nonNullNever.kt") + public void testNonNullNever() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nonNullNever.kt"); doTest(fileName); } + + @TestMetadata("nullabilityNicknames.kt") + public void testNullabilityNicknames() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityNicknames.kt"); + doTest(fileName); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/simple.kt"); + doTest(fileName); + } + + @TestMetadata("strange.kt") + public void testStrange() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/strange.kt"); + doTest(fileName); + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/ignore") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Ignore extends AbstractJavacForeignAnnotationsTest { + public void testAllFilesPresentInIgnore() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/ignore"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("parametersAreNonnullByDefault.kt") + public void testParametersAreNonnullByDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/ignore/parametersAreNonnullByDefault.kt"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullabilityWarnings extends AbstractJavacForeignAnnotationsTest { + public void testAllFilesPresentInNullabilityWarnings() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("nullabilityGenerics.kt") + public void testNullabilityGenerics() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityGenerics.kt"); + doTest(fileName); + } + + @TestMetadata("nullabilityNicknames.kt") + public void testNullabilityNicknames() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/nullabilityNicknames.kt"); + doTest(fileName); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/simple.kt"); + doTest(fileName); + } + + @TestMetadata("strange.kt") + public void testStrange() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/strange.kt"); + doTest(fileName); + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FromPlatformTypes extends AbstractJavacForeignAnnotationsTest { + public void testAllFilesPresentInFromPlatformTypes() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("arithmetic.kt") + public void testArithmetic() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.kt"); + doTest(fileName); + } + + @TestMetadata("array.kt") + public void testArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.kt"); + doTest(fileName); + } + + @TestMetadata("assignToVar.kt") + public void testAssignToVar() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.kt"); + doTest(fileName); + } + + @TestMetadata("conditions.kt") + public void testConditions() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/conditions.kt"); + doTest(fileName); + } + + @TestMetadata("dataFlowInfo.kt") + public void testDataFlowInfo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt"); + doTest(fileName); + } + + @TestMetadata("defaultParameters.kt") + public void testDefaultParameters() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.kt"); + doTest(fileName); + } + + @TestMetadata("delegatedProperties.kt") + public void testDelegatedProperties() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.kt"); + doTest(fileName); + } + + @TestMetadata("delegation.kt") + public void testDelegation() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegation.kt"); + doTest(fileName); + } + + @TestMetadata("derefenceExtension.kt") + public void testDerefenceExtension() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceExtension.kt"); + doTest(fileName); + } + + @TestMetadata("derefenceMember.kt") + public void testDerefenceMember() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceMember.kt"); + doTest(fileName); + } + + @TestMetadata("expectedType.kt") + public void testExpectedType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.kt"); + doTest(fileName); + } + + @TestMetadata("for.kt") + public void testFor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.kt"); + doTest(fileName); + } + + @TestMetadata("functionArguments.kt") + public void testFunctionArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.kt"); + doTest(fileName); + } + + @TestMetadata("invoke.kt") + public void testInvoke() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.kt"); + doTest(fileName); + } + + @TestMetadata("kt6829.kt") + public void testKt6829() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.kt"); + doTest(fileName); + } + + @TestMetadata("multiDeclaration.kt") + public void testMultiDeclaration() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/multiDeclaration.kt"); + doTest(fileName); + } + + @TestMetadata("passToJava.kt") + public void testPassToJava() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.kt"); + doTest(fileName); + } + + @TestMetadata("primitiveArray.kt") + public void testPrimitiveArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.kt"); + doTest(fileName); + } + + @TestMetadata("throw.kt") + public void testThrow() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.kt"); + doTest(fileName); + } + + @TestMetadata("uselessElvisRightIsNull.kt") + public void testUselessElvisRightIsNull() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeQualifierDefault extends AbstractJavacForeignAnnotationsTest { + public void testAllFilesPresentInTypeQualifierDefault() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("fieldsAreNullable.kt") + public void testFieldsAreNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt"); + doTest(fileName); + } + + @TestMetadata("nullabilityFromOverridden.kt") + public void testNullabilityFromOverridden() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt"); + doTest(fileName); + } + + @TestMetadata("overridingDefaultQualifier.kt") + public void testOverridingDefaultQualifier() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefault.kt") + public void testParametersAreNonnullByDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefaultPackage.kt") + public void testParametersAreNonnullByDefaultPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); + doTest(fileName); + } + + @TestMetadata("springNullable.kt") + public void testSpringNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullable.kt"); + doTest(fileName); + } + + @TestMetadata("springNullablePackage.kt") + public void testSpringNullablePackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullablePackage.kt"); + doTest(fileName); + } + } + } + + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeQualifierDefault extends AbstractJavacForeignAnnotationsTest { + public void testAllFilesPresentInTypeQualifierDefault() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("fieldsAreNullable.kt") + public void testFieldsAreNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/fieldsAreNullable.kt"); + doTest(fileName); + } + + @TestMetadata("forceFlexibility.kt") + public void testForceFlexibility() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibility.kt"); + doTest(fileName); + } + + @TestMetadata("forceFlexibleOverOverrides.kt") + public void testForceFlexibleOverOverrides() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/forceFlexibleOverOverrides.kt"); + doTest(fileName); + } + + @TestMetadata("nullabilityFromOverridden.kt") + public void testNullabilityFromOverridden() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/nullabilityFromOverridden.kt"); + doTest(fileName); + } + + @TestMetadata("overridingDefaultQualifier.kt") + public void testOverridingDefaultQualifier() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/overridingDefaultQualifier.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefault.kt") + public void testParametersAreNonnullByDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefault.kt"); + doTest(fileName); + } + + @TestMetadata("parametersAreNonnullByDefaultPackage.kt") + public void testParametersAreNonnullByDefaultPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); + doTest(fileName); + } + + @TestMetadata("springNullable.kt") + public void testSpringNullable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullable.kt"); + doTest(fileName); + } + + @TestMetadata("springNullablePackage.kt") + public void testSpringNullablePackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305/typeQualifierDefault/springNullablePackage.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings") @@ -113,206 +410,65 @@ public class JavacForeignAnnotationsTestGenerated extends AbstractJavacForeignAn KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("jsr305NullabilityGenerics.kt") - public void testJsr305NullabilityGenerics() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityGenerics.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305NullabilityNicknames.kt") - public void testJsr305NullabilityNicknames() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305NullabilityNicknames.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Simple.kt") - public void testJsr305Simple() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Simple.kt"); - doTest(fileName); - } - - @TestMetadata("jsr305Strange.kt") - public void testJsr305Strange() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/jsr305Strange.kt"); - doTest(fileName); - } - - @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes") + @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class FromPlatformTypes extends AbstractJavacForeignAnnotationsTest { - public void testAllFilesPresentInFromPlatformTypes() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + public static class Migration extends AbstractJavacForeignAnnotationsTest { + public void testAllFilesPresentInMigration() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("arithmetic.kt") - public void testArithmetic() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/arithmetic.kt"); + @TestMetadata("customMigration.kt") + public void testCustomMigration() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/customMigration.kt"); doTest(fileName); } - @TestMetadata("array.kt") - public void testArray() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/array.kt"); + @TestMetadata("globalIgnore.kt") + public void testGlobalIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalIgnore.kt"); doTest(fileName); } - @TestMetadata("assignToVar.kt") - public void testAssignToVar() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/assignToVar.kt"); + @TestMetadata("globalWarningMigrationIgnore.kt") + public void testGlobalWarningMigrationIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.kt"); doTest(fileName); } - @TestMetadata("conditions.kt") - public void testConditions() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/conditions.kt"); + @TestMetadata("migrationError.kt") + public void testMigrationError() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationError.kt"); doTest(fileName); } - @TestMetadata("dataFlowInfo.kt") - public void testDataFlowInfo() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt"); + @TestMetadata("migrationIgnore.kt") + public void testMigrationIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationIgnore.kt"); doTest(fileName); } - @TestMetadata("defaultParameters.kt") - public void testDefaultParameters() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/defaultParameters.kt"); + @TestMetadata("migrationWarning.kt") + public void testMigrationWarning() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/migrationWarning.kt"); doTest(fileName); } - @TestMetadata("delegatedProperties.kt") - public void testDelegatedProperties() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegatedProperties.kt"); + @TestMetadata("overrideConflicts.kt") + public void testOverrideConflicts() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/overrideConflicts.kt"); doTest(fileName); } - @TestMetadata("delegation.kt") - public void testDelegation() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/delegation.kt"); + @TestMetadata("specialCollision.kt") + public void testSpecialCollision() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/specialCollision.kt"); doTest(fileName); } - @TestMetadata("derefenceExtension.kt") - public void testDerefenceExtension() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceExtension.kt"); - doTest(fileName); - } - - @TestMetadata("derefenceMember.kt") - public void testDerefenceMember() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/derefenceMember.kt"); - doTest(fileName); - } - - @TestMetadata("expectedType.kt") - public void testExpectedType() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/expectedType.kt"); - doTest(fileName); - } - - @TestMetadata("for.kt") - public void testFor() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/for.kt"); - doTest(fileName); - } - - @TestMetadata("functionArguments.kt") - public void testFunctionArguments() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/functionArguments.kt"); - doTest(fileName); - } - - @TestMetadata("invoke.kt") - public void testInvoke() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/invoke.kt"); - doTest(fileName); - } - - @TestMetadata("kt6829.kt") - public void testKt6829() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/kt6829.kt"); - doTest(fileName); - } - - @TestMetadata("multiDeclaration.kt") - public void testMultiDeclaration() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/multiDeclaration.kt"); - doTest(fileName); - } - - @TestMetadata("passToJava.kt") - public void testPassToJava() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/passToJava.kt"); - doTest(fileName); - } - - @TestMetadata("primitiveArray.kt") - public void testPrimitiveArray() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/primitiveArray.kt"); - doTest(fileName); - } - - @TestMetadata("throw.kt") - public void testThrow() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/throw.kt"); - doTest(fileName); - } - - @TestMetadata("uselessElvisRightIsNull.kt") - public void testUselessElvisRightIsNull() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/fromPlatformTypes/uselessElvisRightIsNull.kt"); - doTest(fileName); - } - } - - @TestMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class TypeQualifierDefault extends AbstractJavacForeignAnnotationsTest { - public void testAllFilesPresentInTypeQualifierDefault() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); - } - - @TestMetadata("fieldsAreNullable.kt") - public void testFieldsAreNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt"); - doTest(fileName); - } - - @TestMetadata("nullabilityFromOverridden.kt") - public void testNullabilityFromOverridden() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.kt"); - doTest(fileName); - } - - @TestMetadata("overridingDefaultQualifier.kt") - public void testOverridingDefaultQualifier() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefault.kt") - public void testParametersAreNonnullByDefault() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefaultPackage.kt") - public void testParametersAreNonnullByDefaultPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); - doTest(fileName); - } - - @TestMetadata("springNullable.kt") - public void testSpringNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullable.kt"); - doTest(fileName); - } - - @TestMetadata("springNullablePackage.kt") - public void testSpringNullablePackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/typeQualifierDefault/springNullablePackage.kt"); + @TestMetadata("stateRefinement.kt") + public void testStateRefinement() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/jsr305NullabilityWarnings/migration/stateRefinement.kt"); doTest(fileName); } } @@ -326,45 +482,9 @@ public class JavacForeignAnnotationsTestGenerated extends AbstractJavacForeignAn KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotations/tests/typeQualifierDefault"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("fieldsAreNullable.kt") - public void testFieldsAreNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/fieldsAreNullable.kt"); - doTest(fileName); - } - - @TestMetadata("nullabilityFromOverridden.kt") - public void testNullabilityFromOverridden() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/nullabilityFromOverridden.kt"); - doTest(fileName); - } - - @TestMetadata("overridingDefaultQualifier.kt") - public void testOverridingDefaultQualifier() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/overridingDefaultQualifier.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefault.kt") - public void testParametersAreNonnullByDefault() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefault.kt"); - doTest(fileName); - } - - @TestMetadata("parametersAreNonnullByDefaultPackage.kt") - public void testParametersAreNonnullByDefaultPackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt"); - doTest(fileName); - } - - @TestMetadata("springNullable.kt") - public void testSpringNullable() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullable.kt"); - doTest(fileName); - } - - @TestMetadata("springNullablePackage.kt") - public void testSpringNullablePackage() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/springNullablePackage.kt"); + @TestMetadata("defaultAndNicknameMigrationPolicy.kt") + public void testDefaultAndNicknameMigrationPolicy() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.kt"); doTest(fileName); } } diff --git a/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java index 07a2786ecd3..f767e14809f 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java @@ -218,6 +218,18 @@ public class CliTestGenerated extends AbstractCliTest { doJvmTest(fileName); } + @TestMetadata("jsr305AllIgnore.args") + public void testJsr305AllIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305AllIgnore.args"); + doJvmTest(fileName); + } + + @TestMetadata("jsr305DefaultMigration.args") + public void testJsr305DefaultMigration() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305DefaultMigration.args"); + doJvmTest(fileName); + } + @TestMetadata("jsr305DeprecatedEnable.args") public void testJsr305DeprecatedEnable() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305DeprecatedEnable.args"); @@ -236,12 +248,48 @@ public class CliTestGenerated extends AbstractCliTest { doJvmTest(fileName); } + @TestMetadata("jsr305FqNameIgnore.args") + public void testJsr305FqNameIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305FqNameIgnore.args"); + doJvmTest(fileName); + } + + @TestMetadata("jsr305FqNameStrict.args") + public void testJsr305FqNameStrict() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305FqNameStrict.args"); + doJvmTest(fileName); + } + @TestMetadata("jsr305Ignore.args") public void testJsr305Ignore() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305Ignore.args"); doJvmTest(fileName); } + @TestMetadata("jsr305MigrationDefault.args") + public void testJsr305MigrationDefault() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305MigrationDefault.args"); + doJvmTest(fileName); + } + + @TestMetadata("jsr305MigrationFqNameIgnore.args") + public void testJsr305MigrationFqNameIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.args"); + doJvmTest(fileName); + } + + @TestMetadata("jsr305MigrationIgnore.args") + public void testJsr305MigrationIgnore() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305MigrationIgnore.args"); + doJvmTest(fileName); + } + + @TestMetadata("jsr305MigrationWarn.args") + public void testJsr305MigrationWarn() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305MigrationWarn.args"); + doJvmTest(fileName); + } + @TestMetadata("jsr305NoFlag.args") public void testJsr305NoFlag() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305NoFlag.args"); @@ -475,6 +523,12 @@ public class CliTestGenerated extends AbstractCliTest { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/wrongScriptWithNoSource.args"); doJvmTest(fileName); } + + @TestMetadata("wrongXjsr305.args") + public void testWrongXjsr305() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/wrongXjsr305.args"); + doJvmTest(fileName); + } } @TestMetadata("compiler/testData/cli/js") diff --git a/compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt b/compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt index 16018d5145c..1a1a46a7eeb 100644 --- a/compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt @@ -29,6 +29,9 @@ class CodeConformanceTest : TestCase() { private val EXCLUDED_FILES_AND_DIRS = listOf( "android.tests.dependencies", "core/reflection.jvm/src/kotlin/reflect/jvm/internal/pcollections", + "libraries/kotlin.test/js/it/.gradle", + "libraries/kotlin.test/js/it/node_modules", + "libraries/stdlib/js/node_modules", "libraries/tools/kotlin-reflect/build", "libraries/tools/kotlin-reflect/target/copied-sources", "libraries/tools/binary-compatibility-validator/src/main/kotlin/org.jetbrains.kotlin.tools", @@ -56,7 +59,10 @@ class CodeConformanceTest : TestCase() { "idea/src/org/jetbrains/kotlin/idea/copyright", "libraries/stdlib/common/build", "libraries/stdlib/common/target", - "libraries/stdlib/js/build" + "libraries/stdlib/js/build", + "libraries/kotlin.test/js/it/.gradle", + "libraries/kotlin.test/js/it/node_modules", + "libraries/stdlib/js/node_modules" ) } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 70dbdb452b6..7ad0b3590e2 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -4275,6 +4275,45 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @TestMetadata("compiler/testData/codegen/box/constructorCall") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConstructorCall extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInConstructorCall() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/constructorCall"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("inlineFunInConstructorCallEvaluationOrder.kt") + public void testInlineFunInConstructorCallEvaluationOrder() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/inlineFunInConstructorCallEvaluationOrder.kt"); + doTest(fileName); + } + + @TestMetadata("inlineFunInInnerClassConstructorCall.kt") + public void testInlineFunInInnerClassConstructorCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/inlineFunInInnerClassConstructorCall.kt"); + doTest(fileName); + } + + @TestMetadata("inlineFunInLocalClassConstructorCall.kt") + public void testInlineFunInLocalClassConstructorCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/inlineFunInLocalClassConstructorCall.kt"); + doTest(fileName); + } + + @TestMetadata("regularConstructorCallEvaluationOrder.kt") + public void testRegularConstructorCallEvaluationOrder() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/regularConstructorCallEvaluationOrder.kt"); + doTest(fileName); + } + + @TestMetadata("tryCatchInConstructorCallEvaluationOrder.kt") + public void testTryCatchInConstructorCallEvaluationOrder() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/tryCatchInConstructorCallEvaluationOrder.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/codegen/box/controlStructures") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -5749,6 +5788,30 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("inlineMultiModule.kt") + public void testInlineMultiModule() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModule.kt"); + doTest(fileName); + } + + @TestMetadata("inlineMultiModuleOverride.kt") + public void testInlineMultiModuleOverride() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleOverride.kt"); + try { + doTest(fileName); + } + catch (Throwable ignore) { + return; + } + throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + } + + @TestMetadata("inlineMultiModuleWithController.kt") + public void testInlineMultiModuleWithController() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithController.kt"); + doTest(fileName); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/simple.kt"); @@ -6440,6 +6503,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); } + @TestMetadata("inheritedFromInterfaceViaAbstractSuperclass.kt") + public void testInheritedFromInterfaceViaAbstractSuperclass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/inheritedFromInterfaceViaAbstractSuperclass.kt"); + doTest(fileName); + } + @TestMetadata("kt6382.kt") public void testKt6382() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/kt6382.kt"); @@ -6884,6 +6953,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); } + @TestMetadata("genericSetValueViaSyntheticAccessor.kt") + public void testGenericSetValueViaSyntheticAccessor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/genericSetValueViaSyntheticAccessor.kt"); + doTest(fileName); + } + @TestMetadata("getAsExtensionFun.kt") public void testGetAsExtensionFun() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/getAsExtensionFun.kt"); @@ -12155,6 +12230,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("kt20387.kt") + public void testKt20387() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt20387.kt"); + doTest(fileName); + } + @TestMetadata("kt4152.kt") public void testKt4152() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); @@ -13739,6 +13820,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt") + public void testForInRangeLiteralWithMixedTypeBounds() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt"); + doTest(fileName); + } + @TestMetadata("forInRangeToConstWithOverflow.kt") public void testForInRangeToConstWithOverflow() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInRangeToConstWithOverflow.kt"); @@ -18922,6 +19009,24 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class SyntheticAccessors extends AbstractBlackBoxCodegenTest { + @TestMetadata("accessorForGenericConstructor.kt") + public void testAccessorForGenericConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethod.kt") + public void testAccessorForGenericMethod() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethodWithDefaults.kt") + public void testAccessorForGenericMethodWithDefaults() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt"); + doTest(fileName); + } + @TestMetadata("accessorForProtected.kt") public void testAccessorForProtected() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForProtected.kt"); @@ -19643,6 +19748,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("doNotCopyImmediatelyCreatedArrays.kt") + public void testDoNotCopyImmediatelyCreatedArrays() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/vararg/doNotCopyImmediatelyCreatedArrays.kt"); + doTest(fileName); + } + @TestMetadata("kt1978.kt") public void testKt1978() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/vararg/kt1978.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index 73879200d6f..86d8f514ed4 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -2202,6 +2202,21 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { } } + @TestMetadata("compiler/testData/codegen/bytecodeText/varargs") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Varargs extends AbstractBytecodeTextTest { + public void testAllFilesPresentInVarargs() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText/varargs"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("doNotCopyImmediatelyCreatedArrays.kt") + public void testDoNotCopyImmediatelyCreatedArrays() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/varargs/doNotCopyImmediatelyCreatedArrays.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/codegen/bytecodeText/when") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CodegenJdkCommonTestSuite.kt b/compiler/tests/org/jetbrains/kotlin/codegen/CodegenJdkCommonTestSuite.kt deleted file mode 100644 index 4ac90f87d9d..00000000000 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CodegenJdkCommonTestSuite.kt +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.codegen - -import org.jetbrains.kotlin.test.clientserver.TestProcessServer -import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime -import org.junit.AfterClass -import org.junit.Assert.assertNotNull -import org.junit.BeforeClass -import org.junit.runner.RunWith -import org.junit.runners.Suite -import java.io.File - -/** - * This suite is used to run java codegen tests under jdk 1.6, 1.8 and 9 - * with different default targets - 1.6, 1.8, 1.9. - */ -@RunWith(Suite::class) -@Suite.SuiteClasses( - BlackBoxCodegenTestGenerated::class, - BlackBoxInlineCodegenTestGenerated::class, - CompileKotlinAgainstInlineKotlinTestGenerated::class, - CompileKotlinAgainstKotlinTestGenerated::class, - BlackBoxAgainstJavaCodegenTestGenerated::class -) -object CodegenJdkCommonTestSuite { - - private var jdkProcess: Process? = null - - @BeforeClass - @JvmStatic - fun setUp() { - val boxInSeparateProcessPort = System.getProperty(CodegenTestCase.RUN_BOX_TEST_IN_SEPARATE_PROCESS_PORT) - if (boxInSeparateProcessPort != null) { - val classpath = (System.getenv("TEST_SERVER_CLASSES_DIRS") ?: "out/test/tests-common") + - File.pathSeparatorChar + - ForTestCompileRuntime.runtimeJarForTests() + - File.pathSeparatorChar + - ForTestCompileRuntime.kotlinTestJarForTests() - - val jdk16 = System.getenv("JDK_16") - assertNotNull(jdk16, "Please specify JDK_16 system property to run codegen test in separate process") - - val builder = ProcessBuilder( - jdk16 + "/bin/java", "-cp", classpath, - TestProcessServer::class.java.name, boxInSeparateProcessPort - ) - println("Starting separate process to run test: " + builder.command().joinToString()) - builder.inheritIO() - builder.redirectErrorStream(true) - jdkProcess = builder.start() - } - } - - @AfterClass - @JvmStatic - fun tearDown() { - if (jdkProcess != null) { - println("Stop separate test process") - jdkProcess!!.destroy() - } - } -} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java index 73cf7c74e51..6ce011f1092 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java @@ -168,6 +168,12 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl doTest(fileName); } + @TestMetadata("multifileClassWithTypealias.kt") + public void testMultifileClassWithTypealias() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/multifileClassWithTypealias.kt"); + doTest(fileName); + } + @TestMetadata("nestedClass.kt") public void testNestedClass() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/nestedClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index fdbc08cca65..bcac1e48bcb 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -4275,6 +4275,45 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/constructorCall") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConstructorCall extends AbstractLightAnalysisModeTest { + public void testAllFilesPresentInConstructorCall() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/constructorCall"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("inlineFunInConstructorCallEvaluationOrder.kt") + public void testInlineFunInConstructorCallEvaluationOrder() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/inlineFunInConstructorCallEvaluationOrder.kt"); + doTest(fileName); + } + + @TestMetadata("inlineFunInInnerClassConstructorCall.kt") + public void testInlineFunInInnerClassConstructorCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/inlineFunInInnerClassConstructorCall.kt"); + doTest(fileName); + } + + @TestMetadata("inlineFunInLocalClassConstructorCall.kt") + public void testInlineFunInLocalClassConstructorCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/inlineFunInLocalClassConstructorCall.kt"); + doTest(fileName); + } + + @TestMetadata("regularConstructorCallEvaluationOrder.kt") + public void testRegularConstructorCallEvaluationOrder() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/regularConstructorCallEvaluationOrder.kt"); + doTest(fileName); + } + + @TestMetadata("tryCatchInConstructorCallEvaluationOrder.kt") + public void testTryCatchInConstructorCallEvaluationOrder() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/tryCatchInConstructorCallEvaluationOrder.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/codegen/box/controlStructures") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -5739,6 +5778,18 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class MultiModule extends AbstractLightAnalysisModeTest { + @TestMetadata("inlineMultiModuleOverride.kt") + public void ignoreInlineMultiModuleOverride() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleOverride.kt"); + try { + doTest(fileName); + } + catch (Throwable ignore) { + return; + } + throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + } + public void testAllFilesPresentInMultiModule() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/coroutines/multiModule"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } @@ -5749,6 +5800,18 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes doTest(fileName); } + @TestMetadata("inlineMultiModule.kt") + public void testInlineMultiModule() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModule.kt"); + doTest(fileName); + } + + @TestMetadata("inlineMultiModuleWithController.kt") + public void testInlineMultiModuleWithController() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithController.kt"); + doTest(fileName); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/simple.kt"); @@ -6440,6 +6503,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/defaultArguments"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } + @TestMetadata("inheritedFromInterfaceViaAbstractSuperclass.kt") + public void testInheritedFromInterfaceViaAbstractSuperclass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/inheritedFromInterfaceViaAbstractSuperclass.kt"); + doTest(fileName); + } + @TestMetadata("kt6382.kt") public void testKt6382() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/kt6382.kt"); @@ -6884,6 +6953,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes doTest(fileName); } + @TestMetadata("genericSetValueViaSyntheticAccessor.kt") + public void testGenericSetValueViaSyntheticAccessor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/genericSetValueViaSyntheticAccessor.kt"); + doTest(fileName); + } + @TestMetadata("getAsExtensionFun.kt") public void testGetAsExtensionFun() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/getAsExtensionFun.kt"); @@ -12155,6 +12230,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes doTest(fileName); } + @TestMetadata("kt20387.kt") + public void testKt20387() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt20387.kt"); + doTest(fileName); + } + @TestMetadata("kt4152.kt") public void testKt4152() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); @@ -13739,6 +13820,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes doTest(fileName); } + @TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt") + public void testForInRangeLiteralWithMixedTypeBounds() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt"); + doTest(fileName); + } + @TestMetadata("forInRangeToConstWithOverflow.kt") public void testForInRangeToConstWithOverflow() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInRangeToConstWithOverflow.kt"); @@ -18922,6 +19009,24 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class SyntheticAccessors extends AbstractLightAnalysisModeTest { + @TestMetadata("accessorForGenericConstructor.kt") + public void testAccessorForGenericConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethod.kt") + public void testAccessorForGenericMethod() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethodWithDefaults.kt") + public void testAccessorForGenericMethodWithDefaults() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt"); + doTest(fileName); + } + @TestMetadata("accessorForProtected.kt") public void testAccessorForProtected() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForProtected.kt"); @@ -19643,6 +19748,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes doTest(fileName); } + @TestMetadata("doNotCopyImmediatelyCreatedArrays.kt") + public void testDoNotCopyImmediatelyCreatedArrays() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/vararg/doNotCopyImmediatelyCreatedArrays.kt"); + doTest(fileName); + } + @TestMetadata("kt1978.kt") public void testKt1978() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/vararg/kt1978.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/TypeQualifierAnnotationResolverTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/TypeQualifierAnnotationResolverTest.kt index 90f47166f91..96533b34b09 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/TypeQualifierAnnotationResolverTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/TypeQualifierAnnotationResolverTest.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.config.* import org.jetbrains.kotlin.container.get import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.resolveClassByFqName import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.load.java.AnnotationTypeQualifierResolver @@ -128,7 +129,7 @@ class TypeQualifierAnnotationResolverTest : KtUsefulTestCase() { private fun ClassDescriptor.findSingleTypeQualifierAnnotationOnMethod( name: String, typeQualifierResolver: AnnotationTypeQualifierResolver - ) = unsubstitutedMemberScope + ): AnnotationDescriptor = unsubstitutedMemberScope .getContributedFunctions(Name.identifier(name), NoLookupLocation.FROM_TEST) .single() .annotations.single() diff --git a/compiler/tests/org/jetbrains/kotlin/multiplatform/AbstractMultiPlatformIntegrationTest.kt b/compiler/tests/org/jetbrains/kotlin/multiplatform/AbstractMultiPlatformIntegrationTest.kt index 8094f858cfd..14e3123c51a 100644 --- a/compiler/tests/org/jetbrains/kotlin/multiplatform/AbstractMultiPlatformIntegrationTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/multiplatform/AbstractMultiPlatformIntegrationTest.kt @@ -26,6 +26,9 @@ import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase import org.jetbrains.kotlin.test.util.trimTrailingWhitespacesAndAddNewlineAtEOF import java.io.File +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths abstract class AbstractMultiPlatformIntegrationTest : KtUsefulTestCase() { fun doTest(directoryPath: String) { @@ -38,6 +41,11 @@ abstract class AbstractMultiPlatformIntegrationTest : KtUsefulTestCase() { val tmpdir = KotlinTestUtils.tmpDir(getTestName(true)) + val optionalStdlibCommon = + if (InTextDirectivesUtils.isDirectiveDefined(commonSrc.readText(), "WITH_RUNTIME")) + arrayOf("-cp", findStdlibCommon().absolutePath) + else emptyArray() + val commonDest = File(tmpdir, "common").absolutePath val jvmDest = File(tmpdir, "jvm").absolutePath val jsDest = File(File(tmpdir, "js"), "output.js").absolutePath @@ -45,7 +53,7 @@ abstract class AbstractMultiPlatformIntegrationTest : KtUsefulTestCase() { val result = buildString { appendln("-- Common --") - appendln(K2MetadataCompiler().compile(listOf(commonSrc), "-d", commonDest)) + appendln(K2MetadataCompiler().compile(listOf(commonSrc), "-d", commonDest, *optionalStdlibCommon)) if (jvmSrc.exists()) { appendln() @@ -69,9 +77,24 @@ abstract class AbstractMultiPlatformIntegrationTest : KtUsefulTestCase() { KotlinTestUtils.assertEqualsToFile(File(root, "output.txt"), result.replace('\\', '/')) } + private fun findStdlibCommon(): File { + // Take kotlin-stdlib-common.jar from dist/ when it's there + val stdlibCommonLibsDir = "libraries/stdlib/common/build/libs" + val commonLibs = Files.newDirectoryStream(Paths.get(stdlibCommonLibsDir)).use(Iterable::toList) + return commonLibs.sorted().findLast { + val name = it.toFile().name + !name.endsWith("-javadoc.jar") && !name.endsWith("-sources.jar") + }?.toFile() ?: error("kotlin-stdlib-common is not found in $stdlibCommonLibsDir") + } + private fun CLICompiler<*>.compileBothWays(commonSource: File, platformSource: File, vararg mainArguments: String): String { - val platformFirst = compile(listOf(platformSource, commonSource), *mainArguments) - val commonFirst = compile(listOf(commonSource, platformSource), *mainArguments) + val configurations = listOf( + listOf(platformSource, commonSource), + listOf(commonSource, platformSource) + ) + + val (platformFirst, commonFirst) = configurations.map { compile(it, *mainArguments) } + if (platformFirst != commonFirst) { assertEquals( "Compilation results are different when compiling [platform-specific, common] compared to when compiling [common, platform-specific]", diff --git a/compiler/tests/org/jetbrains/kotlin/multiplatform/MultiPlatformIntegrationTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/multiplatform/MultiPlatformIntegrationTestGenerated.java index a7d2f06b80f..25207b58b49 100644 --- a/compiler/tests/org/jetbrains/kotlin/multiplatform/MultiPlatformIntegrationTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/multiplatform/MultiPlatformIntegrationTestGenerated.java @@ -102,6 +102,12 @@ public class MultiPlatformIntegrationTestGenerated extends AbstractMultiPlatform doTest(fileName); } + @TestMetadata("jvmMultifileClass") + public void testJvmMultifileClass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/jvmMultifileClass/"); + doTest(fileName); + } + @TestMetadata("missingOverload") public void testMissingOverload() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/missingOverload/"); diff --git a/compiler/tests/org/jetbrains/kotlin/test/util/TestExecutedOnlyOnceTest.java b/compiler/tests/org/jetbrains/kotlin/test/util/TestExecutedOnlyOnceTest.java index c3729cb2d04..94c174b28d4 100644 --- a/compiler/tests/org/jetbrains/kotlin/test/util/TestExecutedOnlyOnceTest.java +++ b/compiler/tests/org/jetbrains/kotlin/test/util/TestExecutedOnlyOnceTest.java @@ -30,6 +30,7 @@ public class TestExecutedOnlyOnceTest extends TestCase { testA = true; } + @RunWith(JUnit3RunnerWithInners.class) public static class InnerTest extends TestCase { private static boolean testB; private static boolean testC; @@ -44,8 +45,10 @@ public class TestExecutedOnlyOnceTest extends TestCase { testC = true; } + @RunWith(JUnit3RunnerWithInners.class) public static class InnerInnerTest extends TestCase { + @RunWith(JUnit3RunnerWithInners.class) public static class InnerInnerInnerTest extends TestCase { private static boolean testD; private static boolean testE; diff --git a/core/builtins/src/kotlin/annotation/Annotations.kt b/core/builtins/src/kotlin/annotation/Annotations.kt index e466d0d198b..d6857da1fb7 100644 --- a/core/builtins/src/kotlin/annotation/Annotations.kt +++ b/core/builtins/src/kotlin/annotation/Annotations.kt @@ -98,4 +98,4 @@ public annotation class Repeatable * documentation for the element to which the annotation is applied. */ @Target(AnnotationTarget.ANNOTATION_CLASS) -public annotation class MustBeDocumented \ No newline at end of file +public annotation class MustBeDocumented diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/AnnotationTypeQualifierResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/AnnotationTypeQualifierResolver.kt index 2bc0f256b7d..04d32d21dc3 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/AnnotationTypeQualifierResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/AnnotationTypeQualifierResolver.kt @@ -19,21 +19,42 @@ package org.jetbrains.kotlin.load.java import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.kotlin.load.java.lazy.NullabilityQualifierWithApplicability +import org.jetbrains.kotlin.load.java.typeEnhancement.NullabilityQualifier +import org.jetbrains.kotlin.load.java.typeEnhancement.NullabilityQualifierWithMigrationStatus import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.constants.ArrayValue import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.resolve.constants.EnumValue import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass +import org.jetbrains.kotlin.resolve.descriptorUtil.firstArgumentValue import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.utils.Jsr305State +import org.jetbrains.kotlin.utils.ReportLevel import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult +import org.jetbrains.kotlin.utils.addToStdlib.safeAs private val TYPE_QUALIFIER_NICKNAME_FQNAME = FqName("javax.annotation.meta.TypeQualifierNickname") private val TYPE_QUALIFIER_FQNAME = FqName("javax.annotation.meta.TypeQualifier") private val TYPE_QUALIFIER_DEFAULT_FQNAME = FqName("javax.annotation.meta.TypeQualifierDefault") -class AnnotationTypeQualifierResolver(storageManager: StorageManager, val jsr305State: Jsr305State) { +private val MIGRATION_ANNOTATION_FQNAME = FqName("kotlin.annotations.jvm.UnderMigration") + +private val BUILT_IN_TYPE_QUALIFIER_DEFAULT_ANNOTATIONS = mapOf( + FqName("javax.annotation.ParametersAreNullableByDefault") to + NullabilityQualifierWithApplicability( + NullabilityQualifierWithMigrationStatus(NullabilityQualifier.NULLABLE), + listOf(AnnotationTypeQualifierResolver.QualifierApplicabilityType.VALUE_PARAMETER) + ), + FqName("javax.annotation.ParametersAreNonnullByDefault") to + NullabilityQualifierWithApplicability( + NullabilityQualifierWithMigrationStatus(NullabilityQualifier.NOT_NULL), + listOf(AnnotationTypeQualifierResolver.QualifierApplicabilityType.VALUE_PARAMETER) + ) +) + +class AnnotationTypeQualifierResolver(storageManager: StorageManager, private val jsr305State: Jsr305State) { enum class QualifierApplicabilityType { METHOD_RETURN_TYPE, VALUE_PARAMETER, FIELD, TYPE_USE } @@ -42,10 +63,14 @@ class AnnotationTypeQualifierResolver(storageManager: StorageManager, val jsr305 private val typeQualifier: AnnotationDescriptor, private val applicability: Int ) { - private fun isApplicableTo(elementType: QualifierApplicabilityType) = (applicability and (1 shl elementType.ordinal)) != 0 - operator fun component1() = typeQualifier operator fun component2() = QualifierApplicabilityType.values().filter(this::isApplicableTo) + + private fun isApplicableTo(elementType: QualifierApplicabilityType) = + isApplicableConsideringMask(QualifierApplicabilityType.TYPE_USE) || isApplicableConsideringMask(elementType) + + private fun isApplicableConsideringMask(elementType: QualifierApplicabilityType) = + (applicability and (1 shl elementType.ordinal)) != 0 } private val resolvedNicknames = @@ -64,7 +89,7 @@ class AnnotationTypeQualifierResolver(storageManager: StorageManager, val jsr305 } fun resolveTypeQualifierAnnotation(annotationDescriptor: AnnotationDescriptor): AnnotationDescriptor? { - if (jsr305State.isIgnored()) { + if (jsr305State.disabled) { return null } @@ -74,8 +99,19 @@ class AnnotationTypeQualifierResolver(storageManager: StorageManager, val jsr305 return resolveTypeQualifierNickname(annotationClass) } + fun resolveQualifierBuiltInDefaultAnnotation(annotationDescriptor: AnnotationDescriptor): NullabilityQualifierWithApplicability? { + if (jsr305State.disabled) { + return null + } + + return BUILT_IN_TYPE_QUALIFIER_DEFAULT_ANNOTATIONS[annotationDescriptor.fqName]?.let { (qualifier, applicability) -> + val state = resolveJsr305AnnotationState(annotationDescriptor).takeIf { it != ReportLevel.IGNORE } ?: return null + return NullabilityQualifierWithApplicability(qualifier.copy(isForWarningOnly = state.isWarning), applicability) + } + } + fun resolveTypeQualifierDefaultAnnotation(annotationDescriptor: AnnotationDescriptor): TypeQualifierWithApplicability? { - if (jsr305State.isIgnored()) { + if (jsr305State.disabled) { return null } @@ -95,12 +131,36 @@ class AnnotationTypeQualifierResolver(storageManager: StorageManager, val jsr305 } .fold(0) { acc: Int, applicabilityType -> acc or (1 shl applicabilityType.ordinal) } - val typeQualifier = - typeQualifierDefaultAnnotatedClass.annotations.firstNotNullResult(this::resolveTypeQualifierAnnotation) - ?: return null + val typeQualifier = typeQualifierDefaultAnnotatedClass.annotations.firstOrNull { resolveTypeQualifierAnnotation(it) != null } + ?: return null + return TypeQualifierWithApplicability(typeQualifier, elementTypesMask) } + fun resolveJsr305AnnotationState(annotationDescriptor: AnnotationDescriptor): ReportLevel { + resolveJsr305CustomState(annotationDescriptor)?.let { return it } + return jsr305State.global + } + + fun resolveJsr305CustomState(annotationDescriptor: AnnotationDescriptor): ReportLevel? { + jsr305State.user[annotationDescriptor.fqName?.asString()]?.let { return it } + return annotationDescriptor.annotationClass?.migrationAnnotationStatus() + } + + private fun ClassDescriptor.migrationAnnotationStatus(): ReportLevel? { + val stateDescriptor = annotations.findAnnotation(MIGRATION_ANNOTATION_FQNAME)?.firstArgumentValue()?.safeAs() + ?: return null + + jsr305State.migration?.let { return jsr305State.migration } + + return when (stateDescriptor.name.asString()) { + "STRICT" -> ReportLevel.STRICT + "WARN" -> ReportLevel.WARN + "IGNORE" -> ReportLevel.IGNORE + else -> null + } + } + private fun ConstantValue<*>.mapConstantToQualifierApplicabilityTypes(): List = when (this) { is ArrayValue -> value.flatMap { it.mapConstantToQualifierApplicabilityTypes() } @@ -115,6 +175,8 @@ class AnnotationTypeQualifierResolver(storageManager: StorageManager, val jsr305 ) else -> emptyList() } + + val disabled: Boolean = jsr305State.disabled } val BUILT_IN_TYPE_QUALIFIER_FQ_NAMES = setOf(JAVAX_NONNULL_ANNOTATION, JAVAX_CHECKFORNULL_ANNOTATION) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/context.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/context.kt index abd15ad56ee..14d3cf5127b 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/context.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/context.kt @@ -28,14 +28,13 @@ import org.jetbrains.kotlin.load.java.lazy.types.JavaTypeResolver import org.jetbrains.kotlin.load.java.sources.JavaSourceElementFactory import org.jetbrains.kotlin.load.java.structure.JavaTypeParameterListOwner import org.jetbrains.kotlin.load.java.typeEnhancement.JavaTypeQualifiers -import org.jetbrains.kotlin.load.java.typeEnhancement.NullabilityQualifier import org.jetbrains.kotlin.load.java.typeEnhancement.NullabilityQualifierWithMigrationStatus import org.jetbrains.kotlin.load.java.typeEnhancement.SignatureEnhancement import org.jetbrains.kotlin.load.kotlin.DeserializedDescriptorResolver import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter import org.jetbrains.kotlin.storage.StorageManager +import org.jetbrains.kotlin.utils.ReportLevel import java.util.* class JavaResolverComponents( @@ -76,12 +75,16 @@ class JavaTypeQualifiersByElementType( internal val nullabilityQualifiers: QualifierByApplicabilityType ) { operator fun get( - applicabilityType: AnnotationTypeQualifierResolver.QualifierApplicabilityType - ): JavaTypeQualifiers? = - ( - nullabilityQualifiers[applicabilityType] - ?: nullabilityQualifiers[AnnotationTypeQualifierResolver.QualifierApplicabilityType.TYPE_USE] - )?.let { JavaTypeQualifiers(it.qualifier, null, isNotNullTypeParameter = false, isNullabilityQualifierForWarning = it.isForWarningOnly) } + applicabilityType: AnnotationTypeQualifierResolver.QualifierApplicabilityType? + ): JavaTypeQualifiers? { + val nullabilityQualifierWithMigrationStatus = nullabilityQualifiers[applicabilityType] ?: return null + + return JavaTypeQualifiers( + nullabilityQualifierWithMigrationStatus.qualifier, null, + isNotNullTypeParameter = false, + isNullabilityQualifierForWarning = nullabilityQualifierWithMigrationStatus.isForWarningOnly + ) + } } class LazyJavaResolverContext internal constructor( @@ -112,7 +115,7 @@ fun LazyJavaResolverContext.child( fun LazyJavaResolverContext.computeNewDefaultTypeQualifiers( additionalAnnotations: Annotations ): JavaTypeQualifiersByElementType? { - if (components.annotationTypeQualifierResolver.jsr305State.isIgnored()) return defaultTypeQualifiers + if (components.annotationTypeQualifierResolver.disabled) return defaultTypeQualifiers val nullabilityQualifiersWithApplicability = additionalAnnotations.mapNotNull(this::extractDefaultNullabilityQualifier) @@ -124,10 +127,9 @@ fun LazyJavaResolverContext.computeNewDefaultTypeQualifiers( ?: QualifierByApplicabilityType(AnnotationTypeQualifierResolver.QualifierApplicabilityType::class.java) var wasUpdate = false - val isForWarning = components.annotationTypeQualifierResolver.jsr305State.isWarning() for ((nullability, applicableTo) in nullabilityQualifiersWithApplicability) { for (applicabilityType in applicableTo) { - nullabilityQualifiersByType[applicabilityType] = NullabilityQualifierWithMigrationStatus(nullability, isForWarning) + nullabilityQualifiersByType[applicabilityType] = nullability wasUpdate = true } } @@ -138,35 +140,35 @@ fun LazyJavaResolverContext.computeNewDefaultTypeQualifiers( private fun LazyJavaResolverContext.extractDefaultNullabilityQualifier( annotationDescriptor: AnnotationDescriptor ): NullabilityQualifierWithApplicability? { - BUILT_IN_TYPE_QUALIFIER_DEFAULT_ANNOTATIONS[annotationDescriptor.fqName]?.let { return it } + val typeQualifierResolver = components.annotationTypeQualifierResolver + typeQualifierResolver.resolveQualifierBuiltInDefaultAnnotation(annotationDescriptor)?.let { return it } val (typeQualifier, applicability) = - components.annotationTypeQualifierResolver.resolveTypeQualifierDefaultAnnotation(annotationDescriptor) + typeQualifierResolver.resolveTypeQualifierDefaultAnnotation(annotationDescriptor) ?: return null - val nullabilityQualifier = components.signatureEnhancement.extractNullability(typeQualifier)?.qualifier ?: return null + val jsr305State = typeQualifierResolver.resolveJsr305CustomState(annotationDescriptor) + ?: typeQualifierResolver.resolveJsr305AnnotationState(typeQualifier) + + if (jsr305State.isIgnore) { + return null + } + + val nullabilityQualifier = + components + .signatureEnhancement + .extractNullability(typeQualifier) + ?.copy(isForWarningOnly = jsr305State.isWarning) + ?: return null return NullabilityQualifierWithApplicability(nullabilityQualifier, applicability) } data class NullabilityQualifierWithApplicability( - val nullabilityQualifier: NullabilityQualifier, + val nullabilityQualifier: NullabilityQualifierWithMigrationStatus, val qualifierApplicabilityTypes: Collection ) -private val BUILT_IN_TYPE_QUALIFIER_DEFAULT_ANNOTATIONS = mapOf( - FqName("javax.annotation.ParametersAreNullableByDefault") to - NullabilityQualifierWithApplicability( - NullabilityQualifier.NULLABLE, - listOf(AnnotationTypeQualifierResolver.QualifierApplicabilityType.VALUE_PARAMETER) - ), - FqName("javax.annotation.ParametersAreNonnullByDefault") to - NullabilityQualifierWithApplicability( - NullabilityQualifier.NOT_NULL, - listOf(AnnotationTypeQualifierResolver.QualifierApplicabilityType.VALUE_PARAMETER) - ) -) - fun LazyJavaResolverContext.replaceComponents( components: JavaResolverComponents ) = LazyJavaResolverContext(components, typeParameterResolver, delegateForDefaultTypeQualifiers) @@ -197,3 +199,13 @@ fun LazyJavaResolverContext.childForClassOrPackage( containingDeclaration, typeParameterOwner, typeParametersIndexOffset, lazy(LazyThreadSafetyMode.NONE) { computeNewDefaultTypeQualifiers(containingDeclaration.annotations) } ) + +fun LazyJavaResolverContext.copyWithNewDefaultTypeQualifiers( + additionalAnnotations: Annotations +) = if (additionalAnnotations.isEmpty()) + this + else + LazyJavaResolverContext( + components, typeParameterResolver, + lazy(LazyThreadSafetyMode.NONE) { computeNewDefaultTypeQualifiers(additionalAnnotations) } + ) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/JvmPackageScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/JvmPackageScope.kt index 957ccb8a000..2e852f7c490 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/JvmPackageScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/JvmPackageScope.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.load.java.structure.JavaPackage import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.MemberScope +import org.jetbrains.kotlin.resolve.scopes.flatMapClassifierNamesOrNull import org.jetbrains.kotlin.storage.getValue import org.jetbrains.kotlin.util.collectionUtils.getFirstClassifierDiscriminateHeaders import org.jetbrains.kotlin.util.collectionUtils.getFromAllScopes @@ -46,7 +47,7 @@ class JvmPackageScope( } override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { - recordLookup(location, name) + recordLookup(name, location) val javaClassifier = javaScope.getContributedClassifier(name, location) if (javaClassifier != null) return javaClassifier @@ -55,12 +56,12 @@ class JvmPackageScope( } override fun getContributedVariables(name: Name, location: LookupLocation): Collection { - recordLookup(location, name) + recordLookup(name, location) return getFromAllScopes(javaScope, kotlinScopes) { it.getContributedVariables(name, location) } } override fun getContributedFunctions(name: Name, location: LookupLocation): Collection { - recordLookup(location, name) + recordLookup(name, location) return getFromAllScopes(javaScope, kotlinScopes) { it.getContributedFunctions(name, location) } } @@ -76,6 +77,10 @@ class JvmPackageScope( addAll(javaScope.getVariableNames()) } + override fun getClassifierNames(): Set? = kotlinScopes.flatMapClassifierNamesOrNull()?.apply { + addAll(javaScope.getClassifierNames()) + } + override fun printScopeStructure(p: Printer) { p.println(this::class.java.simpleName, " {") p.pushIndent() @@ -91,7 +96,7 @@ class JvmPackageScope( p.println("}") } - private fun recordLookup(location: LookupLocation, name: Name) { + override fun recordLookup(name: Name, location: LookupLocation) { c.components.lookupTracker.record(location, packageFragment, name) } } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index b5c8efd79b7..a6de88b03b4 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -672,8 +672,8 @@ class LazyJavaClassMemberScope( } } - private fun recordLookup(name: Name, from: LookupLocation) { - c.components.lookupTracker.record(from, ownerDescriptor, name) + override fun recordLookup(name: Name, location: LookupLocation) { + c.components.lookupTracker.record(location, ownerDescriptor, name) } override fun toString() = "Lazy Java member scope for " + jClass.fqName diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageFragment.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageFragment.kt index cca0e342fe7..d62b2dfb8c4 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageFragment.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaPackageFragment.kt @@ -55,7 +55,7 @@ class LazyJavaPackageFragment( override val annotations = // Do not resolve package annotations if JSR-305 is disabled - if (c.components.annotationTypeQualifierResolver.jsr305State.isIgnored()) Annotations.EMPTY + if (c.components.annotationTypeQualifierResolver.disabled) Annotations.EMPTY else c.resolveAnnotations(jPackage) internal fun getSubPackageFqNames(): List = subPackages() diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt index 23a40fca777..4b3633aa5d1 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt @@ -212,9 +212,15 @@ abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : MemberS private val functionNamesLazy by c.storageManager.createLazyValue { computeFunctionNames(DescriptorKindFilter.FUNCTIONS, null) } private val propertyNamesLazy by c.storageManager.createLazyValue { computePropertyNames(DescriptorKindFilter.VARIABLES, null) } + private val classNamesLazy by c.storageManager.createLazyValue { computeClassNames(DescriptorKindFilter.CLASSIFIERS, null) } override fun getFunctionNames() = functionNamesLazy override fun getVariableNames() = propertyNamesLazy + override fun getClassifierNames() = classNamesLazy + + override fun definitelyDoesNotContainName(name: Name): Boolean { + return name !in functionNamesLazy && name !in propertyNamesLazy && name !in classNamesLazy + } override fun getContributedFunctions(name: Name, location: LookupLocation): Collection { if (name !in getFunctionNames()) return emptyList() diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhancement/signatureEnhancement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhancement/signatureEnhancement.kt index ca0f5328cc0..d822949db78 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhancement/signatureEnhancement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhancement/signatureEnhancement.kt @@ -16,10 +16,7 @@ package org.jetbrains.kotlin.load.java.typeEnhancement -import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.descriptors.PropertyDescriptor +import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotated import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations @@ -29,7 +26,7 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext -import org.jetbrains.kotlin.load.java.lazy.computeNewDefaultTypeQualifiers +import org.jetbrains.kotlin.load.java.lazy.copyWithNewDefaultTypeQualifiers import org.jetbrains.kotlin.load.java.lazy.descriptors.isJavaField import org.jetbrains.kotlin.load.kotlin.SignatureBuildingComponents import org.jetbrains.kotlin.load.kotlin.computeJvmDescriptor @@ -55,40 +52,45 @@ class SignatureEnhancement(private val annotationTypeQualifierResolver: Annotati private fun AnnotationDescriptor.extractNullabilityTypeFromArgument(): NullabilityQualifierWithMigrationStatus? { val enumEntryDescriptor = firstArgumentValue() - // if no argument is specified, use default value: NOT_NULL - ?: return NullabilityQualifierWithMigrationStatus(NullabilityQualifier.NOT_NULL) + // if no argument is specified, use default value: NOT_NULL + ?: return NullabilityQualifierWithMigrationStatus(NullabilityQualifier.NOT_NULL) if (enumEntryDescriptor !is ClassDescriptor) return null return when (enumEntryDescriptor.name.asString()) { "ALWAYS" -> NullabilityQualifierWithMigrationStatus(NullabilityQualifier.NOT_NULL) - "MAYBE" -> NullabilityQualifierWithMigrationStatus(NullabilityQualifier.NULLABLE) + "MAYBE", "NEVER" -> NullabilityQualifierWithMigrationStatus(NullabilityQualifier.NULLABLE) + "UNKNOWN" -> NullabilityQualifierWithMigrationStatus(NullabilityQualifier.FORCE_FLEXIBILITY) else -> null } } fun extractNullability(annotationDescriptor: AnnotationDescriptor): NullabilityQualifierWithMigrationStatus? { + extractNullabilityFromKnownAnnotations(annotationDescriptor)?.let { return it } + + val typeQualifierAnnotation = + annotationTypeQualifierResolver.resolveTypeQualifierAnnotation(annotationDescriptor) + ?: return null + + val jsr305State = annotationTypeQualifierResolver.resolveJsr305AnnotationState(annotationDescriptor) + if (jsr305State.isIgnore) return null + + return extractNullabilityFromKnownAnnotations(typeQualifierAnnotation)?.copy(isForWarningOnly = jsr305State.isWarning) + } + + private fun extractNullabilityFromKnownAnnotations( + annotationDescriptor: AnnotationDescriptor + ): NullabilityQualifierWithMigrationStatus? { val annotationFqName = annotationDescriptor.fqName ?: return null return when (annotationFqName) { in NULLABLE_ANNOTATIONS -> NullabilityQualifierWithMigrationStatus(NullabilityQualifier.NULLABLE) in NOT_NULL_ANNOTATIONS -> NullabilityQualifierWithMigrationStatus(NullabilityQualifier.NOT_NULL) JAVAX_NONNULL_ANNOTATION -> annotationDescriptor.extractNullabilityTypeFromArgument() - else -> { - val forWarning = annotationTypeQualifierResolver.jsr305State.isWarning() - - val typeQualifierAnnotation = - annotationTypeQualifierResolver.resolveTypeQualifierAnnotation(annotationDescriptor) - ?: return null - - // resolveTypeQualifierAnnotation guarantees that `typeQualifierAnnotation` is javax.annotation.NonNull with argument - // or javax.annotation.CheckForNull without arguments - extractNullability(typeQualifierAnnotation)?.copy(isForWarningOnly = forWarning) - } + else -> null } } - fun enhanceSignatures(c: LazyJavaResolverContext, platformSignatures: Collection): Collection { return platformSignatures.map { it.enhanceSignature(c) @@ -105,7 +107,7 @@ class SignatureEnhancement(private val annotationTypeQualifierResolver: Annotati // Fake overrides with one overridden has been enhanced before if (kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE && original.overriddenDescriptors.size == 1) return this - val outerScopeQualifiers = c.computeNewDefaultTypeQualifiers(annotations) + val memberContext = c.copyWithNewDefaultTypeQualifiers(annotations) // When loading method as an override for a property, all annotations are stick to its getter val annotationOwnerForMember = @@ -116,14 +118,11 @@ class SignatureEnhancement(private val annotationTypeQualifierResolver: Annotati val receiverTypeEnhancement = if (extensionReceiverParameter != null) - parts( - typeContainer = - annotationOwnerForMember.safeAs() + partsForValueParameter( + parameterDescriptor = + annotationOwnerForMember.safeAs() ?.getUserData(JavaMethodDescriptor.ORIGINAL_VALUE_PARAMETER_FOR_EXTENSION_RECEIVER), - isCovariant = false, - defaultTopLevelQualifiers = - outerScopeQualifiers - ?.get(AnnotationTypeQualifierResolver.QualifierApplicabilityType.VALUE_PARAMETER) + methodContext = memberContext ) { it.extensionReceiverParameter!!.type }.enhance() else null @@ -140,29 +139,20 @@ class SignatureEnhancement(private val annotationTypeQualifierResolver: Annotati } } - val valueParameterEnhancements = annotationOwnerForMember.valueParameters.map { - p -> - parts( - typeContainer = p, isCovariant = false, - defaultTopLevelQualifiers = - outerScopeQualifiers - ?.get(AnnotationTypeQualifierResolver.QualifierApplicabilityType.VALUE_PARAMETER) - ) { it.valueParameters[p.index].type } + val valueParameterEnhancements = annotationOwnerForMember.valueParameters.map { p -> + partsForValueParameter(p, memberContext) { it.valueParameters[p.index].type } .enhance(predefinedEnhancementInfo?.parametersInfo?.getOrNull(p.index)) } val returnTypeEnhancement = parts( typeContainer = annotationOwnerForMember, isCovariant = true, - defaultTopLevelQualifiers = - outerScopeQualifiers?.get( - if (this.safeAs()?.isJavaField == true) - AnnotationTypeQualifierResolver.QualifierApplicabilityType.FIELD - else - AnnotationTypeQualifierResolver.QualifierApplicabilityType.METHOD_RETURN_TYPE - ) - - + containerContext = memberContext, + containerApplicabilityType = + if (this.safeAs()?.isJavaField == true) + AnnotationTypeQualifierResolver.QualifierApplicabilityType.FIELD + else + AnnotationTypeQualifierResolver.QualifierApplicabilityType.METHOD_RETURN_TYPE ) { it.returnType!! }.enhance(predefinedEnhancementInfo?.returnTypeInfo) if ((receiverTypeEnhancement?.wereChanges ?: false) @@ -179,20 +169,19 @@ class SignatureEnhancement(private val annotationTypeQualifierResolver: Annotati private val fromOverride: KotlinType, private val fromOverridden: Collection, private val isCovariant: Boolean, - private val defaultTopLevelQualifiers: JavaTypeQualifiers? + private val containerContext: LazyJavaResolverContext, + private val containerApplicabilityType: AnnotationTypeQualifierResolver.QualifierApplicabilityType ) { fun enhance(predefined: TypeEnhancementInfo? = null): PartEnhancementResult { val qualifiers = computeIndexedQualifiersForOverride() val qualifiersWithPredefined: ((Int) -> JavaTypeQualifiers)? = predefined?.let { - { - index -> + { index -> predefined.map[index] ?: qualifiers(index) } } - return fromOverride.enhance(qualifiersWithPredefined ?: qualifiers)?.let { - enhanced -> + return fromOverride.enhance(qualifiersWithPredefined ?: qualifiers)?.let { enhanced -> PartEnhancementResult(enhanced, wereChanges = true) } ?: PartEnhancementResult(fromOverride, wereChanges = false) } @@ -218,19 +207,27 @@ class SignatureEnhancement(private val annotationTypeQualifierResolver: Annotati isNotNullTypeParameter = unwrap() is NotNullTypeParameter) } - private fun KotlinType.extractQualifiersFromAnnotations(isHeadTypeConstructor: Boolean): JavaTypeQualifiers { + private fun KotlinType.extractQualifiersFromAnnotations( + isHeadTypeConstructor: Boolean, + defaultQualifiersForType: JavaTypeQualifiers? + ): JavaTypeQualifiers { val composedAnnotation = if (isHeadTypeConstructor && typeContainer != null) composeAnnotations(typeContainer.annotations, annotations) else annotations - fun List.ifPresent(qualifier: T) = + fun List.ifPresent(qualifier: T) = if (any { composedAnnotation.findAnnotation(it) != null }) qualifier else null - fun uniqueNotNull(x: T?, y: T?) = if (x == null || y == null || x == y) x ?: y else null + fun uniqueNotNull(x: T?, y: T?) = if (x == null || y == null || x == y) x ?: y else null + + val defaultTypeQualifier = + if (isHeadTypeConstructor) + containerContext.defaultTypeQualifiers?.get(containerApplicabilityType) + else + defaultQualifiersForType - val defaultTypeQualifier = defaultTopLevelQualifiers?.takeIf { isHeadTypeConstructor } val nullabilityInfo = composedAnnotation.extractNullability() ?: defaultTypeQualifier?.nullability?.let { @@ -259,24 +256,6 @@ class SignatureEnhancement(private val annotationTypeQualifierResolver: Annotati this.firstNotNullResult(this@SignatureEnhancement::extractNullability) private fun computeIndexedQualifiersForOverride(): (Int) -> JavaTypeQualifiers { - fun KotlinType.toIndexed(): List { - val list = ArrayList(1) - - fun add(type: KotlinType) { - list.add(type) - for (arg in type.arguments) { - if (arg.isStarProjection) { - list.add(arg.type) - } - else { - add(arg.type) - } - } - } - - add(this) - return list - } val indexedFromSupertypes = fromOverridden.map { it.toIndexed() } val indexedThisType = fromOverride.toIndexed() @@ -289,23 +268,53 @@ class SignatureEnhancement(private val annotationTypeQualifierResolver: Annotati val onlyHeadTypeConstructor = isCovariant && fromOverridden.any { !KotlinTypeChecker.DEFAULT.equalTypes(it, fromOverride) } val treeSize = if (onlyHeadTypeConstructor) 1 else indexedThisType.size - val computedResult = Array(treeSize) { - index -> + val computedResult = Array(treeSize) { index -> val isHeadTypeConstructor = index == 0 assert(isHeadTypeConstructor || !onlyHeadTypeConstructor) { "Only head type constructors should be computed" } - val qualifiers = indexedThisType[index] - val verticalSlice = indexedFromSupertypes.mapNotNull { it.getOrNull(index) } + val (qualifiers, defaultQualifiers) = indexedThisType[index] + val verticalSlice = indexedFromSupertypes.mapNotNull { it.getOrNull(index)?.type } // Only the head type constructor is safely co-variant - qualifiers.computeQualifiersForOverride(verticalSlice, isCovariant && isHeadTypeConstructor, isHeadTypeConstructor) + qualifiers.computeQualifiersForOverride(verticalSlice, defaultQualifiers, isHeadTypeConstructor) } return { index -> computedResult.getOrElse(index) { JavaTypeQualifiers.NONE } } } + + private fun KotlinType.toIndexed(): List { + val list = ArrayList(1) + + fun add(type: KotlinType, ownerContext: LazyJavaResolverContext) { + val c = ownerContext.copyWithNewDefaultTypeQualifiers(type.annotations) + + list.add( + TypeAndDefaultQualifiers( + type, + c.defaultTypeQualifiers + ?.get(AnnotationTypeQualifierResolver.QualifierApplicabilityType.TYPE_USE) + ) + ) + + for (arg in type.arguments) { + if (arg.isStarProjection) { + // TODO: sort out how to handle wildcards + list.add(TypeAndDefaultQualifiers(arg.type, null)) + } + else { + add(arg.type, c) + } + } + } + + add(this, containerContext) + return list + } + private fun KotlinType.computeQualifiersForOverride( - fromSupertypes: Collection, isCovariant: Boolean, + fromSupertypes: Collection, + defaultQualifiersForType: JavaTypeQualifiers?, isHeadTypeConstructor: Boolean ): JavaTypeQualifiers { val superQualifiers = fromSupertypes.map { it.extractQualifiers() } @@ -314,60 +323,57 @@ class SignatureEnhancement(private val annotationTypeQualifierResolver: Annotati val nullabilityFromSupertypesWithWarning = fromSupertypes .mapNotNull { it.unwrapEnhancement().extractQualifiers().nullability } .toSet() - .takeIf { it != nullabilityFromSupertypes } - - val own = extractQualifiersFromAnnotations(isHeadTypeConstructor) - val isAnyNonNullTypeParameter = own.isNotNullTypeParameter || superQualifiers.any { it.isNotNullTypeParameter } - - fun createJavaTypeQualifiers( - nullability: NullabilityQualifier?, - mutability: MutabilityQualifier?, - forWarning: Boolean - ): JavaTypeQualifiers { - if (!isAnyNonNullTypeParameter || nullability != NullabilityQualifier.NOT_NULL) { - return JavaTypeQualifiers(nullability, mutability, false, forWarning) - } - return JavaTypeQualifiers(nullability, mutability, true, forWarning) - } - - fun Set.select(low: T, high: T, own: T?): T? { - if (isCovariant) { - val supertypeQualifier = if (low in this) low else if (high in this) high else null - return if (supertypeQualifier == low && own == high) null else own ?: supertypeQualifier - } - - // isInvariant - val effectiveSet = own?.let { (this + own).toSet() } ?: this - // if this set contains exactly one element, it is the qualifier everybody agrees upon, - // otherwise (no qualifiers, or multiple qualifiers), there's no single such qualifier - // and all qualifiers are discarded - return effectiveSet.singleOrNull() - } + val own = extractQualifiersFromAnnotations(isHeadTypeConstructor, defaultQualifiersForType) val ownNullability = own.takeIf { !it.isNullabilityQualifierForWarning }?.nullability val ownNullabilityForWarning = own.nullability - val nullability = nullabilityFromSupertypes.select(NullabilityQualifier.NOT_NULL, NullabilityQualifier.NULLABLE, ownNullability) - val mutability = mutabilityFromSupertypes.select(MutabilityQualifier.MUTABLE, MutabilityQualifier.READ_ONLY, own.mutability) + val isCovariantPosition = isCovariant && isHeadTypeConstructor + val nullability = nullabilityFromSupertypes.select(ownNullability, isCovariantPosition) + val mutability = + mutabilityFromSupertypes + .select(MutabilityQualifier.MUTABLE, MutabilityQualifier.READ_ONLY, own.mutability, isCovariantPosition) - val canChange = ownNullabilityForWarning != ownNullability || nullabilityFromSupertypesWithWarning != null + val canChange = ownNullabilityForWarning != ownNullability || nullabilityFromSupertypesWithWarning != nullabilityFromSupertypes + val isAnyNonNullTypeParameter = own.isNotNullTypeParameter || superQualifiers.any { it.isNotNullTypeParameter } if (nullability == null && canChange) { - val nullabilityWithWarning = (nullabilityFromSupertypesWithWarning ?: nullabilityFromSupertypes) - .select(NullabilityQualifier.NOT_NULL, NullabilityQualifier.NULLABLE, ownNullabilityForWarning) + val nullabilityWithWarning = + nullabilityFromSupertypesWithWarning.select(ownNullabilityForWarning, isCovariantPosition) - return createJavaTypeQualifiers(nullabilityWithWarning, mutability, true) + return createJavaTypeQualifiers( + nullabilityWithWarning, mutability, + forWarning = true, isAnyNonNullTypeParameter = isAnyNonNullTypeParameter + ) } - return createJavaTypeQualifiers(nullability, mutability,nullability == null) + return createJavaTypeQualifiers( + nullability, mutability, + forWarning = nullability == null, + isAnyNonNullTypeParameter = isAnyNonNullTypeParameter + ) } + } private data class PartEnhancementResult(val type: KotlinType, val wereChanges: Boolean) - private fun D.parts( + private fun CallableMemberDescriptor.partsForValueParameter( + // TODO: investigate if it's really can be a null (check properties' with extension overrides in Java) + parameterDescriptor: ValueParameterDescriptor?, + methodContext: LazyJavaResolverContext, + collector: (CallableMemberDescriptor) -> KotlinType + ) = parts( + parameterDescriptor, false, + parameterDescriptor?.let { methodContext.copyWithNewDefaultTypeQualifiers(it.annotations) } ?: methodContext, + AnnotationTypeQualifierResolver.QualifierApplicabilityType.VALUE_PARAMETER, + collector + ) + + private fun CallableMemberDescriptor.parts( typeContainer: Annotated?, isCovariant: Boolean, - defaultTopLevelQualifiers: JavaTypeQualifiers?, + containerContext: LazyJavaResolverContext, + containerApplicabilityType: AnnotationTypeQualifierResolver.QualifierApplicabilityType, collector: (CallableMemberDescriptor) -> KotlinType ): SignatureParts { return SignatureParts( @@ -377,8 +383,47 @@ class SignatureEnhancement(private val annotationTypeQualifierResolver: Annotati collector(it) }, isCovariant, - defaultTopLevelQualifiers + // recompute default type qualifiers using type annotations + containerContext.copyWithNewDefaultTypeQualifiers(collector(this).annotations), + containerApplicabilityType ) } } + +private fun createJavaTypeQualifiers( + nullability: NullabilityQualifier?, + mutability: MutabilityQualifier?, + forWarning: Boolean, + isAnyNonNullTypeParameter: Boolean +): JavaTypeQualifiers { + if (!isAnyNonNullTypeParameter || nullability != NullabilityQualifier.NOT_NULL) { + return JavaTypeQualifiers(nullability, mutability, false, forWarning) + } + return JavaTypeQualifiers(nullability, mutability, true, forWarning) +} + +private fun Set.select(low: T, high: T, own: T?, isCovariant: Boolean): T? { + if (isCovariant) { + val supertypeQualifier = if (low in this) low else if (high in this) high else null + return if (supertypeQualifier == low && own == high) null else own ?: supertypeQualifier + } + + // isInvariant + val effectiveSet = own?.let { (this + own).toSet() } ?: this + // if this set contains exactly one element, it is the qualifier everybody agrees upon, + // otherwise (no qualifiers, or multiple qualifiers), there's no single such qualifier + // and all qualifiers are discarded + return effectiveSet.singleOrNull() +} + +private fun Set.select(own: NullabilityQualifier?, isCovariant: Boolean) = + if (own == NullabilityQualifier.FORCE_FLEXIBILITY) + NullabilityQualifier.FORCE_FLEXIBILITY + else + select(NullabilityQualifier.NOT_NULL, NullabilityQualifier.NULLABLE, own, isCovariant) + +private data class TypeAndDefaultQualifiers( + val type: KotlinType, + val defaultQualifiers: JavaTypeQualifiers? +) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhancement/typeQualifiers.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhancement/typeQualifiers.kt index f7bc60bddc1..f4cd64abff0 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhancement/typeQualifiers.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhancement/typeQualifiers.kt @@ -18,7 +18,8 @@ package org.jetbrains.kotlin.load.java.typeEnhancement enum class NullabilityQualifier { NULLABLE, - NOT_NULL + NOT_NULL, + FORCE_FLEXIBILITY } enum class MutabilityQualifier { diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt index 91f099bc17d..5b226d431d7 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt @@ -59,7 +59,7 @@ class RuntimeModuleData private constructor( val runtimePackagePartProvider = RuntimePackagePartProvider(classLoader) val javaResolverCache = JavaResolverCache.EMPTY val notFoundClasses = NotFoundClasses(storageManager, module) - val annotationTypeQualifierResolver = AnnotationTypeQualifierResolver(storageManager, Jsr305State.IGNORE) + val annotationTypeQualifierResolver = AnnotationTypeQualifierResolver(storageManager, Jsr305State.DISABLED) val globalJavaResolverContext = JavaResolverComponents( storageManager, ReflectJavaClassFinder(classLoader), reflectKotlinClassFinder, deserializedDescriptorResolver, ExternalAnnotationResolver.EMPTY, SignaturePropagator.DO_NOTHING, RuntimeErrorReporter, javaResolverCache, diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ModuleDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ModuleDescriptor.kt index a9262fe6349..d5a2164a41a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ModuleDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ModuleDescriptor.kt @@ -40,9 +40,6 @@ interface ModuleDescriptor : DeclarationDescriptor { */ val allDependencyModules: List - // All platform-specific modules depending on common 'this' module (result is empty if this is platform-specific itself) - val allImplementingModules: Set - fun getCapability(capability: Capability): T? class Capability(val name: String) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java index 0e86a80fc8d..d44088542c7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java @@ -310,6 +310,12 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase { return enumMemberNames.invoke(); } + @NotNull + @Override + public Set getClassifierNames() { + return Collections.emptySet(); + } + @NotNull @Override public Set getVariableNames() { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ModuleDescriptorImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ModuleDescriptorImpl.kt index 1564e153448..b703f9a3482 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ModuleDescriptorImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ModuleDescriptorImpl.kt @@ -48,9 +48,6 @@ class ModuleDescriptorImpl @JvmOverloads constructor( private var packageFragmentProviderForModuleContent: PackageFragmentProvider? = null override var isValid: Boolean = true - set(value) { - field = value - } override fun assertValid() { if (!isValid) { @@ -68,9 +65,6 @@ class ModuleDescriptorImpl @JvmOverloads constructor( override val allDependencyModules: List get() = this.dependencies.sure { "Dependencies of module $id were not set" }.allDependencies.filter { it != this } - override val allImplementingModules: Set - get() = this.dependencies.sure { "Dependencies of module $id were not set" }.allImplementingModules - override fun getPackage(fqName: FqName): PackageViewDescriptor { assertValid() return packages(fqName) @@ -144,12 +138,9 @@ class ModuleDescriptorImpl @JvmOverloads constructor( interface ModuleDependencies { val allDependencies: List val modulesWhoseInternalsAreVisible: Set - val allImplementingModules: Set } class ModuleDependenciesImpl( override val allDependencies: List, override val modulesWhoseInternalsAreVisible: Set -) : ModuleDependencies { - override val allImplementingModules: Set = emptySet() -} +) : ModuleDependencies \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SubpackagesScope.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SubpackagesScope.kt index 643254d7d70..fbf0944f99f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SubpackagesScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/SubpackagesScope.kt @@ -57,6 +57,8 @@ open class SubpackagesScope(private val moduleDescriptor: ModuleDescriptor, priv return result } + override fun getClassifierNames(): Set = emptySet() + override fun printScopeStructure(p: Printer) { p.println(this::class.java.simpleName, " {") p.pushIndent() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt index a23eed6efdd..f6a889c55e9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt @@ -55,6 +55,11 @@ abstract class AbstractScopeAdapter : MemberScope { override fun getFunctionNames() = workerScope.getFunctionNames() override fun getVariableNames() = workerScope.getVariableNames() + override fun getClassifierNames() = workerScope.getClassifierNames() + + override fun recordLookup(name: Name, location: LookupLocation) { + workerScope.recordLookup(name, location) + } override fun printScopeStructure(p: Printer) { p.println(this::class.java.simpleName, " {") diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedMemberScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedMemberScope.kt index 8357efafd05..50cd3e5841e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedMemberScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedMemberScope.kt @@ -43,6 +43,11 @@ class ChainedMemberScope( override fun getFunctionNames() = scopes.flatMapTo(mutableSetOf()) { it.getFunctionNames() } override fun getVariableNames() = scopes.flatMapTo(mutableSetOf()) { it.getVariableNames() } + override fun getClassifierNames(): Set? = scopes.flatMapClassifierNamesOrNull() + + override fun recordLookup(name: Name, location: LookupLocation) { + scopes.forEach { it.recordLookup(name, location) } + } override fun toString() = debugName diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/InnerClassesScopeWrapper.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/InnerClassesScopeWrapper.kt index 23f5fcc7c6a..10f0011be3d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/InnerClassesScopeWrapper.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/InnerClassesScopeWrapper.kt @@ -40,5 +40,11 @@ class InnerClassesScopeWrapper(val workerScope: MemberScope) : MemberScopeImpl() workerScope.printScopeStructure(p) } + override fun getFunctionNames() = workerScope.getFunctionNames() + override fun getVariableNames() = workerScope.getVariableNames() + override fun getClassifierNames() = workerScope.getClassifierNames() + + override fun definitelyDoesNotContainName(name: Name) = workerScope.definitelyDoesNotContainName(name) + override fun toString() = "Classes from $workerScope" } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt index 7666365671f..997a35a59e9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.Printer +import org.jetbrains.kotlin.utils.addToStdlib.flatMapToNullable import java.lang.reflect.Modifier interface MemberScope : ResolutionScope { @@ -32,6 +33,7 @@ interface MemberScope : ResolutionScope { */ fun getFunctionNames(): Set fun getVariableNames(): Set + fun getClassifierNames(): Set? /** * Is supposed to be used in tests and debug only @@ -45,6 +47,7 @@ interface MemberScope : ResolutionScope { override fun getFunctionNames() = emptySet() override fun getVariableNames() = emptySet() + override fun getClassifierNames() = emptySet() } companion object { @@ -52,6 +55,11 @@ interface MemberScope : ResolutionScope { } } +fun MemberScope.computeAllNames() = getClassifierNames()?.let { getFunctionNames() + getVariableNames() + it } + +fun Collection.flatMapClassifierNamesOrNull(): MutableSet? = + flatMapToNullable(hashSetOf(), MemberScope::getClassifierNames) + /** * The same as getDescriptors(kindFilter, nameFilter) but the result is guaranteed to be filtered by kind and name. */ diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScopeImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScopeImpl.kt index f54f05fea1b..773936d5a4d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScopeImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScopeImpl.kt @@ -42,6 +42,8 @@ abstract class MemberScopeImpl : MemberScope { DescriptorKindFilter.VARIABLES, alwaysTrue() ).filterIsInstance().mapTo(mutableSetOf()) { it.name } + override fun getClassifierNames(): Set? = null + // This method should not be implemented here by default: every scope class has its unique structure pattern abstract override fun printScopeStructure(p: Printer) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ResolutionScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ResolutionScope.kt index 8c7fcf3f24d..0a772b52259 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ResolutionScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ResolutionScope.kt @@ -16,7 +16,10 @@ package org.jetbrains.kotlin.resolve.scopes -import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.ClassifierDescriptor +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.descriptors.VariableDescriptor import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.Name @@ -36,4 +39,10 @@ interface ResolutionScope { kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL, nameFilter: (Name) -> Boolean = MemberScope.ALL_NAME_FILTER ): Collection + + fun definitelyDoesNotContainName(name: Name): Boolean = false + + fun recordLookup(name: Name, location: LookupLocation) { + getContributedFunctions(name, location) + } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt index 83de7362900..d4cae2f38cb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt @@ -81,6 +81,9 @@ class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor: override fun getFunctionNames() = workerScope.getFunctionNames() override fun getVariableNames() = workerScope.getVariableNames() + override fun getClassifierNames() = workerScope.getClassifierNames() + + override fun definitelyDoesNotContainName(name: Name) = workerScope.definitelyDoesNotContainName(name) override fun printScopeStructure(p: Printer) { p.println(this::class.java.simpleName, " {") diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java index a6d3856fae6..c6885e3a1db 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java @@ -85,12 +85,6 @@ public class ErrorUtils { return emptyList(); } - @NotNull - @Override - public Set getAllImplementingModules() { - return emptySet(); - } - @Override public R accept(@NotNull DeclarationDescriptorVisitor visitor, D data) { return null; @@ -211,6 +205,17 @@ public class ErrorUtils { return emptySet(); } + @NotNull + @Override + public Set getClassifierNames() { + return emptySet(); + } + + @Override + public void recordLookup(@NotNull Name name, @NotNull LookupLocation location) { + + } + @NotNull @Override public Collection getContributedDescriptors( @@ -219,6 +224,11 @@ public class ErrorUtils { return Collections.emptyList(); } + @Override + public boolean definitelyDoesNotContainName(@NotNull Name name) { + return false; + } + @Override public String toString() { return "ErrorScope{" + debugMessage + '}'; @@ -279,6 +289,21 @@ public class ErrorUtils { throw new IllegalStateException(); } + @Override + public Set getClassifierNames() { + throw new IllegalStateException(); + } + + @Override + public void recordLookup(@NotNull Name name, @NotNull LookupLocation location) { + throw new IllegalStateException(); + } + + @Override + public boolean definitelyDoesNotContainName(@NotNull Name name) { + return false; + } + @Override public String toString() { return "ThrowingScope{" + debugMessage + '}'; diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MetadataPackageFragmentProvider.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MetadataPackageFragmentProvider.kt index 71ee450c4e8..f3a6c79e598 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MetadataPackageFragmentProvider.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MetadataPackageFragmentProvider.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.PackagePartProvider import org.jetbrains.kotlin.descriptors.SourceElement import org.jetbrains.kotlin.descriptors.deserialization.AdditionalClassPartsProvider import org.jetbrains.kotlin.descriptors.deserialization.PlatformDependentDeclarationFilter +import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.incremental.components.LookupTracker import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName @@ -106,6 +107,8 @@ class MetadataPackageFragment( containerSource = null, components = components, classNames = { emptyList() } ) { override fun hasClass(name: Name): Boolean = hasTopLevelClass(name) + override fun definitelyDoesNotContainName(name: Name) = false + override fun getClassifierNames(): Set? = null }) return ChainedMemberScope.create("Metadata scope", scopes) diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt index ff802785fc7..0014c9e96ba 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt @@ -294,8 +294,8 @@ class DeserializedClassDescriptor( result.addAll(classDescriptor.enumEntries?.all().orEmpty()) } - private fun recordLookup(name: Name, from: LookupLocation) { - c.components.lookupTracker.record(from, classDescriptor, name) + override fun recordLookup(name: Name, location: LookupLocation) { + c.components.lookupTracker.record(location, classDescriptor, name) } } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt index ebba36a8561..d46f1158a7e 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt @@ -76,6 +76,11 @@ abstract class DeserializedMemberScope protected constructor( override fun getFunctionNames() = functionNamesLazy override fun getVariableNames() = variableNamesLazy + override fun getClassifierNames(): Set? = classNames + typeAliasNames + + override fun definitelyDoesNotContainName(name: Name): Boolean { + return name !in functionNamesLazy && name !in variableNamesLazy && name !in classNames && name !in typeAliasNames + } private inline fun Collection.groupByName( getNameIndex: (M) -> Int diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt index bc9b7bef674..7b585b775ab 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt @@ -55,10 +55,14 @@ open class DeserializedPackageMemberScope( override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? { - c.components.lookupTracker.record(location, packageDescriptor, name) + recordLookup(name, location) return super.getContributedClassifier(name, location) } + override fun recordLookup(name: Name, location: LookupLocation) { + c.components.lookupTracker.record(location, packageDescriptor, name) + } + override fun getNonDeclaredFunctionNames(): Set = emptySet() override fun getNonDeclaredVariableNames(): Set = emptySet() diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/Jsr305State.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/Jsr305State.kt index 23314787efa..0f9885a2e7d 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/Jsr305State.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/Jsr305State.kt @@ -16,21 +16,48 @@ package org.jetbrains.kotlin.utils -enum class Jsr305State( - val description: String -) { +enum class ReportLevel(val description: String) { IGNORE("ignore"), WARN("warn"), STRICT("strict"), ; companion object { - @JvmField - val DEFAULT: Jsr305State = WARN - - fun findByDescription(description: String?) = values().firstOrNull { it.description == description } + fun findByDescription(description: String?): ReportLevel? = values().firstOrNull { it.description == description } } - fun isIgnored(): Boolean = this == IGNORE - fun isWarning(): Boolean = this == WARN + val isWarning: Boolean get() = this == ReportLevel.WARN + val isIgnore: Boolean get() = this == ReportLevel.IGNORE +} + +data class Jsr305State( + val global: ReportLevel, + val migration: ReportLevel?, + val user: Map +) { + val description: Array by lazy { + val result = mutableListOf() + result.add(global.description) + + migration?.let { result.add("under-migration:${it.description}") } + + user.forEach { + result.add("@${it.key}:${it.value.description}") + } + + result.toTypedArray() + } + + val disabled: Boolean get() = this === DISABLED + + companion object { + @JvmField + val DEFAULT: Jsr305State = Jsr305State(ReportLevel.WARN, null, emptyMap()) + + @JvmField + val DISABLED: Jsr305State = Jsr305State(ReportLevel.IGNORE, ReportLevel.IGNORE, emptyMap()) + + @JvmField + val STRICT: Jsr305State = Jsr305State(ReportLevel.STRICT, ReportLevel.STRICT, emptyMap()) + } } diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt index be639c80350..c364f463a81 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt @@ -138,3 +138,11 @@ fun > Iterable>.flattenTo(c: C): C { } return c } + +inline fun > Iterable.flatMapToNullable(destination: C, transform: (T) -> Iterable?): C? { + for (element in this) { + val list = transform(element) ?: return null + destination.addAll(list) + } + return destination +} diff --git a/generators/infrastructure/increment-version.kts b/generators/infrastructure/increment-version.kts index 5635d81f9e9..fec8a1abaf2 100644 --- a/generators/infrastructure/increment-version.kts +++ b/generators/infrastructure/increment-version.kts @@ -28,13 +28,13 @@ fun main(args: Array) { "") } - var versionStr = args[0] + val versionStr = args[0] val incrementPartStr = versionStr.takeLastWhile(Char::isDigit) - val versionPrefix = versionStr.take(versionStr.length - incrementPartStr.length) val incrementPart = incrementPartStr.toInt() + val versionPrefix = versionStr.take(versionStr.length - incrementPartStr.length) - var filePath = args.getOrNull(1) ?: filePathDefault + val filePath = args.getOrNull(1) ?: filePathDefault val result = "${versionPrefix}${incrementPart + 1}" diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 1790e86d898..1f8621fa212 100755 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -517,6 +517,14 @@ fun main(args: Array) { model("foreignAnnotationsJava8/tests") } + testClass { + model("foreignAnnotationsJava8/tests") + } + + testClass { + model("foreignAnnotationsJava8/tests") + } + testClass { model("loadJava8/compiledJava", extension = "java", testMethod = "doTestCompiledJava") model("loadJava8/sourceJava", extension = "java", testMethod = "doTestSourceJava") @@ -527,6 +535,10 @@ fun main(args: Array) { model("loadJava8/sourceJava", extension = "java", testMethod = "doTestSourceJava") } + testClass { + model("loadJava8/compiledJava", extension = "java", testMethod = "doTestCompiledJava") + } + testClass { model("resolvedCalls/enhancedSignatures") } diff --git a/idea/build.gradle.kts b/idea/build.gradle.kts index 687ee201c71..8a015254af2 100644 --- a/idea/build.gradle.kts +++ b/idea/build.gradle.kts @@ -57,13 +57,15 @@ dependencies { testRuntime(ideaSdkDeps("*.jar")) testRuntime(ideaPluginDeps("*.jar", plugin = "junit")) - testRuntime(ideaPluginDeps("jcommander", "resources_en", plugin = "testng")) testRuntime(ideaPluginDeps("resources_en", plugin = "properties")) testRuntime(ideaPluginDeps("*.jar", plugin = "gradle")) testRuntime(ideaPluginDeps("*.jar", plugin = "Groovy")) - testRuntime(ideaPluginDeps("jacocoant", plugin = "coverage")) + testRuntime(ideaPluginDeps("*.jar", plugin = "coverage")) testRuntime(ideaPluginDeps("*.jar", plugin = "maven")) testRuntime(ideaPluginDeps("*.jar", plugin = "android")) + testRuntime(ideaPluginDeps("*.jar", plugin = "testng")) + + testRuntime(project(":plugins:kapt3-idea")) { isTransitive = false } // deps below are test runtime deps, but made test compile to split compilation and running to reduce mem req testCompile(project(":plugins:android-extensions-compiler")) @@ -107,4 +109,5 @@ projectTest { testsJar {} classesDirsArtifact() +configureInstrumentation() diff --git a/idea/ide-common/src/org/jetbrains/kotlin/caches/resolve/KotlinCacheService.kt b/idea/ide-common/src/org/jetbrains/kotlin/caches/resolve/KotlinCacheService.kt index e38c48848cd..d47377a7c55 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/caches/resolve/KotlinCacheService.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/caches/resolve/KotlinCacheService.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.caches.resolve import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.project.Project import com.intellij.psi.PsiFile +import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.idea.resolve.ResolutionFacade import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.resolve.TargetPlatform @@ -33,4 +34,5 @@ interface KotlinCacheService { fun getResolutionFacadeByFile(file: PsiFile, platform: TargetPlatform): ResolutionFacade fun getSuppressionCache(): KotlinSuppressCache + fun getResolutionFacadeByModuleInfo(moduleInfo: ModuleInfo, platform: TargetPlatform): ResolutionFacade? } \ No newline at end of file diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/kdoc/resolveKDocLink.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/kdoc/resolveKDocLink.kt index 67912426e92..b66aedbaffa 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/kdoc/resolveKDocLink.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/kdoc/resolveKDocLink.kt @@ -253,6 +253,8 @@ private class ExtensionsScope( .toSet() } + override fun getClassifierNames() = null + override fun printScopeStructure(p: Printer) { p.println("Extensions for ${receiverClass.name} in:") contextScope.printStructure(p) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt index e6f619c02b1..c4dc9e1b312 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt @@ -102,14 +102,13 @@ class ShadowedDeclarationsFilter( } } - private fun signature(descriptor: DeclarationDescriptor): Any { - return when (descriptor) { - is SimpleFunctionDescriptor -> FunctionSignature(descriptor) - is VariableDescriptor -> descriptor.name - is ClassDescriptor -> descriptor.importableFqName ?: descriptor - else -> descriptor - } - } + private fun signature(descriptor: DeclarationDescriptor): Any = + when (descriptor) { + is SimpleFunctionDescriptor -> FunctionSignature(descriptor) + is VariableDescriptor -> descriptor.name + is ClassDescriptor -> descriptor.importableFqName ?: descriptor + else -> descriptor + } private fun packageName(descriptor: DeclarationDescriptor) = descriptor.importableFqName?.parent() @@ -119,14 +118,19 @@ class ShadowedDeclarationsFilter( ): Collection { if (descriptors.size == 1) return descriptors - val first = descriptors.first() + val first = descriptors.firstOrNull { + it is ClassDescriptor || it is ConstructorDescriptor || it is CallableDescriptor && !it.name.isSpecial + } ?: return descriptors if (first is ClassDescriptor) { // for classes with the same FQ-name we simply take the first one - return listOf(first) + return listOf(first) } val isFunction = first is FunctionDescriptor - val name = first.name + val name = when (first) { + is ConstructorDescriptor -> first.constructedClass.name + else -> first.name + } val parameters = (first as CallableDescriptor).valueParameters val dummyArgumentExpressions = dummyExpressionFactory.createDummyExpressions(parameters.size) @@ -203,7 +207,7 @@ class ShadowedDeclarationsFilter( val dataFlowInfo = bindingContext.getDataFlowInfoBefore(context) val context = BasicCallResolutionContext.create(bindingTrace, scope, newCall, TypeUtils.NO_EXPECTED_TYPE, dataFlowInfo, ContextDependency.INDEPENDENT, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, - false, resolutionFacade.frontendService()) + false, /* languageVersionSettings */ resolutionFacade.frontendService()) val callResolver = resolutionFacade.frontendService() val results = if (isFunction) callResolver.resolveFunctionCall(context) else callResolver.resolveSimpleProperty(context) val resultingDescriptors = results.resultingCalls.map { it.resultingDescriptor } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt index c24fb63d8bc..b9fb969d86d 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt @@ -38,6 +38,8 @@ class ExplicitImportsScope(private val descriptors: Collection Boolean, changeNamesForAliased: Boolean) = descriptors + override fun computeImportedNames() = descriptors.mapTo(hashSetOf()) { it.name } + override fun printStructure(p: Printer) { p.println(this::class.java.name) } diff --git a/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUtil.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/KotlinPluginUtil.java similarity index 100% rename from idea/src/org/jetbrains/kotlin/idea/KotlinPluginUtil.java rename to idea/idea-analysis/src/org/jetbrains/kotlin/idea/KotlinPluginUtil.java diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt index d9b0ac8dbc7..c81f2f36346 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.kt @@ -219,7 +219,7 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG override fun resolveToDescriptor(declaration: KtDeclaration): DeclarationDescriptor? { try { - return declaration.unsafeResolveToDescriptor() + return declaration.resolveToDescriptorIfAny(BodyResolveMode.FULL) } catch (e: NoDescriptorForDeclarationException) { return null diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfos.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfos.kt index bffa8c2a4a4..d046bc971ce 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfos.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IdeaModuleInfos.kt @@ -21,6 +21,7 @@ import com.intellij.openapi.module.impl.scopes.LibraryScopeBase import com.intellij.openapi.project.Project import com.intellij.openapi.projectRoots.Sdk import com.intellij.openapi.roots.* +import com.intellij.openapi.roots.impl.ModuleOrderEntryImpl import com.intellij.openapi.roots.impl.libraries.LibraryEx import com.intellij.openapi.roots.libraries.Library import com.intellij.openapi.util.ModificationTracker @@ -35,6 +36,7 @@ import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.analyzer.TrackableModuleInfo import org.jetbrains.kotlin.caches.resolve.LibraryModuleInfo import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.idea.KotlinPluginUtil import org.jetbrains.kotlin.idea.framework.getLibraryPlatform import org.jetbrains.kotlin.idea.project.KotlinModuleModificationTracker import org.jetbrains.kotlin.idea.project.TargetPlatformDetector @@ -58,8 +60,8 @@ interface IdeaModuleInfo : ModuleInfo { override fun dependencies(): List } -private fun orderEntryToModuleInfo(project: Project, orderEntry: OrderEntry, productionOnly: Boolean): List { - fun Module.toInfos() = correspondingModuleInfos().filter { !productionOnly || it is ModuleProductionSourceInfo } +private fun orderEntryToModuleInfo(project: Project, orderEntry: OrderEntry, forProduction: Boolean): List { + fun Module.toInfos() = correspondingModuleInfos().filter { !forProduction || it is ModuleProductionSourceInfo } if (!orderEntry.isValid) return emptyList() @@ -68,7 +70,13 @@ private fun orderEntryToModuleInfo(project: Project, orderEntry: OrderEntry, pro orderEntry.getOwnerModule().toInfos() } is ModuleOrderEntry -> { - orderEntry.module?.toInfos().orEmpty() + val module = orderEntry.module ?: return emptyList() + if (forProduction && orderEntry is ModuleOrderEntryImpl && orderEntry.isProductionOnTestDependency) { + listOfNotNull(module.testSourceInfo()) + } + else { + module.toInfos() + } } is LibraryOrderEntry -> { val library = orderEntry.library ?: return listOf() @@ -88,16 +96,25 @@ fun Module.cached(provider: CachedValueProvider): T { return CachedValuesManager.getManager(project).getCachedValue(this, provider) } -private fun ideaModelDependencies(module: Module, productionOnly: Boolean): List { +private fun OrderEntry.acceptAsDependency(forProduction: Boolean): Boolean { + return this !is ExportableOrderEntry + || !forProduction + // this is needed for Maven/Gradle projects with "production-on-test" dependency + || this is ModuleOrderEntryImpl && isProductionOnTestDependency + || scope.isForProductionCompile +} + +private fun ideaModelDependencies(module: Module, forProduction: Boolean): List { //NOTE: lib dependencies can be processed several times during recursive traversal val result = LinkedHashSet() val dependencyEnumerator = ModuleRootManager.getInstance(module).orderEntries().compileOnly().recursively().exportedOnly() - if (productionOnly) { + if (forProduction && !(KotlinPluginUtil.isMavenModule(module) || KotlinPluginUtil.isGradleModule(module))) { dependencyEnumerator.productionOnly() } - dependencyEnumerator.forEach { - orderEntry -> - result.addAll(orderEntryToModuleInfo(module.project, orderEntry!!, productionOnly)) + dependencyEnumerator.forEach { orderEntry -> + if (orderEntry.acceptAsDependency(forProduction)) { + result.addAll(orderEntryToModuleInfo(module.project, orderEntry!!, forProduction)) + } true } return result.toList() @@ -125,7 +142,7 @@ data class ModuleProductionSourceInfo internal constructor(override val module: override fun dependencies() = module.cached(CachedValueProvider { CachedValueProvider.Result( - ideaModelDependencies(module, productionOnly = true), + ideaModelDependencies(module, forProduction = true), ProjectRootModificationTracker.getInstance(module.project)) }) } @@ -140,7 +157,7 @@ data class ModuleTestSourceInfo internal constructor(override val module: Module override fun dependencies() = module.cached(CachedValueProvider { CachedValueProvider.Result( - ideaModelDependencies(module, productionOnly = false), + ideaModelDependencies(module, forProduction = false), ProjectRootModificationTracker.getInstance(module.project)) }) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheServiceImpl.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheServiceImpl.kt index 4f6bc881abb..ce546117cc9 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheServiceImpl.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheServiceImpl.kt @@ -28,8 +28,7 @@ import com.intellij.psi.util.CachedValueProvider import com.intellij.psi.util.CachedValuesManager import com.intellij.psi.util.PsiModificationTracker import com.intellij.util.containers.SLRUCache -import org.jetbrains.kotlin.analyzer.LanguageSettingsProvider -import org.jetbrains.kotlin.analyzer.EmptyResolverForProject +import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.caches.resolve.KotlinCacheService import org.jetbrains.kotlin.config.LanguageFeature @@ -367,6 +366,9 @@ class KotlinCacheServiceImpl(val project: Project) : KotlinCacheService { return ResolutionFacadeImpl(projectFacade, moduleInfo) } + override fun getResolutionFacadeByModuleInfo(moduleInfo: ModuleInfo, platform: TargetPlatform): ResolutionFacade? = + (moduleInfo as? IdeaModuleInfo)?.let { getResolutionFacadeByModuleInfo(it, platform) } + private fun Collection.filterNotInProjectSource(moduleInfo: IdeaModuleInfo) = mapNotNull { if (it is KtCodeFragment) it.getContextFile() else it }.filter { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/getModuleInfo.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/getModuleInfo.kt index 11dea1b30bb..d5f6df5ef1b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/getModuleInfo.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/getModuleInfo.kt @@ -181,7 +181,7 @@ private inline fun collectInfosByVirtualFile( onOccurrence(ScriptModuleInfo(project, virtualFile, scriptDefinition)) } - val isBinary = virtualFile.isKotlinBinary() + val isBinary = virtualFile.fileType.isKotlinBinary() val scriptConfigurationManager = ScriptDependenciesManager.getInstance(project) if (isBinary && virtualFile in scriptConfigurationManager.getAllScriptsClasspathScope()) { if (treatAsLibrarySource) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/IDELanguageSettingsProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/IDELanguageSettingsProvider.kt index bfae1e7df72..8706ba0493a 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/IDELanguageSettingsProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/IDELanguageSettingsProvider.kt @@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project import org.jetbrains.kotlin.analyzer.LanguageSettingsProvider import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.config.* import org.jetbrains.kotlin.idea.caches.resolve.LibraryInfo import org.jetbrains.kotlin.idea.caches.resolve.ModuleSourceInfo @@ -41,13 +42,10 @@ object IDELanguageSettingsProvider : LanguageSettingsProvider { val map = mutableMapOf, Any>() for (module in ModuleManager.getInstance(project).modules) { val settings = KotlinFacetSettingsProvider.getInstance(project).getSettings(module) ?: continue - val compilerArguments = settings.compilerArguments as? K2JVMCompilerArguments ?: continue + val compilerArguments = settings.mergedCompilerArguments as? K2JVMCompilerArguments ?: continue - val jsr305state = Jsr305State.findByDescription(compilerArguments.jsr305) - if (jsr305state != null && jsr305state != Jsr305State.IGNORE) { - map.put(AnalysisFlag.jsr305, jsr305state) - break - } + val jsr305State = compilerArguments.parseJsr305(MessageCollector.NONE) + map.put(AnalysisFlag.jsr305, jsr305State) } return map } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/ClassFileDecompilerUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/ClassFileDecompilerUtil.kt index aa8038287da..7b4f87d0cd1 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/ClassFileDecompilerUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/classFile/ClassFileDecompilerUtil.kt @@ -50,6 +50,11 @@ fun isKotlinWithCompatibleAbiVersion(file: VirtualFile): Boolean { * which should NOT be decompiled (and, as a result, shown under the library in the Project view, be searchable via Find class, etc.) */ fun isKotlinInternalCompiledFile(file: VirtualFile, fileContent: ByteArray? = null): Boolean { + // Don't crash on invalid files (EA-97751) + if (!file.isValid || fileContent?.size == 0) { + return false + } + if (!IDEKotlinBinaryClassCache.isKotlinJvmCompiledFile(file, fileContent)) { return false } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeErrorMessages.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeErrorMessages.java index 17c6e928009..ff0e49c9e70 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeErrorMessages.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeErrorMessages.java @@ -175,7 +175,7 @@ public class IdeErrorMessages { MAP.put(EXPERIMENTAL_FEATURE_WARNING, "{0}", new LanguageFeatureMessageRenderer(LanguageFeatureMessageRenderer.Type.WARNING, true)); MAP.put(EXPERIMENTAL_FEATURE_ERROR, "{0}", new LanguageFeatureMessageRenderer(LanguageFeatureMessageRenderer.Type.ERROR, true)); - MAP.put(NO_ACTUAL_FOR_EXPECT, "Expected {0} has no actual in module{1}{2}", DECLARATION_NAME_WITH_KIND, + MAP.put(NO_ACTUAL_FOR_EXPECT, "Expected {0} has no actual declaration in module{1}{2}", DECLARATION_NAME_WITH_KIND, PLATFORM, new PlatformIncompatibilityDiagnosticRenderer(IdeMultiplatformDiagnosticRenderingMode.INSTANCE)); MAP.put(ACTUAL_WITHOUT_EXPECT, "Actual {0} has no corresponding expected declaration{1}", DECLARATION_NAME_WITH_KIND, new PlatformIncompatibilityDiagnosticRenderer(IdeMultiplatformDiagnosticRenderingMode.INSTANCE)); diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/IdeSampleResolutionService.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/IdeSampleResolutionService.kt index 0cc7a37c59d..f0da18e9181 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/IdeSampleResolutionService.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/IdeSampleResolutionService.kt @@ -75,8 +75,8 @@ private class GlobalSyntheticPackageViewDescriptor(override val fqName: FqName, override fun getContributedFunctions(name: Name, location: LookupLocation): Collection = shouldNotBeCalled() override fun getFunctionNames(): Set = shouldNotBeCalled() - override fun getVariableNames(): Set = shouldNotBeCalled() + override fun getClassifierNames(): Set = shouldNotBeCalled() override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = shouldNotBeCalled() @@ -130,4 +130,4 @@ private class GlobalSyntheticPackageViewDescriptor(override val fqName: FqName, override fun acceptVoid(visitor: DeclarationDescriptorVisitor?) = shouldNotBeCalled() override val annotations = Annotations.EMPTY -} \ No newline at end of file +} diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt index f2e8ecfc168..e4eef941c4d 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt @@ -61,6 +61,10 @@ class StubBasedPackageMemberDeclarationProvider( return result } + override fun getDeclarationNames() = + getDeclarations(DescriptorKindFilter.ALL, { true }) + .mapTo(mutableSetOf()) { ResolveSessionUtils.safeNameForLazyResolve(it as KtNamedDeclaration) } + override fun getClassOrObjectDeclarations(name: Name): Collection { val result = ArrayList() runReadAction { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ProjectRootsUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ProjectRootsUtil.kt index d2cde1c1e7e..bd1ac41a70f 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ProjectRootsUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ProjectRootsUtil.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.util import com.intellij.ide.highlighter.ArchiveFileType import com.intellij.ide.highlighter.JavaClassFileType import com.intellij.injected.editor.VirtualFileWindow +import com.intellij.openapi.fileTypes.FileType import com.intellij.openapi.module.Module import com.intellij.openapi.module.ModuleUtilCore import com.intellij.openapi.project.Project @@ -39,7 +40,7 @@ import org.jetbrains.kotlin.idea.util.application.runReadAction private val kotlinBinaries = listOf(JavaClassFileType.INSTANCE, KotlinBuiltInFileType, KotlinModuleFileType.INSTANCE) -fun VirtualFile.isKotlinBinary(): Boolean = fileType in kotlinBinaries +fun FileType.isKotlinBinary(): Boolean = this in kotlinBinaries fun FileIndex.isInSourceContentWithoutInjected(file: VirtualFile): Boolean { return file !is VirtualFileWindow && isInSourceContent(file) @@ -62,8 +63,9 @@ object ProjectRootsUtil { if (!includeLibraryClasses && !includeLibrarySource) return false // NOTE: the following is a workaround for cases when class files are under library source roots and source files are under class roots - val canContainClassFiles = file.fileType == ArchiveFileType.INSTANCE || file.isDirectory - val isBinary = file.isKotlinBinary() + val fileType = file.fileType + val canContainClassFiles = fileType == ArchiveFileType.INSTANCE || file.isDirectory + val isBinary = fileType.isKotlinBinary() val scriptConfigurationManager = if (includeScriptDependencies) ScriptDependenciesManager.getInstance(project) else null diff --git a/idea/idea-android/src/org/jetbrains/kotlin/android/configure/KotlinAndroidGradleModuleConfigurator.kt b/idea/idea-android/src/org/jetbrains/kotlin/android/configure/KotlinAndroidGradleModuleConfigurator.kt index 963d276708a..3a9dc222d1c 100644 --- a/idea/idea-android/src/org/jetbrains/kotlin/android/configure/KotlinAndroidGradleModuleConfigurator.kt +++ b/idea/idea-android/src/org/jetbrains/kotlin/android/configure/KotlinAndroidGradleModuleConfigurator.kt @@ -25,6 +25,7 @@ import com.intellij.openapi.roots.ModuleRootManager import com.intellij.psi.PsiFile import org.jetbrains.kotlin.idea.KotlinPluginUtil import org.jetbrains.kotlin.idea.configuration.KotlinWithGradleConfigurator +import org.jetbrains.kotlin.idea.util.projectStructure.version import org.jetbrains.kotlin.idea.versions.MAVEN_STDLIB_ID_JRE7 import org.jetbrains.kotlin.idea.versions.hasJreSpecificRuntime import org.jetbrains.kotlin.resolve.TargetPlatform @@ -62,7 +63,7 @@ class KotlinAndroidGradleModuleConfigurator internal constructor() : KotlinWithG override fun getStdlibArtifactName(sdk: Sdk?, version: String): String { if (sdk != null && hasJreSpecificRuntime(version)) { - val sdkVersion = JavaSdk.getInstance().getVersion(sdk) + val sdkVersion = sdk.version if (sdkVersion != null && sdkVersion.isAtLeast(JavaSdkVersion.JDK_1_8)) { // Android dex can't convert our kotlin-stdlib-jre8 artifact, so use jre7 instead (KT-16530) return MAVEN_STDLIB_ID_JRE7 diff --git a/idea/idea-android/tests/org/jetbrains/kotlin/android/quickfix/AbstractAndroidQuickFixMultiFileTest.java b/idea/idea-android/tests/org/jetbrains/kotlin/android/quickfix/AbstractAndroidQuickFixMultiFileTest.java index 41704163d37..77b5944c2be 100644 --- a/idea/idea-android/tests/org/jetbrains/kotlin/android/quickfix/AbstractAndroidQuickFixMultiFileTest.java +++ b/idea/idea-android/tests/org/jetbrains/kotlin/android/quickfix/AbstractAndroidQuickFixMultiFileTest.java @@ -45,7 +45,7 @@ public abstract class AbstractAndroidQuickFixMultiFileTest extends AbstractQuick } @Override - protected void doTestWithExtraFile(@NotNull String beforeFileName) throws Exception { + protected void doTestWithExtraFile(@NotNull String beforeFileName) { addManifest(); super.doTestWithExtraFile(beforeFileName); } @@ -59,7 +59,7 @@ public abstract class AbstractAndroidQuickFixMultiFileTest extends AbstractQuick ApplicationManager.getApplication().runWriteAction(facetModel::commit); } - private void addManifest() throws Exception { + private void addManifest() { myFixture.configureByFile("idea/testData/android/AndroidManifest.xml"); } } diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/AbstractCompletionHandlerTests.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/AbstractCompletionHandlerTests.kt index be5d7fa6bde..65c99a6c155 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/AbstractCompletionHandlerTests.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/AbstractCompletionHandlerTests.kt @@ -78,7 +78,7 @@ abstract class AbstractCompletionHandlerTest(private val defaultCompletionType: } } - doTestWithTextLoaded(completionType, invocationCount, lookupString, itemText, tailText, completionChar, testPath + ".after") + doTestWithTextLoaded(completionType, invocationCount, lookupString, itemText, tailText, completionChar, File(testPath).name + ".after") } finally { settingManager.dropTemporarySettings() diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionHandlerTestBase.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionHandlerTestBase.kt index 9dac4d6a713..776fbefc5da 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionHandlerTestBase.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/CompletionHandlerTestBase.kt @@ -25,7 +25,6 @@ import com.intellij.codeInsight.lookup.impl.LookupImpl import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture import org.jetbrains.kotlin.idea.completion.test.ExpectedCompletionUtils import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase -import org.jetbrains.kotlin.test.KotlinTestUtils abstract class CompletionHandlerTestBase() : KotlinLightCodeInsightFixtureTestCase() { protected val fixture: JavaCodeInsightTestFixture @@ -106,8 +105,6 @@ abstract class CompletionHandlerTestBase() : KotlinLightCodeInsightFixtureTestCa return foundElement } - override fun getTestDataPath() = KotlinTestUtils.getHomeDirectory() - protected fun selectItem(item: LookupElement?, completionChar: Char) { val lookup = (fixture.lookup as LookupImpl) if (lookup.currentItem != item) { // do not touch selection if not changed - important for char filter tests diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/ideaTestUtils.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/ideaTestUtils.kt index 2f10667b367..06022ac896c 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/ideaTestUtils.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/ideaTestUtils.kt @@ -21,21 +21,17 @@ import com.intellij.testFramework.UsefulTestCase import com.intellij.testFramework.fixtures.CodeInsightTestFixture import java.io.File -fun CodeInsightTestFixture.configureWithExtraFileAbs(path: String, vararg extraNameParts: String) { - configureWithExtraFile(path, *extraNameParts, relativePaths = false) -} +fun CodeInsightTestFixture.configureWithExtraFile(path: String, vararg extraNameParts: String = arrayOf(".Data")) { + val fileName = File(path).name -fun CodeInsightTestFixture.configureWithExtraFile(path: String, vararg extraNameParts: String = arrayOf(".Data"), relativePaths: Boolean = false) { - fun String.toFile(): File = if (relativePaths) File(testDataPath, this) else File(this) - - val noExtensionPath = FileUtil.getNameWithoutExtension(path) + val noExtensionPath = FileUtil.getNameWithoutExtension(fileName) val extensions = arrayOf("kt", "java") val extraPaths: List = extraNameParts .flatMap { extensions.map { ext -> "$noExtensionPath$it.$ext" } } - .filter { it.toFile().exists() } + .mapNotNull { File(testDataPath, it).takeIf { it.exists() }?.name } - configureByFiles(*(listOf(path) + extraPaths).toTypedArray()) + configureByFiles(*(listOf(fileName) + extraPaths).toTypedArray()) } @Suppress("unused") // Used in kotlin-ultimate -inline fun Any?.assertInstanceOf() = UsefulTestCase.assertInstanceOf(this, T::class.java) \ No newline at end of file +inline fun Any?.assertInstanceOf() = UsefulTestCase.assertInstanceOf(this, T::class.java) diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/weighers/AbstractCompletionWeigherTest.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/weighers/AbstractCompletionWeigherTest.kt index 199486c3686..8d7f5eaf003 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/weighers/AbstractCompletionWeigherTest.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/weighers/AbstractCompletionWeigherTest.kt @@ -17,15 +17,13 @@ package org.jetbrains.kotlin.idea.completion.test.weighers import com.intellij.codeInsight.completion.CompletionType -import org.jetbrains.kotlin.idea.completion.test.configureWithExtraFile -import org.jetbrains.kotlin.idea.completion.test.COMPLETION_TEST_DATA_BASE_PATH import org.jetbrains.kotlin.idea.completion.test.RELATIVE_COMPLETION_TEST_DATA_BASE_PATH +import org.jetbrains.kotlin.idea.completion.test.configureWithExtraFile import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.junit.Assert -import java.io.File abstract class AbstractCompletionWeigherTest(val completionType: CompletionType, val relativeTestDataPath: String) : KotlinLightCodeInsightFixtureTestCase() { fun doTest(path: String) { @@ -33,7 +31,7 @@ abstract class AbstractCompletionWeigherTest(val completionType: CompletionType, assert(path.startsWith(pathPrefix)) val relativePath = path.removePrefix(pathPrefix) - myFixture.configureWithExtraFile(relativePath, ".Data", ".Data1", ".Data2", ".Data3", ".Data4", ".Data5", ".Data6", relativePaths = true) + myFixture.configureWithExtraFile(relativePath, ".Data", ".Data1", ".Data2", ".Data3", ".Data4", ".Data5", ".Data6") val text = myFixture.editor.document.text @@ -43,8 +41,6 @@ abstract class AbstractCompletionWeigherTest(val completionType: CompletionType, myFixture.complete(completionType, InTextDirectivesUtils.getPrefixedInt(text, "// INVOCATION_COUNT:") ?: 1) myFixture.assertPreferredCompletionItems(InTextDirectivesUtils.getPrefixedInt(text, "// SELECTED:") ?: 0, *items) } - - override fun getTestDataPath() = File(COMPLETION_TEST_DATA_BASE_PATH, relativeTestDataPath).path + File.separator } abstract class AbstractBasicCompletionWeigherTest() : AbstractCompletionWeigherTest(CompletionType.BASIC, "weighers/basic") { diff --git a/idea/idea-gradle/build.gradle.kts b/idea/idea-gradle/build.gradle.kts index 1fac863ce44..f0c4f5d6fc4 100644 --- a/idea/idea-gradle/build.gradle.kts +++ b/idea/idea-gradle/build.gradle.kts @@ -2,7 +2,7 @@ apply { plugin("kotlin") } dependencies { - compileOnly(ideaSdkDeps("openapi", "idea", "external-system-rt")) + compileOnly(ideaSdkDeps("openapi", "idea", "external-system-rt", "forms_rt")) compileOnly(ideaPluginDeps("gradle-tooling-api", "gradle", "gradle-base-services", plugin = "gradle")) compileOnly(ideaPluginDeps("Groovy", plugin = "Groovy")) @@ -55,4 +55,6 @@ testsJar() projectTest { workingDir = rootDir -} \ No newline at end of file +} + +configureInstrumentation() diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/GradleKotlinFrameworkSupportProvider.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/GradleKotlinFrameworkSupportProvider.kt index 4b13993f84d..5a7a2a6d0b1 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/GradleKotlinFrameworkSupportProvider.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/GradleKotlinFrameworkSupportProvider.kt @@ -138,7 +138,7 @@ open class GradleKotlinJSFrameworkSupportProvider(frameworkTypeId: String = "KOT } open class GradleKotlinMPPCommonFrameworkSupportProvider : - GradleKotlinFrameworkSupportProvider("KOTLIN_MPP_COMMON", "Kotlin (Multiplatform - Common)", KotlinIcons.SMALL_LOGO) { + GradleKotlinFrameworkSupportProvider("KOTLIN_MPP_COMMON", "Kotlin (Multiplatform Common - Experimental)", KotlinIcons.SMALL_LOGO) { override fun getPluginId() = "kotlin-platform-common" override fun getDependencies(sdk: Sdk?) = listOf(MAVEN_COMMON_STDLIB_ID) @@ -148,7 +148,7 @@ open class GradleKotlinMPPCommonFrameworkSupportProvider : } class GradleKotlinMPPJavaFrameworkSupportProvider - : GradleKotlinJavaFrameworkSupportProvider("KOTLIN_MPP_JVM", "Kotlin (Multiplatform - JVM)") { + : GradleKotlinJavaFrameworkSupportProvider("KOTLIN_MPP_JVM", "Kotlin (Multiplatform JVM - Experimental)") { override fun getPluginId() = "kotlin-platform-jvm" override fun getDescription() = "JVM-specific code for a Kotlin multiplatform project" @@ -156,7 +156,7 @@ class GradleKotlinMPPJavaFrameworkSupportProvider } class GradleKotlinMPPJSFrameworkSupportProvider - : GradleKotlinJSFrameworkSupportProvider("KOTLIN_MPP_JS", "Kotlin (Multiplatform - JS)") { + : GradleKotlinJSFrameworkSupportProvider("KOTLIN_MPP_JS", "Kotlin (Multiplatform JS - Experimental)") { override fun getPluginId() = "kotlin-platform-js" override fun getDescription() = "JavaScript-specific code for a Kotlin multiplatform project" diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMultiplatformModuleBuilder.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMultiplatformModuleBuilder.kt index 3d44012c2ed..8ef5c51d8aa 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMultiplatformModuleBuilder.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/configuration/KotlinGradleMultiplatformModuleBuilder.kt @@ -40,7 +40,7 @@ class KotlinGradleMultiplatformModuleBuilder : GradleModuleBuilder() { override fun getNodeIcon() = KotlinIcons.SMALL_LOGO - override fun getPresentableName() = "Kotlin (Multiplatform)" + override fun getPresentableName() = "Kotlin (Multiplatform - Experimental)" override fun getDescription() = "Multiplatform projects allow reusing the same code between multiple platforms supported by Kotlin. Such projects are built with Gradle." diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/run/MultiplatformGradleProjectTaskRunner.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/run/MultiplatformGradleProjectTaskRunner.kt index 3b8d823dfb4..0909877e9ae 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/run/MultiplatformGradleProjectTaskRunner.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/run/MultiplatformGradleProjectTaskRunner.kt @@ -73,7 +73,7 @@ class MultiplatformGradleProjectTaskRunner : GradleProjectTaskRunner() { ) { val configuration = context.runConfiguration if (configuration is ModuleBasedConfiguration<*> && - (configuration.configurationModule is JavaRunConfigurationModule || configuration is JetRunConfiguration)) { + (configuration.configurationModule is JavaRunConfigurationModule || configuration is KotlinRunConfiguration)) { val module = configuration.configurationModule.module if (module?.targetPlatform == TargetPlatformKind.Common) { diff --git a/idea/idea-jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt b/idea/idea-jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt index 439a14b3a29..2b8938ea570 100644 --- a/idea/idea-jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt +++ b/idea/idea-jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt @@ -97,7 +97,7 @@ private fun readV2AndLaterConfig(element: Element): KotlinFacetSettings { val platformName = element.getAttributeValue("platform") val platformKind = TargetPlatformKind.ALL_PLATFORMS.firstOrNull { it.description == platformName } ?: TargetPlatformKind.DEFAULT_PLATFORM element.getChild("implements")?.let { - implementedModuleName = (element.content.firstOrNull() as? Text)?.textTrim + implementedModuleName = (it.content.firstOrNull() as? Text)?.textTrim } element.getChild("compilerSettings")?.let { compilerSettings = CompilerSettings() diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/coverage/KotlinCoverageExtension.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/coverage/KotlinCoverageExtension.kt index 98175f337ee..0966fd10c18 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/coverage/KotlinCoverageExtension.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/coverage/KotlinCoverageExtension.kt @@ -33,7 +33,7 @@ import com.intellij.psi.PsiClass import com.intellij.psi.PsiFile import com.intellij.psi.PsiNamedElement import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil -import org.jetbrains.kotlin.idea.run.JetRunConfiguration +import org.jetbrains.kotlin.idea.run.KotlinRunConfiguration import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtFile @@ -42,7 +42,7 @@ import java.io.File class KotlinCoverageExtension : JavaCoverageEngineExtension() { private val LOG = Logger.getInstance(KotlinCoverageExtension::class.java) - override fun isApplicableTo(conf: RunConfigurationBase?): Boolean = conf is JetRunConfiguration + override fun isApplicableTo(conf: RunConfigurationBase?): Boolean = conf is KotlinRunConfiguration override fun suggestQualifiedName(sourceFile: PsiFile, classes: Array, names: MutableSet): Boolean { if (sourceFile is KtFile) { diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/KotlinMultiplatformJUnitRecognizer.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/KotlinMultiplatformJUnitRecognizer.kt index bfebf76b95c..fd0b61faf23 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/KotlinMultiplatformJUnitRecognizer.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/run/KotlinMultiplatformJUnitRecognizer.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor -import org.jetbrains.kotlin.idea.highlighter.allImplementingCompatibleModules +import org.jetbrains.kotlin.idea.facet.implementingDescriptors import org.jetbrains.kotlin.idea.highlighter.markers.actualsFor import org.jetbrains.kotlin.idea.project.targetPlatform import org.jetbrains.kotlin.idea.util.module @@ -41,7 +41,7 @@ class KotlinMultiplatformJUnitRecognizer : JUnitRecognizer() { if (origin.module?.targetPlatform !is TargetPlatformKind.Common) return false val moduleDescriptor = origin.containingKtFile.findModuleDescriptor() - val implModules = moduleDescriptor.allImplementingCompatibleModules + val implModules = moduleDescriptor.implementingDescriptors if (implModules.isEmpty()) return false val bindingContext = origin.analyze(BodyResolveMode.PARTIAL) diff --git a/idea/idea-live-templates/src/org/jetbrains/kotlin/idea/liveTemplates/macro/AnonymousTemplateEditingListener.kt b/idea/idea-live-templates/src/org/jetbrains/kotlin/idea/liveTemplates/macro/AnonymousTemplateEditingListener.kt index cf82dc21af1..f971d8c4243 100644 --- a/idea/idea-live-templates/src/org/jetbrains/kotlin/idea/liveTemplates/macro/AnonymousTemplateEditingListener.kt +++ b/idea/idea-live-templates/src/org/jetbrains/kotlin/idea/liveTemplates/macro/AnonymousTemplateEditingListener.kt @@ -38,8 +38,8 @@ internal class AnonymousTemplateEditingListener(private val psiFile: PsiFile, pr private var classRef: KtReferenceExpression? = null private var classDescriptor: ClassDescriptor? = null - override fun currentVariableChanged(templateState: TemplateState?, template: Template?, oldIndex: Int, newIndex: Int) { - assert(templateState!!.template != null) + override fun currentVariableChanged(templateState: TemplateState, template: Template?, oldIndex: Int, newIndex: Int) { + if (templateState.template == null) return val variableRange = templateState.getVariableRange("SUPERTYPE") ?: return val name = psiFile.findElementAt(variableRange.startOffset) if (name != null && name.parent is KtReferenceExpression) { diff --git a/idea/idea-live-templates/testData/anonymous_1.exp.kt b/idea/idea-live-templates/testData/anonymous_1.exp.kt index 4a7c30f5d47..292e4969fc8 100644 --- a/idea/idea-live-templates/testData/anonymous_1.exp.kt +++ b/idea/idea-live-templates/testData/anonymous_1.exp.kt @@ -3,7 +3,7 @@ import javax.swing.SwingUtilities fun main(args : Array) { SwingUtilities.invokeLater(object : Runnable { override fun run() { - throw UnsupportedOperationException() + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } }) } diff --git a/idea/idea-live-templates/testData/serr.exp.kt b/idea/idea-live-templates/testData/serr.exp.kt index 94baca416ae..19101ee4a36 100644 --- a/idea/idea-live-templates/testData/serr.exp.kt +++ b/idea/idea-live-templates/testData/serr.exp.kt @@ -1,3 +1,3 @@ fun main(args : Array) { - System.err?.println() + System.err.println() } diff --git a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt index ac9e7c5cf78..df802db22e0 100644 --- a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt +++ b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt @@ -21,7 +21,6 @@ import com.intellij.codeInsight.template.TemplateManager import com.intellij.codeInsight.template.impl.TemplateManagerImpl import com.intellij.codeInsight.template.impl.TemplateState import com.intellij.ide.DataManager -import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.command.CommandProcessor import com.intellij.openapi.editor.actionSystem.EditorActionManager import com.intellij.testFramework.LightProjectDescriptor @@ -85,7 +84,7 @@ class LiveTemplatesTest : KotlinLightCodeInsightFixtureTestCase() { fun testSoutv() { start() - assertStringItems("ASSERTIONS_ENABLED", "args", "defaultBlockSize", "defaultBufferSize", "minimumBlockSize", "x", "y") + assertStringItems("DEFAULT_BUFFER_SIZE", "args", "x", "y") typeAndNextTab("y") checkAfter() @@ -190,7 +189,7 @@ class LiveTemplatesTest : KotlinLightCodeInsightFixtureTestCase() { fun testIter() { start() - assertStringItems("args", "myList", "o", "str", "stream") + assertStringItems("args", "myList", "o", "str") type("args") nextTab(2) diff --git a/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt b/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt index 48d89f6458a..03c2eb62fee 100644 --- a/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt +++ b/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt @@ -23,12 +23,16 @@ import com.intellij.openapi.projectRoots.ProjectJdkTable import com.intellij.openapi.roots.LibraryOrderEntry import com.intellij.openapi.roots.ModuleRootManager import com.intellij.openapi.roots.impl.libraries.LibraryEx +import junit.framework.TestCase import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments import org.jetbrains.kotlin.config.* +import org.jetbrains.kotlin.idea.caches.resolve.analyzeAndGetResult import org.jetbrains.kotlin.idea.facet.KotlinFacet import org.jetbrains.kotlin.idea.framework.CommonLibraryKind import org.jetbrains.kotlin.idea.framework.JSLibraryKind +import org.jetbrains.kotlin.idea.refactoring.toPsiFile +import org.jetbrains.kotlin.psi.KtFile import org.junit.Assert import java.io.File @@ -735,7 +739,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib - 1.1.0 + $kotlinVersion @@ -783,7 +787,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib-js - 1.1.0 + $kotlinVersion @@ -831,7 +835,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib-common - 1.1.0 + $kotlinVersion @@ -879,7 +883,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib - 1.1.0 + $kotlinVersion @@ -927,7 +931,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib-js - 1.1.0 + $kotlinVersion @@ -975,7 +979,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib-common - 1.1.0 + $kotlinVersion @@ -1023,12 +1027,12 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib-common - 1.1.0 + $kotlinVersion org.jetbrains.kotlin kotlin-stdlib-js - 1.1.0 + $kotlinVersion @@ -1081,7 +1085,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib - 1.1.0 + $kotlinVersion @@ -1123,7 +1127,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib-js - 1.1.0 + $kotlinVersion @@ -1165,7 +1169,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib-common - 1.1.0 + $kotlinVersion @@ -1211,7 +1215,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib - 1.1.0 + $kotlinVersion @@ -1259,7 +1263,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib-js - 1.1.0 + $kotlinVersion @@ -1307,7 +1311,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib-common - 1.1.0 + $kotlinVersion @@ -1355,7 +1359,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-stdlib - 1.1.0 + $kotlinVersion @@ -1379,7 +1383,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { org.jetbrains.kotlin kotlin-maven-allopen - 1.1.0 + $kotlinVersion @@ -1405,7 +1409,8 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { listOf("plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.stereotype.Component", "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.transaction.annotation.Transactional", "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.scheduling.annotation.Async", - "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.cache.annotation.Cacheable"), + "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.cache.annotation.Cacheable", + "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.boot.test.context.SpringBootTest"), compilerArguments!!.pluginOptions!!.toList() ) } @@ -1787,6 +1792,217 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { } } + fun testProductionOnTestDependency() { + createProjectSubDirs( + "module-with-java/src/main/java", + "module-with-java/src/test/java", + "module-with-kotlin/src/main/kotlin", + "module-with-kotlin/src/test/kotlin" + ) + + val dummyFile = createProjectSubFile( + "module-with-kotlin/src/main/kotlin/foo/dummy.kt", + """ + package foo + + fun dummy() { + } + + """.trimIndent() + ) + + val pomA = createModulePom( + "module-with-java", + """ + + test-group + mvnktest + 0.0.0.0-SNAPSHOT + + + module-with-java + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.6 + + + + test-jar + + + + + + + """.trimIndent() + ) + + val pomB = createModulePom( + "module-with-kotlin", + """ + + test-group + mvnktest + 0.0.0.0-SNAPSHOT + + + module-with-kotlin + + + 1.1.4 + 1.8 + true + + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${"$"}{kotlin.version} + + + org.jetbrains.kotlin + kotlin-runtime + ${"$"}{kotlin.version} + + + org.jetbrains.kotlin + kotlin-reflect + ${"$"}{kotlin.version} + + + + test-group + module-with-java + + + + test-group + module-with-java + test-jar + compile + + + + + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${"$"}{kotlin.version} + + + compile + compile + + + ${"$"}{project.basedir}/src/main/kotlin + ${"$"}{project.basedir}/src/main/java + + + + + test-compile + test-compile + + + ${"$"}{project.basedir}/src/test/kotlin + ${"$"}{project.basedir}/src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + + + default-compile + none + + + + default-testCompile + none + + + java-compile + compile + compile + + + java-test-compile + test-compile + testCompile + + + + + + """.trimIndent() + ) + + val pomMain = createModulePom( + "", + """ + test-group + mvnktest + 0.0.0.0-SNAPSHOT + + pom + + + 1.1.4 + 1.8 + true + + + + module-with-java + module-with-kotlin + + + + + + test-group + module-with-kotlin + ${"$"}{project.version} + + + test-group + module-with-java + ${"$"}{project.version} + + + test-group + module-with-java + ${"$"}{project.version} + test-jar + test + + + + """.trimIndent() + ) + + importProjects(pomMain, pomA, pomB) + + assertModules("module-with-kotlin", "module-with-java", "mvnktest") + + val dependencies = (dummyFile.toPsiFile(myProject) as KtFile).analyzeAndGetResult().moduleDescriptor.allDependencyModules + TestCase.assertTrue(dependencies.any { it.name.asString() == "" }) + TestCase.assertTrue(dependencies.any { it.name.asString() == "" }) + } + private fun assertImporterStatePresent() { assertNotNull("Kotlin importer component is not present", myTestFixture.module.getComponent(KotlinImporterComponent::class.java)) } diff --git a/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/MavenTestCase.java b/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/MavenTestCase.java index d25f11e2ad2..c8918d34553 100644 --- a/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/MavenTestCase.java +++ b/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/MavenTestCase.java @@ -47,11 +47,35 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.Modifier; +import java.net.HttpURLConnection; +import java.net.URL; import java.util.*; import java.util.List; import java.util.concurrent.TimeUnit; public abstract class MavenTestCase extends UsefulTestCase { + + private static final String mavenMirrorUrl = System.getProperty("idea.maven.test.mirror", + // use JB maven proxy server for internal use by default, see details at + // https://confluence.jetbrains.com/display/JBINT/Maven+proxy+server + "http://maven.labs.intellij.net/repo1"); + private static boolean mirrorDiscoverable = false; + + static { + try { + URL url = new URL(mavenMirrorUrl); + HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); + urlConnection.setConnectTimeout(1000); + int responseCode = urlConnection.getResponseCode(); + if(responseCode < 400) { + mirrorDiscoverable = true; + } + } + catch (Exception e) { + mirrorDiscoverable = false; + } + } + private File ourTempDir; protected IdeaProjectTestFixture myTestFixture; @@ -319,16 +343,22 @@ public abstract class MavenTestCase extends UsefulTestCase { } private static String createSettingsXmlContent(String content) { - String mirror = System.getProperty("idea.maven.test.mirror", - // use JB maven proxy server for internal use by default, see details at - // https://confluence.jetbrains.com/display/JBINT/Maven+proxy+server - "http://maven.labs.intellij.net/repo1"); + + if (!mirrorDiscoverable) { + System.err.println("Maven mirror at " + mavenMirrorUrl + " not reachable, so not using it."); + + return "" + + content + + ""; + } + + System.out.println("Using Maven mirror at " + mavenMirrorUrl); return "" + content + "" + " " + " jb-central-proxy" + - " " + mirror + "" + + " " + mavenMirrorUrl + "" + " external:*" + " " + "" + diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightCodeInsightFixtureTestCase.kt b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightCodeInsightFixtureTestCase.kt index b5938618e1f..d5aec1156d8 100644 --- a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightCodeInsightFixtureTestCase.kt +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightCodeInsightFixtureTestCase.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,8 +23,11 @@ import com.intellij.openapi.actionSystem.ActionPlaces import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.Presentation import com.intellij.openapi.actionSystem.ex.ActionManagerEx +import com.intellij.openapi.application.WriteAction import com.intellij.openapi.editor.ex.EditorEx +import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl import com.intellij.openapi.module.Module +import com.intellij.openapi.project.Project import com.intellij.openapi.startup.StartupManager import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.text.StringUtil @@ -32,7 +35,10 @@ import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess import com.intellij.testFramework.LightProjectDescriptor import com.intellij.testFramework.LoggedErrorProcessor import org.apache.log4j.Logger +import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode +import org.jetbrains.kotlin.idea.facet.configureFacet +import org.jetbrains.kotlin.idea.facet.getOrCreateFacet import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.TestMetadata @@ -171,3 +177,19 @@ abstract class KotlinLightCodeInsightFixtureTestCase : KotlinLightCodeInsightFix return this::class.findAnnotation()?.value ?: super.getTestDataPath() } } + +fun configureLanguageVersion(fileText: String, project: Project, module: Module) { + val version = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// LANGUAGE_VERSION: ") + if (version != null) { + val accessToken = WriteAction.start() + try { + val modelsProvider = IdeModifiableModelsProviderImpl(project) + val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false) + facet.configureFacet(version, LanguageFeature.State.DISABLED, null, modelsProvider) + modelsProvider.commit() + } + finally { + accessToken.finish() + } + } +} diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightJava9ModulesCodeInsightFixtureTestCase.kt b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightJava9ModulesCodeInsightFixtureTestCase.kt new file mode 100644 index 00000000000..c0f1ecafa87 --- /dev/null +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightJava9ModulesCodeInsightFixtureTestCase.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.test + +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.testFramework.EditorTestUtil +import com.intellij.testFramework.LightProjectDescriptor +import com.intellij.testFramework.VfsTestUtil +import org.intellij.lang.annotations.Language +import org.jetbrains.kotlin.idea.test.KotlinMultiModuleJava9ProjectDescriptor.ModuleDescriptor + +abstract class KotlinLightJava9ModulesCodeInsightFixtureTestCase : KotlinLightCodeInsightFixtureTestCase() { + override fun getProjectDescriptor(): LightProjectDescriptor = KotlinMultiModuleJava9ProjectDescriptor + + override fun tearDown() { + KotlinMultiModuleJava9ProjectDescriptor.cleanupSourceRoots() + super.tearDown() + } + + protected fun addFile(path: String, text: String, module: ModuleDescriptor = ModuleDescriptor.MAIN): VirtualFile = + VfsTestUtil.createFile(module.root(), path, text) + + protected fun addKotlinFile(path: String, @Language("kotlin") text: String, module: ModuleDescriptor = ModuleDescriptor.MAIN): VirtualFile = + addFile(path, text.toTestData(), module) + + protected fun addJavaFile(path: String, @Language("java") text: String, module: ModuleDescriptor = ModuleDescriptor.MAIN): VirtualFile = + addFile(path, text.toTestData(), module) + + protected fun moduleInfo(@Language("JAVA") text: String, module: ModuleDescriptor = ModuleDescriptor.MAIN) = + addFile("module-info.java", text.toTestData(), module) + + protected fun checkModuleInfo(@Language("JAVA") text: String) = + myFixture.checkResult("module-info.java", text.toTestData(), false) +} + +private const val IDENTIFIER_CARET = "CARET" +private const val COMMENT_CARET_CHAR = "/*|*/" +private const val COMMENT_CARET = "/*CARET*/" +private val ADDITIONAL_CARET_MARKERS = arrayOf(IDENTIFIER_CARET, COMMENT_CARET_CHAR, COMMENT_CARET) + +private fun String.toTestData(): String = + ADDITIONAL_CARET_MARKERS.fold(trimIndent()) { result, marker -> result.replace(marker, EditorTestUtil.CARET_TAG, ignoreCase = true) } \ No newline at end of file diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightPlatformCodeInsightFixtureTestCase.kt b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightPlatformCodeInsightFixtureTestCase.kt index fc2ca98d60f..23819654002 100644 --- a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightPlatformCodeInsightFixtureTestCase.kt +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinLightPlatformCodeInsightFixtureTestCase.kt @@ -22,6 +22,8 @@ import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode import org.jetbrains.kotlin.test.KotlinTestUtils +import org.jetbrains.kotlin.test.TestMetadata +import kotlin.reflect.full.findAnnotation abstract class KotlinLightPlatformCodeInsightFixtureTestCase: LightPlatformCodeInsightFixtureTestCase() { private var kotlinInternalModeOriginalValue: Boolean = false @@ -44,4 +46,6 @@ abstract class KotlinLightPlatformCodeInsightFixtureTestCase: LightPlatformCodeI super.tearDown() } } -} \ No newline at end of file + + override fun getTestDataPath(): String = this::class.findAnnotation()?.value ?: super.getTestDataPath() +} diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinMultiModuleJava9ProjectDescriptor.kt b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinMultiModuleJava9ProjectDescriptor.kt new file mode 100644 index 00000000000..00249f3d6eb --- /dev/null +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinMultiModuleJava9ProjectDescriptor.kt @@ -0,0 +1,118 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.test + +import com.intellij.openapi.application.runWriteAction +import com.intellij.openapi.module.Module +import com.intellij.openapi.module.ModuleManager +import com.intellij.openapi.project.Project +import com.intellij.openapi.projectRoots.Sdk +import com.intellij.openapi.roots.* +import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.openapi.vfs.ex.temp.TempFileSystem +import com.intellij.pom.java.LanguageLevel +import com.intellij.testFramework.LightPlatformTestCase +import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor +import org.jetbrains.jps.model.java.JavaSourceRootType +import org.jetbrains.kotlin.test.TestJdkKind + +/** + * Dependencies: 'main' -> 'm2', 'main' -> 'm4', 'main' -> 'm5', 'main' -> 'm6' => 'm7' + */ +object KotlinMultiModuleJava9ProjectDescriptor : DefaultLightProjectDescriptor() { + enum class ModuleDescriptor(internal val moduleName: String, internal val rootName: String) { + // Dependent for: none, Depends on: M2, M4, M5, M6 + MAIN(TEST_MODULE_NAME, "/not_used/"), + + // Dependent for: MAIN, Depends on: none + M2("${TEST_MODULE_NAME}_m2", "src_m2"), + + // Dependent for: none, Depends on: none + M3("${TEST_MODULE_NAME}_m3", "src_m3"), + + // Dependent for: MAIN, Depends on: none + M4("${TEST_MODULE_NAME}_m4", "src_m4"), + + // Dependent for: MAIN, Depends on: none + M5("${TEST_MODULE_NAME}_m5", "src_m5"), + + // Dependent for: MAIN, Depends on: M7 + M6("${TEST_MODULE_NAME}_m6", "src_m6"), + + // Dependent for: M6, Depends on: none + M7("${TEST_MODULE_NAME}_m7", "src_m7"); + + fun root(): VirtualFile = + if (this == MAIN) LightPlatformTestCase.getSourceRoot() else TempFileSystem.getInstance().findFileByPath("/$rootName")!! + + fun testRoot(): VirtualFile? = + if (this == MAIN) TempFileSystem.getInstance().findFileByPath("/test_src")!! else null + } + + override fun getSdk(): Sdk = PluginTestCaseBase.jdk(TestJdkKind.FULL_JDK_9) + + override fun setUpProject(project: Project, handler: SetupHandler) { + super.setUpProject(project, handler) + + runWriteAction { + val main = ModuleManager.getInstance(project).findModuleByName(TEST_MODULE_NAME)!! + + val m2 = makeModule(project, ModuleDescriptor.M2) + ModuleRootModificationUtil.addDependency(main, m2) + + makeModule(project, ModuleDescriptor.M3) + + val m4 = makeModule(project, ModuleDescriptor.M4) + ModuleRootModificationUtil.addDependency(main, m4) + + val m5 = makeModule(project, ModuleDescriptor.M5) + ModuleRootModificationUtil.addDependency(main, m5) + + val m6 = makeModule(project, ModuleDescriptor.M6) + ModuleRootModificationUtil.addDependency(main, m6) + + val m7 = makeModule(project, ModuleDescriptor.M7) + ModuleRootModificationUtil.addDependency(m6, m7, DependencyScope.COMPILE, true) + } + } + + private fun makeModule(project: Project, descriptor: ModuleDescriptor): Module { + val path = FileUtil.join(FileUtil.getTempDirectory(), "${descriptor.moduleName}.iml") + val module = createModule(project, path) + val sourceRoot = createSourceRoot(module, descriptor.rootName) + createContentEntry(module, sourceRoot) + return module + } + + override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry) { + model.getModuleExtension(LanguageLevelModuleExtension::class.java).languageLevel = LanguageLevel.JDK_1_9 + if (module.name == TEST_MODULE_NAME) { + val testRoot = createSourceRoot(module, "test_src") + registerSourceRoot(module.project, testRoot) + model.addContentEntry(testRoot).addSourceFolder(testRoot, JavaSourceRootType.TEST_SOURCE) + } + } + + fun cleanupSourceRoots() = runWriteAction { + ModuleDescriptor.values().asSequence() + .filter { it != ModuleDescriptor.MAIN } + .flatMap { it.root().children.asSequence() } + .plus(ModuleDescriptor.MAIN.testRoot()!!.children.asSequence()) + .forEach { it.delete(this) } + } +} \ No newline at end of file diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/PluginTestCaseBase.java b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/PluginTestCaseBase.java index f91c1e84f36..79d818b979b 100644 --- a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/PluginTestCaseBase.java +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/PluginTestCaseBase.java @@ -16,11 +16,17 @@ package org.jetbrains.kotlin.idea.test; +import com.intellij.openapi.Disposable; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.projectRoots.JavaSdk; +import com.intellij.openapi.projectRoots.ProjectJdkTable; import com.intellij.openapi.projectRoots.Sdk; +import com.intellij.openapi.projectRoots.impl.JavaSdkImpl; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.TestOnly; import org.jetbrains.kotlin.test.KotlinTestUtils; import org.jetbrains.kotlin.test.TestJdkKind; @@ -38,6 +44,12 @@ public class PluginTestCaseBase { return KotlinTestUtils.getHomeDirectory() + TEST_DATA_PROJECT_RELATIVE; } + @NotNull + @TestOnly + private static Sdk createMockJdk(@NotNull String name, String path) { + return ((JavaSdkImpl)JavaSdk.getInstance()).createMockJdk(name, path, false); + } + @NotNull private static Sdk getSdk(String sdkHome, String name) { return JavaSdk.getInstance().createJdk(name, sdkHome, true); @@ -48,6 +60,23 @@ public class PluginTestCaseBase { return getSdk("compiler/testData/mockJDK/jre", "Mock JDK"); } + @NotNull + public static Sdk mockJdk6() { + return getSdk("compiler/testData/mockJDK/jre", "1.6"); + } + + @NotNull + public static Sdk mockJdk8() { + // Using JDK 6, but with version 1.8 + return getSdk("compiler/testData/mockJDK/jre", "1.8"); + } + + @TestOnly + @NotNull + public static Sdk mockJdk9() { + return createMockJdk("9", "compiler/testData/mockJDK9/jre"); + } + @NotNull public static Sdk fullJdk() { String javaHome = System.getProperty("java.home"); @@ -75,4 +104,14 @@ public class PluginTestCaseBase { public static boolean isAllFilesPresentTest(@NotNull String testName) { return StringUtil.startsWithIgnoreCase(testName, "allFilesPresentIn"); } + + @TestOnly + public static void clearSdkTable(@NotNull Disposable disposable) { + Disposer.register(disposable, () -> ApplicationManager.getApplication().runWriteAction(() -> { + ProjectJdkTable jdkTable = ProjectJdkTable.getInstance(); + for (Sdk sdk : jdkTable.getAllJdks()) { + jdkTable.removeJdk(sdk); + } + })); + } } diff --git a/idea/resources/inspectionDescriptions/MigrateDiagnosticSuppression.html b/idea/resources/inspectionDescriptions/MigrateDiagnosticSuppression.html new file mode 100644 index 00000000000..d10e30878da --- /dev/null +++ b/idea/resources/inspectionDescriptions/MigrateDiagnosticSuppression.html @@ -0,0 +1,8 @@ + + +This inspection reports suppression with old diagnostic names, for example: +
+  @Suppress("HEADER_WITHOUT_IMPLEMENTATION")
+
+ + \ No newline at end of file diff --git a/idea/resources/inspectionDescriptions/ReplaceArrayEqualityOpWithArraysEquals.html b/idea/resources/inspectionDescriptions/ReplaceArrayEqualityOpWithArraysEquals.html index 74bf53dda29..f7d5dce04b7 100644 --- a/idea/resources/inspectionDescriptions/ReplaceArrayEqualityOpWithArraysEquals.html +++ b/idea/resources/inspectionDescriptions/ReplaceArrayEqualityOpWithArraysEquals.html @@ -1,5 +1,5 @@ -This inspection detects '==' operator for arrays that should be replaced with 'Arrays.equals' +This inspection detects '==' or '!=' operator for arrays that should be replaced with 'Arrays.equals' \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ReplaceArrayEqualityOpWithArraysEqualsIntention/description.html b/idea/resources/intentionDescriptions/ReplaceArrayEqualityOpWithArraysEqualsIntention/description.html index 4d248a19655..ae679a64594 100644 --- a/idea/resources/intentionDescriptions/ReplaceArrayEqualityOpWithArraysEqualsIntention/description.html +++ b/idea/resources/intentionDescriptions/ReplaceArrayEqualityOpWithArraysEqualsIntention/description.html @@ -1,5 +1,5 @@ -This intention replace '==' operator for arrays with 'Arrays.equals' +This intention replace '==' or '!=' operator for arrays with 'Arrays.equals' \ No newline at end of file diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index e1e06bfed0a..bb596d2aa6a 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -629,7 +629,7 @@ - + @@ -1740,6 +1740,7 @@ groupPath="Kotlin" groupName="Redundant constructs" enabledByDefault="true" + cleanupTool="true" level="WEAK WARNING" language="kotlin" /> @@ -2120,6 +2121,7 @@ groupPath="Kotlin" groupName="Redundant constructs" enabledByDefault="true" + cleanupTool="true" level="WEAK WARNING" language="kotlin" /> @@ -2129,6 +2131,7 @@ groupPath="Kotlin" groupName="Redundant constructs" enabledByDefault="true" + cleanupTool="true" level="INFO" language="kotlin" /> @@ -2202,6 +2205,7 @@ groupPath="Kotlin" groupName="Redundant constructs" enabledByDefault="true" + cleanupTool="true" level="WEAK WARNING" language="kotlin" /> @@ -2211,6 +2215,7 @@ groupPath="Kotlin" groupName="Redundant constructs" enabledByDefault="true" + cleanupTool="true" level="WEAK WARNING" language="kotlin" /> @@ -2346,6 +2351,7 @@ groupPath="Kotlin" groupName="Style issues" enabledByDefault="true" + cleanupTool="true" level="INFO" language="kotlin" /> @@ -2472,6 +2478,7 @@ groupPath="Kotlin" groupName="Redundant constructs" enabledByDefault="true" + cleanupTool="true" level="WEAK WARNING" language="kotlin" /> @@ -2571,6 +2578,7 @@ groupPath="Kotlin" groupName="Redundant constructs" enabledByDefault="true" + cleanupTool="true" level="WEAK WARNING" language="kotlin" /> @@ -2604,6 +2612,16 @@ language="kotlin" /> + + diff --git a/idea/src/org/jetbrains/kotlin/idea/ProgressUtil.kt b/idea/src/org/jetbrains/kotlin/idea/ProgressUtil.kt index e3d51869b52..4450c3ea973 100644 --- a/idea/src/org/jetbrains/kotlin/idea/ProgressUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/ProgressUtil.kt @@ -22,37 +22,21 @@ import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.progress.util.ProgressIndicatorUtils import com.intellij.openapi.project.Project -fun runInReadActionWithWriteActionPriorityWithPCE(f: () -> T): T { - var r: T? = null - if (!with(ApplicationManager.getApplication()) { isDispatchThread && isUnitTestMode }) { - val complete = ProgressIndicatorUtils.runInReadActionWithWriteActionPriority { - r = f() - } - - // There is a write action in progress or pending, so no point in counting the result - if (!complete) throw ProcessCanceledException() - } - else { - r = f() - } - - return r!! -} +fun runInReadActionWithWriteActionPriorityWithPCE(f: () -> T): T = + runInReadActionWithWriteActionPriority(f) ?: throw ProcessCanceledException() fun runInReadActionWithWriteActionPriority(f: () -> T): T? { - var r: T? = null - if (!with(ApplicationManager.getApplication()) { isDispatchThread && isUnitTestMode }) { - val complete = ProgressIndicatorUtils.runInReadActionWithWriteActionPriority { - r = f() - } - - if (!complete) return null + if (with(ApplicationManager.getApplication()) { isDispatchThread && isUnitTestMode }) { + return f() } - else { + + var r: T? = null + val complete = ProgressIndicatorUtils.runInReadActionWithWriteActionPriority { r = f() } - return r + if (!complete) return null + return r!! } fun Project.runSynchronouslyWithProgress(progressTitle: String, canBeCanceled: Boolean, action: () -> T): T? { diff --git a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java b/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java index 936e6548464..3bc2d18255c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java +++ b/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java @@ -443,10 +443,10 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co ComparingUtils.isModified(keepAliveCheckBox, compilerWorkspaceSettings.getEnableDaemon()))) || ComparingUtils.isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.getSourceMap()) || - ComparingUtils.isModified(outputPrefixFile, k2jsCompilerArguments.getOutputPrefix()) || - ComparingUtils.isModified(outputPostfixFile, k2jsCompilerArguments.getOutputPostfix()) || + ComparingUtils.isModified(outputPrefixFile, StringUtil.notNullize(k2jsCompilerArguments.getOutputPrefix())) || + ComparingUtils.isModified(outputPostfixFile, StringUtil.notNullize(k2jsCompilerArguments.getOutputPostfix())) || !getSelectedModuleKind().equals(getModuleKindOrDefault(k2jsCompilerArguments.getModuleKind())) || - ComparingUtils.isModified(sourceMapPrefix, k2jsCompilerArguments.getSourceMapPrefix()) || + ComparingUtils.isModified(sourceMapPrefix, StringUtil.notNullize(k2jsCompilerArguments.getSourceMapPrefix())) || !getSelectedSourceMapSourceEmbedding().equals( getSourceMapSourceEmbeddingOrDefault(k2jsCompilerArguments.getSourceMapEmbedSources())) || !getSelectedJvmVersion().equals(getJvmVersionOrDefault(k2jvmCompilerArguments.getJvmTarget())); diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInProjectUtils.kt b/idea/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInProjectUtils.kt index 6050707fbec..a97fc0f3991 100644 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInProjectUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInProjectUtils.kt @@ -37,6 +37,7 @@ import org.jetbrains.kotlin.idea.configuration.ui.notifications.ConfigureKotlinN import org.jetbrains.kotlin.idea.framework.JSLibraryKind import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.idea.util.projectStructure.allModules +import org.jetbrains.kotlin.idea.versions.SuppressNotificationState import org.jetbrains.kotlin.idea.versions.getKotlinJvmRuntimeMarkerClass import org.jetbrains.kotlin.idea.versions.hasKotlinJsKjsmFile import org.jetbrains.kotlin.idea.vfilefinder.IDEVirtualFileFinder @@ -132,7 +133,7 @@ fun getConfigurableModulesWithKotlinFiles(project: Project): List = emptyList()) { val notificationString = DumbService.getInstance(project).runReadActionInSmartMode(Computable { val modules = getConfigurableModulesWithKotlinFiles(project).exclude(excludeModules) - if (modules.all(::isModuleConfigured)) + if (modules.all(::isNotConfiguredNotificationRequired)) null else ConfigureKotlinNotification.getNotificationString(project, excludeModules) @@ -153,6 +154,10 @@ fun showConfigureKotlinNotificationIfNeeded(project: Project, excludeModules: Li } } +fun isNotConfiguredNotificationRequired(moduleGroup: ModuleSourceRootGroup): Boolean { + return !SuppressNotificationState.isKotlinNotConfiguredSuppressed(moduleGroup) && isModuleConfigured(moduleGroup) +} + fun getAbleToRunConfigurators(project: Project): Collection { val modules = getConfigurableModules(project) @@ -253,7 +258,7 @@ fun isEap(version: String): Boolean { } fun useEapRepository(minorKotlinVersion: Int, version: String): Boolean { - return Regex("1\\.$minorKotlinVersion(\\.\\d)?-[A-Za-z][A-Za-z0-9-]*").matches(version) && + return Regex("1\\.$minorKotlinVersion(\\.\\d\\d?)?-[A-Za-z][A-Za-z0-9-]*").matches(version) && !version.startsWith("1.$minorKotlinVersion.0-dev") } diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinNotificationManager.kt b/idea/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinNotificationManager.kt index e0ad5899781..8dbc8488851 100644 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinNotificationManager.kt +++ b/idea/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinNotificationManager.kt @@ -76,7 +76,7 @@ fun checkHideNonConfiguredNotifications(project: Project) { if (!checkInProgress.compareAndSet(false, true)) return@executeOnPooledThread DumbService.getInstance(project).waitForSmartMode() - if (getConfigurableModulesWithKotlinFiles(project).all(::isModuleConfigured)) { + if (getConfigurableModulesWithKotlinFiles(project).all(::isNotConfiguredNotificationRequired)) { ApplicationManager.getApplication().invokeLater { ConfigureKotlinNotificationManager.expireOldNotifications(project) checkInProgress.set(false) diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinJavaModuleConfigurator.kt b/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinJavaModuleConfigurator.kt index 9a2a31791aa..5ba7adf34f5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinJavaModuleConfigurator.kt +++ b/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinJavaModuleConfigurator.kt @@ -36,6 +36,7 @@ import org.jetbrains.kotlin.idea.framework.JavaRuntimeLibraryDescription import org.jetbrains.kotlin.idea.framework.JsLibraryStdDetectionUtil import org.jetbrains.kotlin.idea.util.projectStructure.allModules import org.jetbrains.kotlin.idea.util.projectStructure.sdk +import org.jetbrains.kotlin.idea.util.projectStructure.version import org.jetbrains.kotlin.idea.versions.LibraryJarDescriptor import org.jetbrains.kotlin.idea.versions.isKotlinJavaRuntime import org.jetbrains.kotlin.resolve.TargetPlatform @@ -76,7 +77,7 @@ open class KotlinJavaModuleConfigurator internal constructor() : KotlinWithLibra LibraryJarDescriptor.REFLECT_JAR, LibraryJarDescriptor.RUNTIME_SRC_JAR, LibraryJarDescriptor.TEST_JAR) - val sdkVersion = sdk?.let { JavaSdk.getInstance().getVersion(it) } ?: return result + val sdkVersion = sdk?.version ?: return result if (sdkVersion.isAtLeast(JavaSdkVersion.JDK_1_7)) { result += listOf(LibraryJarDescriptor.RUNTIME_JRE7_JAR, LibraryJarDescriptor.RUNTIME_JRE7_SOURCES_JAR) } @@ -93,7 +94,7 @@ open class KotlinJavaModuleConfigurator internal constructor() : KotlinWithLibra override fun configureKotlinSettings(modules: List) { val project = modules.firstOrNull()?.project ?: return val canChangeProjectSettings = project.allModules().all { - it.sdk?.let { JavaSdk.getInstance().getVersion(it)?.isAtLeast(JavaSdkVersion.JDK_1_8) } ?: true + it.sdk?.version?.isAtLeast(JavaSdkVersion.JDK_1_8) ?: true } if (canChangeProjectSettings) { Kotlin2JvmCompilerArgumentsHolder.getInstance(project).update { @@ -102,8 +103,8 @@ open class KotlinJavaModuleConfigurator internal constructor() : KotlinWithLibra } else { for (module in modules) { - val hasJdk8 = module.sdk?.let { JavaSdk.getInstance().getVersion(it)?.isAtLeast(JavaSdkVersion.JDK_1_8) } - if (hasJdk8 == true) { + val sdkVersion = module.sdk?.version + if (sdkVersion != null && sdkVersion.isAtLeast(JavaSdkVersion.JDK_1_8)) { val modelsProvider = IdeModifiableModelsProviderImpl(project) val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false, commitModel = true) val facetSettings = facet.configuration.settings diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinSetupEnvironmentNotificationProvider.kt b/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinSetupEnvironmentNotificationProvider.kt index 339707a0bca..e4d5b85f001 100644 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinSetupEnvironmentNotificationProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinSetupEnvironmentNotificationProvider.kt @@ -41,6 +41,7 @@ import org.jetbrains.kotlin.idea.KotlinFileType import org.jetbrains.kotlin.idea.KotlinLanguage import org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerComponent import org.jetbrains.kotlin.idea.util.application.runWriteAction +import org.jetbrains.kotlin.idea.versions.SuppressNotificationState import org.jetbrains.kotlin.idea.versions.UnsupportedAbiVersionNotificationPanelProvider import org.jetbrains.kotlin.idea.versions.createComponentActionLabel @@ -79,8 +80,10 @@ class KotlinSetupEnvironmentNotificationProvider( } if (!KotlinConfigurationCheckerComponent.getInstance(module.project).isSyncing && + !SuppressNotificationState.isKotlinNotConfiguredSuppressed(module.toModuleGroup()) && !hasAnyKotlinRuntimeInScope(module) && - UnsupportedAbiVersionNotificationPanelProvider.collectBadRoots(module).isEmpty()) { + UnsupportedAbiVersionNotificationPanelProvider.collectBadRoots(module).isEmpty() + ) { return createKotlinNotConfiguredPanel(module) } @@ -121,6 +124,11 @@ class KotlinSetupEnvironmentNotificationProvider( configuratorsPopup.showUnderneathOf(label) } } + + createComponentActionLabel("Ignore") { + SuppressNotificationState.suppressKotlinNotConfigured(module) + EditorNotifications.getInstance(module.project).updateAllNotifications() + } } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinWithLibraryConfigurator.kt b/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinWithLibraryConfigurator.kt index fd803ac4185..87a2a14de16 100644 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinWithLibraryConfigurator.kt +++ b/idea/src/org/jetbrains/kotlin/idea/configuration/KotlinWithLibraryConfigurator.kt @@ -17,17 +17,21 @@ package org.jetbrains.kotlin.idea.configuration import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.module.Module import com.intellij.openapi.module.ModuleManager import com.intellij.openapi.project.Project +import com.intellij.openapi.projectRoots.JavaSdkVersion import com.intellij.openapi.projectRoots.Sdk import com.intellij.openapi.roots.* import com.intellij.openapi.roots.libraries.* +import com.intellij.openapi.util.Computable import com.intellij.openapi.vfs.JarFileSystem import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.vfs.VfsUtilCore import com.intellij.psi.PsiElement +import com.intellij.psi.PsiJavaModule import org.jetbrains.annotations.Contract import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider @@ -37,11 +41,16 @@ import org.jetbrains.kotlin.idea.KotlinPluginUtil import org.jetbrains.kotlin.idea.facet.getRuntimeLibraryVersion import org.jetbrains.kotlin.idea.framework.ui.CreateLibraryDialogWithModules import org.jetbrains.kotlin.idea.framework.ui.FileUIUtils +import org.jetbrains.kotlin.idea.quickfix.KotlinAddRequiredModuleFix import org.jetbrains.kotlin.idea.quickfix.askUpdateRuntime import org.jetbrains.kotlin.idea.util.application.runWriteAction +import org.jetbrains.kotlin.idea.util.findFirstPsiJavaModule +import org.jetbrains.kotlin.idea.util.projectStructure.sdk +import org.jetbrains.kotlin.idea.util.projectStructure.version import org.jetbrains.kotlin.idea.versions.LibraryJarDescriptor import org.jetbrains.kotlin.idea.versions.findAllUsedLibraries import org.jetbrains.kotlin.idea.versions.findKotlinRuntimeLibrary +import org.jetbrains.kotlin.resolve.jvm.modules.KOTLIN_STDLIB_MODULE_NAME import java.io.File import java.util.* @@ -56,7 +65,7 @@ abstract class KotlinWithLibraryConfigurator internal constructor() : KotlinProj open val libraryType: LibraryType? = null - protected val libraryKind: PersistentLibraryKind<*>? = libraryType?.kind + protected val libraryKind: PersistentLibraryKind<*>? = libraryType?.kind override fun getStatus(moduleSourceRootGroup: ModuleSourceRootGroup): ConfigureKotlinStatus { val module = moduleSourceRootGroup.baseModule @@ -129,12 +138,12 @@ abstract class KotlinWithLibraryConfigurator internal constructor() : KotlinProj pathFromDialog: String?, collector: NotificationMessageCollector ) { - val classesPath = getPathToCopyFileTo(module.project, OrderRootType.CLASSES, defaultPath, pathFromDialog) - val sourcesPath = getPathToCopyFileTo(module.project, OrderRootType.SOURCES, defaultPath, pathFromDialog) + val classesPath = getPathToCopyFileTo(module.project, OrderRootType.CLASSES, defaultPath, pathFromDialog) + val sourcesPath = getPathToCopyFileTo(module.project, OrderRootType.SOURCES, defaultPath, pathFromDialog) configureModuleWithLibrary(module, classesPath, sourcesPath, collector, useBundled = pathFromDialog == null) } - fun configureModuleWithLibrary( + fun configureModuleWithLibrary( module: Module, classesPath: String, sourcesPath: String, @@ -149,7 +158,7 @@ abstract class KotlinWithLibraryConfigurator internal constructor() : KotlinProj ?: getKotlinLibrary(project) ?: createNewLibrary(project, collector) - val sdk = ModuleRootManager.getInstance(module).sdk + val sdk = module.sdk val model = library.modifiableModel for (descriptor in getLibraryJarDescriptors(sdk)) { @@ -167,6 +176,23 @@ abstract class KotlinWithLibraryConfigurator internal constructor() : KotlinProj ApplicationManager.getApplication().runWriteAction { model.commit() } addLibraryToModuleIfNeeded(module, library, collector) + + updateModuleInfo(module, collector) + } + + private fun updateModuleInfo(module: Module, collector: NotificationMessageCollector) { + if (module.sdk?.version?.isAtLeast(JavaSdkVersion.JDK_1_9) != true) return + + val project = module.project + val javaModule: PsiJavaModule = findFirstPsiJavaModule(module) ?: return + + val success = WriteCommandAction.runWriteCommandAction(project, Computable { + KotlinAddRequiredModuleFix.addModuleRequirement(javaModule, KOTLIN_STDLIB_MODULE_NAME) + }) + + if (success) { + collector.addMessage("Added $KOTLIN_STDLIB_MODULE_NAME requirement to module-info in ${module.name}") + } } fun configureLibraryJar( diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/DebuggerClassNameProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/DebuggerClassNameProvider.kt index 76599e0ee94..32b3c64ac4b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/DebuggerClassNameProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/DebuggerClassNameProvider.kt @@ -92,7 +92,9 @@ class DebuggerClassNameProvider( } private fun doGetClassesForPosition(position: SourcePosition): Set { - val relevantElement = runReadAction { getRelevantElement(position.elementAt) } + val relevantElement = runReadAction { + position.elementAt?.let { getRelevantElement(it) } + } val result = getOrComputeClassNames(relevantElement) { element -> getOuterClassNamesForElement(element) diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt index 51381286e07..3f54101b467 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt @@ -65,8 +65,8 @@ private fun findAdditionalExpressions(position: SourcePosition): Set 0 } ?: return emptySet() - val elem = file.findElementAt(offset) - val containingElement = getContainingElement(elem!!) ?: elem ?: return emptySet() + val elem = file.findElementAt(offset) ?: return emptySet() + val containingElement = getContainingElement(elem) ?: elem val limit = getLineRangeForElement(containingElement, doc) diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt index 0133ac39090..e845f2bfda0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt @@ -195,8 +195,8 @@ class KotlinFieldBreakpoint( descriptor = bindingContext.get(BindingContext.VALUE_PARAMETER_AS_PROPERTY, descriptor) } - if (descriptor != null) { - if (bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor as PropertyDescriptor)!!) { + if (descriptor is PropertyDescriptor) { + if (bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor)!!) { BreakpointType.FIELD } else { diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinLineBreakpointType.java b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinLineBreakpointType.java index 5d47ec5788b..15ef3ca559a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinLineBreakpointType.java +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinLineBreakpointType.java @@ -141,7 +141,7 @@ public class KotlinLineBreakpointType extends JavaLineBreakpointType { } public class KotlinLambdaBreakpointVariant extends ExactJavaBreakpointVariant { - public KotlinLambdaBreakpointVariant(XSourcePosition position, KtFunction function, Integer lambdaOrdinal) { + public KotlinLambdaBreakpointVariant(@NotNull XSourcePosition position, @Nullable KtFunction function, Integer lambdaOrdinal) { super(position, function, lambdaOrdinal); } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/breakpointTypeUtils.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/breakpointTypeUtils.kt index a8f9db23f6a..84c5e73da2c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/breakpointTypeUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/breakpointTypeUtils.kt @@ -43,7 +43,7 @@ import java.util.* fun canPutAt(file: VirtualFile, line: Int, project: Project, breakpointTypeClass: Class<*>): Boolean { val psiFile = PsiManager.getInstance(project).findFile(file) - if (psiFile == null || psiFile.virtualFile.fileType != KotlinFileType.INSTANCE) { + if (psiFile == null || psiFile.virtualFile?.fileType != KotlinFileType.INSTANCE) { return false } @@ -106,8 +106,11 @@ fun computeVariants( } lambdas.forEachIndexed { ordinal, lambda -> - result.add(kotlinBreakpointType.KotlinLambdaBreakpointVariant( - XSourcePositionImpl.createByElement(lambda.bodyExpression), lambda, ordinal)) + val positionImpl = XSourcePositionImpl.createByElement(lambda.bodyExpression) + + if (positionImpl != null) { + result.add(kotlinBreakpointType.KotlinLambdaBreakpointVariant(positionImpl, lambda, ordinal)) + } } val allBreakpoint = (kotlinBreakpointType as JavaLineBreakpointType).JavaBreakpointVariant(position) diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt index 18bad29ada3..038100fcc8c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt @@ -108,7 +108,8 @@ class KotlinSteppingCommandProvider : JvmSteppingCommandProvider() { val file = sourcePosition.file as? KtFile ?: return null if (sourcePosition.line < 0) return null - val containingFunction = sourcePosition.elementAt.parents + val elementAt = sourcePosition.elementAt ?: return null + val containingFunction = elementAt.parents .filterIsInstance() .firstOrNull { !it.isLocal } ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/facet/KotlinFacetEditorGeneralTab.kt b/idea/src/org/jetbrains/kotlin/idea/facet/KotlinFacetEditorGeneralTab.kt index e5794f3c677..fc2205555fe 100644 --- a/idea/src/org/jetbrains/kotlin/idea/facet/KotlinFacetEditorGeneralTab.kt +++ b/idea/src/org/jetbrains/kotlin/idea/facet/KotlinFacetEditorGeneralTab.kt @@ -243,10 +243,7 @@ class KotlinFacetEditorGeneralTab( private fun restrictAPIVersions() { with(editor.compilerConfigurable) { - val targetPlatform = editor.targetPlatformComboBox.selectedItem as TargetPlatformKind<*>? - val libraryLevel = getLibraryLanguageLevel(editorContext.module, editorContext.rootModel, targetPlatform) - val versionUpperBound = minOf(selectedLanguageVersion, libraryLevel) - restrictAPIVersions(versionUpperBound) + restrictAPIVersions(selectedLanguageVersion) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt b/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt index a0c67031c0d..ad68853f91e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.idea.facet import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider +import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project import com.intellij.openapi.projectRoots.JavaSdk @@ -24,11 +25,17 @@ import com.intellij.openapi.projectRoots.JavaSdkVersion import com.intellij.openapi.projectRoots.ProjectJdkTable import com.intellij.openapi.roots.ModuleRootManager import com.intellij.openapi.roots.ModuleRootModel +import com.intellij.openapi.roots.ProjectRootModificationTracker import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.text.StringUtil +import com.intellij.psi.util.CachedValueProvider +import org.jetbrains.kotlin.analyzer.ModuleInfo +import org.jetbrains.kotlin.caches.resolve.KotlinCacheService import org.jetbrains.kotlin.cli.common.arguments.* import org.jetbrains.kotlin.compilerRunner.ArgumentUtils import org.jetbrains.kotlin.config.* +import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.* import org.jetbrains.kotlin.idea.compiler.configuration.Kotlin2JsCompilerArgumentsHolder import org.jetbrains.kotlin.idea.compiler.configuration.Kotlin2JvmCompilerArgumentsHolder import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder @@ -84,7 +91,7 @@ fun KotlinFacetSettings.initializeIfNeeded( LanguageVersion.fromVersionString(commonArguments.apiVersion) ?: languageLevel } else { - languageLevel!!.coerceAtMost(getLibraryLanguageLevel(module, rootModel, targetPlatformKind!!)) + languageLevel!!.coerceAtMost(getLibraryLanguageLevel(module, rootModel, targetPlatformKind)) } } } @@ -111,6 +118,47 @@ val mavenLibraryIdToPlatform: Map> by lazy { .toMap() } +private fun Module.findImplementedModuleName(modelsProvider: IdeModifiableModelsProvider): String? { + val facetModel = modelsProvider.getModifiableFacetModel(this) + val facet = facetModel.findFacet(KotlinFacetType.TYPE_ID, KotlinFacetType.INSTANCE.defaultFacetName) + return facet?.configuration?.settings?.implementedModuleName +} + +private fun Module.findImplementingModules(modelsProvider: IdeModifiableModelsProvider): List { + return modelsProvider.modules.filter { module -> + module.findImplementedModuleName(modelsProvider) == name + } +} + +private fun Module.findImplementingModuleInfos(moduleSourceInfo: ModuleSourceInfo): List { + val modelsProvider = IdeModifiableModelsProviderImpl(project) + val implementingModules = findImplementingModules(modelsProvider) + return implementingModules.mapNotNull { + when (moduleSourceInfo) { + is ModuleProductionSourceInfo -> it.productionSourceInfo() + is ModuleTestSourceInfo -> it.testSourceInfo() + else -> null + } + } +} + +val ModuleDescriptor.implementingDescriptors: List + get() { + val moduleSourceInfo = getCapability(ModuleInfo.Capability) as? ModuleSourceInfo ?: return emptyList() + val module = moduleSourceInfo.module + return module.cached(CachedValueProvider { + val implementingModuleInfos = module.findImplementingModuleInfos(moduleSourceInfo) + val implementingModuleDescriptors = implementingModuleInfos.mapNotNull { + KotlinCacheService.getInstance(module.project).getResolutionFacadeByModuleInfo(it, it.platform)?.moduleDescriptor + } + CachedValueProvider.Result( + implementingModuleDescriptors, + *(implementingModuleInfos.map { it.createModificationTracker() } + + ProjectRootModificationTracker.getInstance(module.project)).toTypedArray() + ) + }) + } + fun Module.getOrCreateFacet(modelsProvider: IdeModifiableModelsProvider, useProjectSettings: Boolean, commitModel: Boolean = false): KotlinFacet { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/PlatformExpectedAnnotator.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/PlatformExpectedAnnotator.kt similarity index 77% rename from idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/PlatformExpectedAnnotator.kt rename to idea/src/org/jetbrains/kotlin/idea/highlighter/PlatformExpectedAnnotator.kt index 0697129138d..4ccb08c6fca 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/PlatformExpectedAnnotator.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/PlatformExpectedAnnotator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,11 @@ package org.jetbrains.kotlin.idea.highlighter import com.intellij.lang.annotation.AnnotationHolder import com.intellij.lang.annotation.Annotator import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.caches.resolve.KotlinCacheService import org.jetbrains.kotlin.descriptors.MemberDescriptor -import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.idea.caches.resolve.ModuleProductionSourceInfo -import org.jetbrains.kotlin.idea.caches.resolve.ModuleTestSourceInfo import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor import org.jetbrains.kotlin.idea.core.toDescriptor +import org.jetbrains.kotlin.idea.facet.implementingDescriptors import org.jetbrains.kotlin.idea.project.TargetPlatformDetector import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtDeclaration @@ -37,22 +34,6 @@ import org.jetbrains.kotlin.resolve.TargetPlatform import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker import org.jetbrains.kotlin.resolve.diagnostics.SimpleDiagnostics -val ModuleDescriptor.sourceKind: SourceKind - get() = when (getCapability(ModuleInfo.Capability)) { - is ModuleProductionSourceInfo -> SourceKind.PRODUCTION - is ModuleTestSourceInfo -> SourceKind.TEST - else -> SourceKind.OTHER - } - -enum class SourceKind { OTHER, PRODUCTION, TEST } - -val ModuleDescriptor.allImplementingCompatibleModules - get() = allImplementingModules.filter { other -> - this.sourceKind == SourceKind.OTHER || - other.sourceKind == SourceKind.OTHER || - other.sourceKind == this.sourceKind - } - class PlatformExpectedAnnotator : Annotator { override fun annotate(element: PsiElement, holder: AnnotationHolder) { val declaration = element as? KtDeclaration ?: return @@ -60,7 +41,7 @@ class PlatformExpectedAnnotator : Annotator { if (TargetPlatformDetector.getPlatform(declaration.containingKtFile) !is TargetPlatform.Common) return - val implementingModules = declaration.findModuleDescriptor().allImplementingCompatibleModules + val implementingModules = declaration.findModuleDescriptor().implementingDescriptors if (implementingModules.isEmpty()) return val descriptor = declaration.toDescriptor() as? MemberDescriptor ?: return diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/HasActualMarker.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/HasActualMarker.kt index 18e2ed44336..c578bb1bce9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/HasActualMarker.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/HasActualMarker.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor import org.jetbrains.kotlin.idea.core.toDescriptor -import org.jetbrains.kotlin.idea.highlighter.allImplementingCompatibleModules +import org.jetbrains.kotlin.idea.facet.implementingDescriptors import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.MultiTargetPlatform @@ -48,7 +48,7 @@ fun getPlatformActualTooltip(declaration: KtDeclaration): String? { val descriptor = declaration.toDescriptor() as? MemberDescriptor ?: return null val commonModuleDescriptor = declaration.containingKtFile.findModuleDescriptor() - val platformModulesWithActuals = commonModuleDescriptor.allImplementingCompatibleModules.filter { + val platformModulesWithActuals = commonModuleDescriptor.implementingDescriptors.filter { it.hasActualsFor(descriptor) } if (platformModulesWithActuals.isEmpty()) return null @@ -74,7 +74,7 @@ private fun DeclarationDescriptor.actualsForExpected(): Collection SourceKind.PRODUCTION + is ModuleTestSourceInfo -> SourceKind.TEST + else -> SourceKind.OTHER + } + +enum class SourceKind { OTHER, PRODUCTION, TEST } + fun ModuleDescriptor.commonModuleOrNull(): ModuleDescriptor? { val sourceKind = sourceKind return allDependencyModules.firstOrNull { dependency -> diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt index b3a5e2f686e..4139e5310eb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/markers/KotlinLineMarkerProvider.kt @@ -44,7 +44,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor import org.jetbrains.kotlin.idea.core.isInheritable import org.jetbrains.kotlin.idea.core.isOverridable import org.jetbrains.kotlin.idea.core.toDescriptor -import org.jetbrains.kotlin.idea.highlighter.allImplementingCompatibleModules +import org.jetbrains.kotlin.idea.facet.implementingDescriptors import org.jetbrains.kotlin.idea.util.ProjectRootsUtil import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* @@ -292,7 +292,7 @@ private fun collectActualMarkers(declaration: KtNamedDeclaration, val descriptor = declaration.toDescriptor() as? MemberDescriptor ?: return val commonModuleDescriptor = declaration.containingKtFile.findModuleDescriptor() - if (commonModuleDescriptor.allImplementingCompatibleModules.none { it.hasActualsFor(descriptor) }) return + if (commonModuleDescriptor.implementingDescriptors.none { it.hasActualsFor(descriptor) }) return val anchor = declaration.nameIdentifier ?: declaration diff --git a/idea/src/org/jetbrains/kotlin/idea/injection/KotlinLanguageInjectionSupport.kt b/idea/src/org/jetbrains/kotlin/idea/injection/KotlinLanguageInjectionSupport.kt index af3aba95603..ba0b82bcb40 100644 --- a/idea/src/org/jetbrains/kotlin/idea/injection/KotlinLanguageInjectionSupport.kt +++ b/idea/src/org/jetbrains/kotlin/idea/injection/KotlinLanguageInjectionSupport.kt @@ -57,8 +57,8 @@ class KotlinLanguageInjectionSupport : AbstractLanguageInjectionSupport() { val configuration = Configuration.getProjectInstance(host.project).advancedConfiguration if (!configuration.isSourceModificationAllowed) { // It's not allowed to modify code without explicit permission. Postpone adding @Inject or comment till it granted. - host.putUserData(InjectLanguageAction.FIX_KEY, Processor { fixHost -> - addInjectionInstructionInCode(language, fixHost) + host.putUserData(InjectLanguageAction.FIX_KEY, Processor { fixHost: PsiLanguageInjectionHost? -> + fixHost != null && addInjectionInstructionInCode(language, fixHost) }) return false } diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ConflictingExtensionPropertyInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ConflictingExtensionPropertyInspection.kt index c98dcb7fa04..8dbe2357433 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ConflictingExtensionPropertyInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ConflictingExtensionPropertyInspection.kt @@ -58,7 +58,7 @@ import org.jetbrains.kotlin.resolve.scopes.collectSyntheticExtensionProperties import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull -class ConflictingExtensionPropertyInspection : AbstractKotlinInspection(), CleanupLocalInspectionTool { +class ConflictingExtensionPropertyInspection : AbstractKotlinInspection() { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor { val file = session.file as? KtFile ?: return PsiElementVisitor.EMPTY_VISITOR val resolutionFacade = file.getResolutionFacade() diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspection.kt index 93bb5f02bca..7b869617b0d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinCleanupInspection.kt @@ -99,7 +99,8 @@ class KotlinCleanupInspection : LocalInspectionTool(), CleanupLocalInspectionToo Errors.COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT, ErrorsJs.WRONG_EXTERNAL_DECLARATION, Errors.YIELD_IS_RESERVED, - Errors.DEPRECATED_MODIFIER_FOR_TARGET + Errors.DEPRECATED_MODIFIER_FOR_TARGET, + Errors.DEPRECATED_MODIFIER ) private fun Diagnostic.isObsoleteLabel(): Boolean { diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/MigrateDiagnosticSuppressionInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/MigrateDiagnosticSuppressionInspection.kt new file mode 100644 index 00000000000..7827e61a324 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/MigrateDiagnosticSuppressionInspection.kt @@ -0,0 +1,99 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.inspections + +import com.intellij.codeInsight.FileModificationService +import com.intellij.codeInspection.* +import com.intellij.openapi.project.Project +import com.intellij.openapi.util.text.StringUtil +import com.intellij.psi.PsiElementVisitor +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.diagnostics.DiagnosticFactory +import org.jetbrains.kotlin.diagnostics.Errors.* +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode + +class MigrateDiagnosticSuppressionInspection : AbstractKotlinInspection(), CleanupLocalInspectionTool { + override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor { + return object : KtVisitorVoid() { + + override fun visitAnnotationEntry(annotationEntry: KtAnnotationEntry) { + super.visitAnnotationEntry(annotationEntry) + + if (annotationEntry.calleeExpression?.text != "Suppress") return + val context = annotationEntry.analyze(BodyResolveMode.PARTIAL) + val descriptor = context[BindingContext.ANNOTATION, annotationEntry] ?: return + if (descriptor.fqName != KotlinBuiltIns.FQ_NAMES.suppress) return + + for (argument in annotationEntry.valueArguments) { + val expression = argument.getArgumentExpression() as? KtStringTemplateExpression ?: continue + val text = expression.text + if (text.firstOrNull() != '\"' || text.lastOrNull() != '\"') continue + val newDiagnosticFactory = MIGRATION_MAP[StringUtil.unquoteString(text)] ?: continue + + holder.registerProblem( + expression, + "Diagnostic name should be replaced by the new one", + ProblemHighlightType.GENERIC_ERROR_OR_WARNING, + ReplaceDiagnosticNameFix(newDiagnosticFactory) + ) + } + } + } + } + + class ReplaceDiagnosticNameFix(private val diagnosticFactory: DiagnosticFactory<*>) : LocalQuickFix { + override fun getName() = "$familyName with ${diagnosticFactory.name}" + + override fun getFamilyName() = "Replace diagnostic name" + + override fun applyFix(project: Project, descriptor: ProblemDescriptor) { + val expression = descriptor.psiElement as? KtStringTemplateExpression ?: return + if (!FileModificationService.getInstance().preparePsiElementForWrite(expression)) return + + val psiFactory = KtPsiFactory(expression) + expression.replace(psiFactory.createExpression("\"${diagnosticFactory.name}\"")) + } + + } + + companion object { + + private val MIGRATION_MAP = mapOf( + "HEADER_DECLARATION_WITH_BODY" to EXPECTED_DECLARATION_WITH_BODY, + "HEADER_DECLARATION_WITH_DEFAULT_PARAMETER" to EXPECTED_DECLARATION_WITH_DEFAULT_PARAMETER, + "HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL" to EXPECTED_CLASS_CONSTRUCTOR_DELEGATION_CALL, + "HEADER_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER" to EXPECTED_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER, + "HEADER_ENUM_CONSTRUCTOR" to EXPECTED_ENUM_CONSTRUCTOR, + "HEADER_ENUM_ENTRY_WITH_BODY" to EXPECTED_ENUM_ENTRY_WITH_BODY, + "HEADER_PROPERTY_INITIALIZER" to EXPECTED_PROPERTY_INITIALIZER, + + "IMPL_TYPE_ALIAS_NOT_TO_CLASS" to ACTUAL_TYPE_ALIAS_NOT_TO_CLASS, + "IMPL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE" to ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE, + "IMPL_TYPE_ALIAS_WITH_USE_SITE_VARIANCE" to ACTUAL_TYPE_ALIAS_WITH_USE_SITE_VARIANCE, + "IMPL_TYPE_ALIAS_WITH_COMPLEX_SUBSTITUTION" to ACTUAL_TYPE_ALIAS_WITH_COMPLEX_SUBSTITUTION, + + "HEADER_WITHOUT_IMPLEMENTATION" to NO_ACTUAL_FOR_EXPECT, + "IMPLEMENTATION_WITHOUT_HEADER" to ACTUAL_WITHOUT_EXPECT, + + "HEADER_CLASS_MEMBERS_ARE_NOT_IMPLEMENTED" to NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, + "IMPL_MISSING" to ACTUAL_MISSING + ) + } +} diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/NullChecksToSafeCallInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/NullChecksToSafeCallInspection.kt index 5aa894e519b..bcac51efc65 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/NullChecksToSafeCallInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/NullChecksToSafeCallInspection.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.types.TypeUtils -class NullChecksToSafeCallInspection : AbstractKotlinInspection(), CleanupLocalInspectionTool { +class NullChecksToSafeCallInspection : AbstractKotlinInspection() { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession) = object : KtVisitorVoid() { override fun visitBinaryExpression(expression: KtBinaryExpression) { diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RecursivePropertyAccessorInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RecursivePropertyAccessorInspection.kt index 34eb740972d..1515f089c20 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RecursivePropertyAccessorInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RecursivePropertyAccessorInspection.kt @@ -95,6 +95,7 @@ class RecursivePropertyAccessorInspection : AbstractKotlinInspection() { if (element !is KtSimpleNameExpression) return false val propertyAccessor = element.getParentOfType(true) as? KtPropertyAccessor ?: return false if (element.text != propertyAccessor.property.name) return false + if (element.parent is KtCallableReferenceExpression) return false val bindingContext = element.analyze() val target = bindingContext[REFERENCE_TARGET, element] if (target != bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, propertyAccessor.property]) return false @@ -112,6 +113,7 @@ class RecursivePropertyAccessorInspection : AbstractKotlinInspection() { val isGetter = name == "get$referencedName" val isSetter = name == "set$referencedName" if (!isGetter && !isSetter) return false + if (element.parent is KtCallableReferenceExpression) return false val bindingContext = element.analyze() val syntheticDescriptor = bindingContext[REFERENCE_TARGET, element] as? SyntheticJavaPropertyDescriptor ?: return false val namedFunctionDescriptor = bindingContext[DECLARATION_TO_DESCRIPTOR, namedFunction] diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantGetterInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantGetterInspection.kt index 7c0aa2eab9e..43766544da4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantGetterInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantGetterInspection.kt @@ -21,7 +21,7 @@ import com.intellij.openapi.project.Project import com.intellij.psi.PsiElementVisitor import org.jetbrains.kotlin.psi.* -class RedundantGetterInspection : AbstractKotlinInspection() { +class RedundantGetterInspection : AbstractKotlinInspection(), CleanupLocalInspectionTool { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor { return object : KtVisitorVoid() { override fun visitPropertyAccessor(accessor: KtPropertyAccessor) { diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSetterInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSetterInspection.kt index 567154cabdd..9a69b87bcba 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSetterInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantSetterInspection.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* -class RedundantSetterInspection : AbstractKotlinInspection() { +class RedundantSetterInspection : AbstractKotlinInspection(), CleanupLocalInspectionTool { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor { return object : KtVisitorVoid() { override fun visitPropertyAccessor(accessor: KtPropertyAccessor) { diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantUnitReturnTypeInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantUnitReturnTypeInspection.kt index 88c3ebedaea..b69a475ecd5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantUnitReturnTypeInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/RedundantUnitReturnTypeInspection.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.idea.inspections +import com.intellij.codeInspection.CleanupLocalInspectionTool import com.intellij.codeInspection.IntentionWrapper import com.intellij.codeInspection.ProblemHighlightType import com.intellij.codeInspection.ProblemsHolder @@ -31,7 +32,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.types.typeUtil.isNothing import org.jetbrains.kotlin.types.typeUtil.isUnit -class RedundantUnitReturnTypeInspection : AbstractKotlinInspection() { +class RedundantUnitReturnTypeInspection : AbstractKotlinInspection(), CleanupLocalInspectionTool { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor { return object : KtVisitorVoid() { override fun visitNamedFunction(function: KtNamedFunction) { diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceArrayOfWithLiteralInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceArrayOfWithLiteralInspection.kt index 36701c19182..cdc801cb7d5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceArrayOfWithLiteralInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ReplaceArrayOfWithLiteralInspection.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.config.LanguageFeature.ArrayLiteralsInAnnotations import org.jetbrains.kotlin.idea.intentions.isArrayOfMethod import org.jetbrains.kotlin.idea.project.languageVersionSettings import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getParentOfType class ReplaceArrayOfWithLiteralInspection : AbstractKotlinInspection() { @@ -69,6 +70,10 @@ class ReplaceArrayOfWithLiteralInspection : AbstractKotlinInspection() { override fun applyFix(project: Project, descriptor: ProblemDescriptor) { val calleeExpression = descriptor.psiElement as KtExpression val callExpression = calleeExpression.parent as KtCallExpression + + val valueArgument = callExpression.getParentOfType(false) + valueArgument?.getSpreadElement()?.delete() + val arguments = callExpression.valueArguments val arrayLiteral = KtPsiFactory(callExpression).buildExpression { appendFixedText("[") @@ -80,6 +85,7 @@ class ReplaceArrayOfWithLiteralInspection : AbstractKotlinInspection() { } appendFixedText("]") } as KtCollectionLiteralExpression + callExpression.replace(arrayLiteral) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/SuspiciousEqualsCombination.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/SuspiciousEqualsCombination.kt index af38c0a9b3b..8abedda09ac 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/SuspiciousEqualsCombination.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/SuspiciousEqualsCombination.kt @@ -16,14 +16,13 @@ package org.jetbrains.kotlin.idea.inspections -import com.intellij.codeInspection.CleanupLocalInspectionTool import com.intellij.codeInspection.LocalInspectionToolSession import com.intellij.codeInspection.ProblemHighlightType import com.intellij.codeInspection.ProblemsHolder import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* -class SuspiciousEqualsCombination : AbstractKotlinInspection(), CleanupLocalInspectionTool { +class SuspiciousEqualsCombination : AbstractKotlinInspection() { override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession) = object : KtVisitorVoid() { override fun visitBinaryExpression(expression: KtBinaryExpression) { diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt index fb35dcf561e..cb0bd1a5355 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt @@ -53,9 +53,9 @@ import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny import org.jetbrains.kotlin.idea.core.isInheritable import org.jetbrains.kotlin.idea.core.toDescriptor +import org.jetbrains.kotlin.idea.facet.implementingDescriptors import org.jetbrains.kotlin.idea.findUsages.KotlinFindUsagesHandlerFactory import org.jetbrains.kotlin.idea.findUsages.handlers.KotlinFindClassUsagesHandler -import org.jetbrains.kotlin.idea.highlighter.allImplementingCompatibleModules import org.jetbrains.kotlin.idea.highlighter.markers.hasActualsFor import org.jetbrains.kotlin.idea.imports.importableFqName import org.jetbrains.kotlin.idea.references.mainReference @@ -334,7 +334,7 @@ class UnusedSymbolInspection : AbstractKotlinInspection() { descriptor as? MemberDescriptor ?: return false val commonModuleDescriptor = declaration.containingKtFile.findModuleDescriptor() - return commonModuleDescriptor.allImplementingCompatibleModules.any { it.hasActualsFor(descriptor) } || + return commonModuleDescriptor.implementingDescriptors.any { it.hasActualsFor(descriptor) } || commonModuleDescriptor.hasActualsFor(descriptor) } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ChooseValueExpression.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ChooseValueExpression.kt index dfe3b405f48..8c2c416d7d9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ChooseValueExpression.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ChooseValueExpression.kt @@ -25,16 +25,18 @@ import com.intellij.codeInsight.template.impl.TemplateManagerImpl import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil //TODO: move it somewhere else and reuse -abstract class ChooseValueExpression( +abstract class ChooseValueExpression( lookupItems: Collection, - protected val defaultItem: T, + defaultItem: T, private val advertisementText: String? = null ) : Expression() { - protected abstract fun getLookupString(element: T): String protected abstract fun getResult(element: T): String - protected val lookupItems: Array = lookupItems.map { suggestion -> + @Suppress("LeakingThis") + private val defaultItemString = getLookupString(defaultItem) + + private val lookupItems: Array = lookupItems.map { suggestion -> LookupElementBuilder.create(suggestion, getLookupString(suggestion)).withInsertHandler { context, item -> val topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(context.editor) val templateState = TemplateManagerImpl.getTemplateState(topLevelEditor) @@ -52,7 +54,7 @@ abstract class ChooseValueExpression( override fun calculateQuickResult(context: ExpressionContext) = calculateResult(context) - override fun calculateResult(context: ExpressionContext) = TextResult(getLookupString(defaultItem)) + override fun calculateResult(context: ExpressionContext) = TextResult(defaultItemString) override fun getAdvertisingText() = advertisementText } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt index 8ff388f2ca7..d78401f8b84 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToBlockBodyIntention.kt @@ -19,8 +19,10 @@ package org.jetbrains.kotlin.idea.intentions import com.intellij.codeInsight.intention.LowPriorityAction import com.intellij.openapi.editor.Editor import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny import org.jetbrains.kotlin.idea.core.setType import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext @@ -81,7 +83,15 @@ class ConvertToBlockBodyIntention : SelfTargetingIntention generateBody(declaration.isGetter) + is KtPropertyAccessor -> { + val parent = declaration.parent + if (parent is KtProperty && parent.typeReference == null) { + val descriptor = parent.resolveToDescriptorIfAny() + (descriptor as? CallableDescriptor)?.returnType?.let { parent.setType(it) } + } + + generateBody(declaration.isGetter) + } else -> throw RuntimeException("Unknown declaration type: $declaration") } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceArrayEqualityOpWithArraysEqualsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceArrayEqualityOpWithArraysEqualsIntention.kt index 38c95ff7a42..bb2c68f46c7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceArrayEqualityOpWithArraysEqualsIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceArrayEqualityOpWithArraysEqualsIntention.kt @@ -18,13 +18,11 @@ package org.jetbrains.kotlin.idea.intentions import com.intellij.openapi.editor.Editor import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.idea.caches.resolve.resolveImportReference import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection -import org.jetbrains.kotlin.idea.util.ImportInsertHelper import org.jetbrains.kotlin.lexer.KtTokens -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtBinaryExpression import org.jetbrains.kotlin.psi.KtPsiFactory +import org.jetbrains.kotlin.psi.createExpressionByPattern import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall class ReplaceArrayEqualityOpWithArraysEqualsInspection : @@ -32,7 +30,7 @@ class ReplaceArrayEqualityOpWithArraysEqualsInspection : class ReplaceArrayEqualityOpWithArraysEqualsIntention : SelfTargetingOffsetIndependentIntention( KtBinaryExpression::class.java, - "Replace '==' with 'Arrays.equals'" + "Replace '==' with 'contentEquals'" ) { override fun applyTo(element: KtBinaryExpression, editor: Editor?) { @@ -40,16 +38,18 @@ class ReplaceArrayEqualityOpWithArraysEqualsIntention : SelfTargetingOffsetIndep val right = element.right ?: return val left = element.left ?: return val factory = KtPsiFactory(project) - val ktFile = element.containingKtFile - ktFile.resolveImportReference(FqName("java.util.Arrays")).firstOrNull()?.let { - ImportInsertHelper.getInstance(project).importDescriptor(ktFile, it) + val template = buildString { + if (element.operationToken == KtTokens.EXCLEQ) append("!") + append("$0.contentEquals($1)") } - val expression = factory.createExpression("Arrays.equals(${left.text}, ${right.text})") + val expression = factory.createExpressionByPattern(template, left, right) element.replace(expression) } override fun isApplicableTo(element: KtBinaryExpression): Boolean { - if (element.operationToken != KtTokens.EQEQ) return false + val operationToken = element.operationToken + if (operationToken != KtTokens.EQEQ && operationToken != KtTokens.EXCLEQ) return false + if (operationToken == KtTokens.EXCLEQ) text = "Replace '!=' with 'contentEquals'" val right = element.right ?: return false val left = element.left ?: return false val rightResolvedCall = right.getResolvedCall(right.analyze()) ?: return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyBooleanWithConstantsIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyBooleanWithConstantsIntention.kt index d6094aff21f..27c020d4cc2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyBooleanWithConstantsIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyBooleanWithConstantsIntention.kt @@ -24,10 +24,13 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.core.copied import org.jetbrains.kotlin.idea.core.replaced import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection +import org.jetbrains.kotlin.idea.intentions.loopToCallChain.isTrueConstant import org.jetbrains.kotlin.lexer.KtTokens.* import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType import org.jetbrains.kotlin.resolve.CompileTimeConstantUtils import org.jetbrains.kotlin.resolve.calls.callUtil.getType +import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull import org.jetbrains.kotlin.types.isFlexible class SimplifyBooleanWithConstantsInspection : IntentionBasedInspection(SimplifyBooleanWithConstantsIntention::class) @@ -58,7 +61,17 @@ class SimplifyBooleanWithConstantsIntention : SelfTargetingOffsetIndependentInte override fun applyTo(element: KtBinaryExpression, editor: Editor?) { val topBinary = PsiTreeUtil.getTopmostParentOfType(element, KtBinaryExpression::class.java) ?: element val simplified = toSimplifiedExpression(topBinary) - topBinary.replace(KtPsiUtil.safeDeparenthesize(simplified, true)) + val result = topBinary.replaced(KtPsiUtil.safeDeparenthesize(simplified, true)) + removeRedundantAssertion(result) + } + + internal fun removeRedundantAssertion(expression: KtExpression) { + val callExpression = expression.getNonStrictParentOfType() ?: return + val fqName = callExpression.getCallableDescriptor()?.fqNameOrNull() + val valueArguments = callExpression.valueArguments + val isRedundant = fqName?.asString() == "kotlin.assert" && + valueArguments.singleOrNull()?.getArgumentExpression().isTrueConstant() + if (isRedundant) callExpression.delete() } private fun toSimplifiedExpression(expression: KtExpression): KtExpression { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyTypeExplicitlyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyTypeExplicitlyIntention.kt index f4cbcb99d15..92b3f413a0f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyTypeExplicitlyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/SpecifyTypeExplicitlyIntention.kt @@ -132,10 +132,14 @@ class SpecifyTypeExplicitlyIntention : } }.ifEmpty { return null } - return object : ChooseValueExpression(types, types.first()) { - override fun getLookupString(element: KotlinType) = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(element) - override fun getResult(element: KotlinType) = IdeDescriptorRenderers.SOURCE_CODE.renderType(element) - } + return TypeChooseValueExpression(types, types.first()) + } + + // Explicit class is used because of KT-20460 + private class TypeChooseValueExpression(items: List, defaultItem: KotlinType) : + ChooseValueExpression(items, defaultItem) { + override fun getLookupString(element: KotlinType) = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.renderType(element) + override fun getResult(element: KotlinType) = IdeDescriptorRenderers.SOURCE_CODE.renderType(element) } fun addTypeAnnotation(editor: Editor?, declaration: KtCallableDeclaration, exprType: KotlinType) { diff --git a/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinBlockIntoSingleStatementHandler.kt b/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinBlockIntoSingleStatementHandler.kt index e8028632a6d..7ac894cf4ee 100644 --- a/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinBlockIntoSingleStatementHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/joinLines/JoinBlockIntoSingleStatementHandler.kt @@ -19,9 +19,11 @@ package org.jetbrains.kotlin.idea.joinLines import com.intellij.codeInsight.editorActions.JoinRawLinesHandlerDelegate import com.intellij.openapi.editor.Document import com.intellij.psi.PsiFile +import org.jetbrains.kotlin.idea.inspections.UseExpressionBodyInspection import org.jetbrains.kotlin.idea.intentions.MergeIfsIntention import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.startOffset class JoinBlockIntoSingleStatementHandler : JoinRawLinesHandlerDelegate { override fun tryJoinRawLines(document: Document, file: PsiFile, start: Int, end: Int): Int { @@ -36,8 +38,12 @@ class JoinBlockIntoSingleStatementHandler : JoinRawLinesHandlerDelegate { val block = brace.parent as? KtBlockExpression ?: return -1 val statement = block.statements.singleOrNull() ?: return -1 + val parent = block.parent - if (parent !is KtContainerNode && parent !is KtWhenEntry) return -1 + val useExpressionBodyInspection = UseExpressionBodyInspection(convertEmptyToUnit = false) + val oneLineReturnFunction = (parent as? KtDeclarationWithBody)?.takeIf { useExpressionBodyInspection.isActiveFor(it) } + if (parent !is KtContainerNode && parent !is KtWhenEntry && oneLineReturnFunction == null) return -1 + if (block.node.getChildren(KtTokens.COMMENTS).isNotEmpty()) return -1 // otherwise we will loose comments // handle nested if's @@ -61,8 +67,14 @@ class JoinBlockIntoSingleStatementHandler : JoinRawLinesHandlerDelegate { } } - val newStatement = block.replace(statement) - return newStatement.textRange!!.startOffset + return if (oneLineReturnFunction != null) { + useExpressionBodyInspection.simplify(oneLineReturnFunction, false) + oneLineReturnFunction.bodyExpression!!.startOffset + } + else { + val newStatement = block.replace(statement) + newStatement.textRange!!.startOffset + } } override fun tryJoinLines(document: Document, file: PsiFile, start: Int, end: Int) = -1 diff --git a/idea/src/org/jetbrains/kotlin/idea/projectView/projectViewProviders.kt b/idea/src/org/jetbrains/kotlin/idea/projectView/projectViewProviders.kt index 0f1eb97abdc..3dae6753b99 100644 --- a/idea/src/org/jetbrains/kotlin/idea/projectView/projectViewProviders.kt +++ b/idea/src/org/jetbrains/kotlin/idea/projectView/projectViewProviders.kt @@ -46,7 +46,7 @@ class KotlinExpandNodeProjectViewProvider : TreeStructureProvider, DumbAware { val result = ArrayList>() for (child in children) { - val childValue = child.value.asKtFile() + val childValue = child.value?.asKtFile() if (childValue != null) { val declarations = childValue.declarations diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddDataModifierFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddDataModifierFix.kt new file mode 100644 index 00000000000..8c7c0df6244 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddDataModifierFix.kt @@ -0,0 +1,80 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.quickfix + +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.diagnostics.Diagnostic +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade +import org.jetbrains.kotlin.idea.core.isVisible +import org.jetbrains.kotlin.lexer.KtTokens +import org.jetbrains.kotlin.psi.KtClass +import org.jetbrains.kotlin.psi.KtDestructuringDeclarationEntry +import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.KtModifierListOwner +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils +import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall + +class AddDataModifierFix(element: KtClass, private val fqName: String) : AddModifierFix(element, KtTokens.DATA_KEYWORD) { + + override fun getText() = "Make '$fqName' data class" + + override fun getFamilyName() = text + + companion object : KotlinSingleIntentionActionFactory() { + + override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { + val element = diagnostic.psiElement as? KtExpression ?: return null + val context = element.analyze() + + val callableDescriptor = if (element is KtDestructuringDeclarationEntry) { + context[BindingContext.DECLARATION_TO_DESCRIPTOR, element.parent.parent] as? CallableDescriptor + } + else { + element.getResolvedCall(context)?.resultingDescriptor + } + + val constructor = callableDescriptor?.returnType?.arguments?.firstOrNull()?.type?.constructor + ?: callableDescriptor?.returnType?.constructor + + val classDescriptor = constructor?.declarationDescriptor as? ClassDescriptor ?: return null + + val modality = classDescriptor.modality + if (modality != Modality.FINAL || classDescriptor.isInner) return null + val ctorParams = classDescriptor.constructors.firstOrNull { it.isPrimary }?.valueParameters ?: return null + if (ctorParams.isEmpty()) return null + + if (!ctorParams.all { + if (it.varargElementType != null) return@all false + val property = context[BindingContext.VALUE_PARAMETER_AS_PROPERTY, it] ?: return@all false + // NB: we use element as receiver because element is a constructor call + // which is effectively used as receiver by destructuring declaration + property.isVisible(element, element, context, element.getResolutionFacade()) + }) return null + + val klass = DescriptorToSourceUtils.descriptorToDeclaration(classDescriptor) as? KtClass ?: return null + val fqName = DescriptorUtils.getFqName(classDescriptor).asString() + return AddDataModifierFix(klass, fqName) + } + + } + +} diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ConvertCollectionFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ConvertCollectionFix.kt new file mode 100644 index 00000000000..cfc8ab5f64b --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ConvertCollectionFix.kt @@ -0,0 +1,88 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.quickfix + +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.idea.core.replaced +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.KtPsiFactory +import org.jetbrains.kotlin.psi.createExpressionByPattern +import org.jetbrains.kotlin.psi.psiUtil.endOffset +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf + +class ConvertCollectionFix(element: KtExpression, val type: CollectionType) : KotlinQuickFixAction(element) { + override fun getFamilyName(): String = "Convert to ${type.displayName}" + override fun getText() = "Convert expression to '${type.displayName}' by inserting '.${type.functionCall}'" + + override fun invoke(project: Project, editor: Editor?, file: KtFile) { + val expression = element ?: return + val factory = KtPsiFactory(expression) + + val replaced = expression.replaced(factory.createExpressionByPattern("$0.$1", expression, type.functionCall)) + editor?.caretModel?.moveToOffset(replaced.endOffset) + } + + enum class CollectionType( + val functionCall: String, + val fqName: FqName, + private val nameOverride: String? = null + ) { + List("toList()", FqName("kotlin.collections.List")), + Collection("toList()", FqName("kotlin.collections.Collection")), + Iterable("toList()", FqName("kotlin.collections.Iterable")), + MutableList("toMutableList()", FqName("kotlin.collections.MutableList")), + Array("toTypedArray()", FqName("kotlin.Array")), + Sequence("asSequence()", FqName("kotlin.sequences.Sequence")), + + //specialized types must be last because iteration order is relevant for getCollectionType + ArrayViaList("toList().toTypedArray()", FqName("kotlin.Array"), "Array"), + ; + + val displayName get() = nameOverride ?: name + + fun specializeFor(sourceType: CollectionType) = when { + this == Array && sourceType == Sequence -> ArrayViaList + this == Array && sourceType == Iterable -> ArrayViaList + else -> this + } + } + + companion object { + private val TYPES = CollectionType.values() + + fun getConversionTypeOrNull(expressionType: KotlinType, expectedType: KotlinType): CollectionType? { + val expressionCollectionType = expressionType.getCollectionType() ?: return null + val expectedCollectionType = expectedType.getCollectionType() ?: return null + + val expressionTypeArg = expressionType.arguments.singleOrNull()?.type ?: return null + val expectedTypeArg = expectedType.arguments.singleOrNull()?.type ?: return null + if (!expressionTypeArg.isSubtypeOf(expectedTypeArg)) return null + + return expectedCollectionType.specializeFor(expressionCollectionType) + } + + private fun KotlinType.getCollectionType(): CollectionType? { + if (isMarkedNullable) return null + return TYPES.firstOrNull { KotlinBuiltIns.isConstructedFromGivenClass(this, it.fqName) } + } + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinAddRequiredModuleFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinAddRequiredModuleFix.kt new file mode 100644 index 00000000000..1e02b40f239 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinAddRequiredModuleFix.kt @@ -0,0 +1,93 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.quickfix + +import com.intellij.codeInsight.daemon.QuickFixBundle +import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil +import com.intellij.codeInsight.daemon.impl.quickfix.AddRequiredModuleFix +import com.intellij.codeInsight.intention.IntentionAction +import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project +import com.intellij.psi.* +import com.intellij.psi.util.PsiUtil +import com.intellij.util.containers.ContainerUtil +import org.jetbrains.kotlin.diagnostics.Diagnostic +import org.jetbrains.kotlin.diagnostics.DiagnosticFactory +import org.jetbrains.kotlin.idea.util.findRequireDirective +import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm + +class KotlinAddRequiredModuleFix(module: PsiJavaModule, private val requiredName: String) : LocalQuickFixAndIntentionActionOnPsiElement(module) { + override fun getFamilyName(): String = QuickFixBundle.message("module.info.add.requires.family.name") + override fun getText(): String = QuickFixBundle.message("module.info.add.requires.name", requiredName); + override fun startInWriteAction() = true + + override fun isAvailable(project: Project, file: PsiFile, startElement: PsiElement, endElement: PsiElement): Boolean { + return PsiUtil.isLanguageLevel9OrHigher(file) && + startElement is PsiJavaModule && + startElement.getManager().isInProject(startElement) && + getLBrace(startElement) != null; + } + + override fun invoke(project: Project, file: PsiFile, editor: Editor?, startElement: PsiElement, endElement: PsiElement) { + addModuleRequirement(startElement as PsiJavaModule, requiredName) + } + + companion object : KotlinSingleIntentionActionFactory() { + override fun createAction(diagnostic: Diagnostic): IntentionAction? { + val expression = diagnostic.psiElement as? KtExpression ?: return null + val javaModule = JavaModuleGraphUtil.findDescriptorByElement(expression) ?: return null + + val dependDiagnostic = DiagnosticFactory.cast(diagnostic, ErrorsJvm.JAVA_MODULE_DOES_NOT_DEPEND_ON_MODULE) + val moduleName = dependDiagnostic.a + + return KotlinAddRequiredModuleFix(javaModule, moduleName) + } + + fun addModuleRequirement(module: PsiJavaModule, requiredName: String): Boolean { + if (!module.isValid) return false + if (findRequireDirective(module, requiredName) != null) return false + + val parserFacade = JavaPsiFacade.getInstance(module.project).parserFacade + val tempModule = parserFacade.createModuleFromText("module TempModuleName { requires $requiredName; }") + val requiresStatement = tempModule.requires.first() + + val addingPlace = findAddingPlace(module) ?: return false + addingPlace.parent.addAfter(requiresStatement, addingPlace) + + return true + } + + private fun getLBrace(module: PsiJavaModule): PsiElement? { + val nameElement = module.nameIdentifier + var element: PsiElement? = nameElement.nextSibling + while (element != null) { + if (PsiUtil.isJavaToken(element, JavaTokenType.LBRACE)) { + return element + } + element = element.nextSibling + } + return null // module-info is incomplete + } + + private fun findAddingPlace(module: PsiJavaModule): PsiElement? { + val addingPlace = module.requires.lastOrNull() + return addingPlace ?: getLBrace(module) + } + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.kt index d82049a6892..bd31eeeba42 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -116,6 +116,10 @@ class QuickFixFactoryForTypeMismatchError : KotlinIntentionActionsFactory() { expressionTypeDeclaration?.let { actions.add(LetImplementInterfaceFix(it, expectedType, expressionType)) } } + ConvertCollectionFix.getConversionTypeOrNull(expressionType, expectedType)?.let { + actions.add(ConvertCollectionFix(diagnosticElement, it)) + } + fun KtExpression.getTopMostQualifiedForSelectorIfAny(): KtExpression { var qualifiedOrThis = this do { @@ -245,3 +249,4 @@ class QuickFixFactoryForTypeMismatchError : KotlinIntentionActionsFactory() { } } } + diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index 37e50c29920..b212203a1bf 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -158,7 +158,7 @@ class QuickFixRegistrar : QuickFixContributor { FUNCTION_EXPECTED.registerFactory(InvokeImportFix) DELEGATE_SPECIAL_FUNCTION_MISSING.registerFactory(DelegateAccessorsImportFix) - COMPONENT_FUNCTION_MISSING.registerFactory(ComponentsImportFix) + COMPONENT_FUNCTION_MISSING.registerFactory(ComponentsImportFix, AddDataModifierFix) NO_GET_METHOD.registerFactory(ArrayAccessorImportFix) NO_SET_METHOD.registerFactory(ArrayAccessorImportFix) @@ -516,5 +516,10 @@ class QuickFixRegistrar : QuickFixContributor { NO_CONSTRUCTOR.registerFactory(RemoveNoConstructorFix) ANNOTATION_USED_AS_ANNOTATION_ARGUMENT.registerFactory(RemoveAtFromAnnotationArgument) + + ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION.registerFactory(ReplaceWithArrayCallInAnnotationFix) + ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION.registerFactory(SurroundWithArrayOfWithSpreadOperatorInFunctionFix) + + JAVA_MODULE_DOES_NOT_DEPEND_ON_MODULE.registerFactory(KotlinAddRequiredModuleFix) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithArrayCallInAnnotationFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithArrayCallInAnnotationFix.kt new file mode 100644 index 00000000000..8d29c2583fe --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithArrayCallInAnnotationFix.kt @@ -0,0 +1,54 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.quickfix + +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project +import org.jetbrains.kotlin.diagnostics.Diagnostic +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getParentOfType +import org.jetbrains.kotlin.utils.addToStdlib.safeAs + +class ReplaceWithArrayCallInAnnotationFix(argument: KtExpression) : KotlinQuickFixAction(argument) { + override fun getText() = "Replace with array call" + + override fun getFamilyName() = text + + override fun invoke(project: Project, editor: Editor?, file: KtFile) { + val argument = element?.getParentOfType(false) ?: return + val spreadElement = argument.getSpreadElement() + if (spreadElement != null) + spreadElement.delete() + else + surroundWithArrayLiteral(argument) + } + + private fun surroundWithArrayLiteral(argument: KtValueArgument) { + val argumentExpression = argument.getArgumentExpression() ?: return + val factory = KtPsiFactory(argumentExpression) + val surrounded = factory.createExpressionByPattern("[$0]", argumentExpression) + + argumentExpression.replace(surrounded) + } + + companion object : KotlinSingleIntentionActionFactory() { + override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { + val element = diagnostic.psiElement.safeAs() ?: return null + return ReplaceWithArrayCallInAnnotationFix(element) + } + } +} diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/SimplifyComparisonFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/SimplifyComparisonFix.kt index 84de5c4e90c..48d715e5b19 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/SimplifyComparisonFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/SimplifyComparisonFix.kt @@ -21,6 +21,7 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.DiagnosticWithParameters2 +import org.jetbrains.kotlin.idea.core.replaced import org.jetbrains.kotlin.idea.intentions.SimplifyBooleanWithConstantsIntention import org.jetbrains.kotlin.psi.KtBinaryExpression import org.jetbrains.kotlin.psi.KtExpression @@ -35,15 +36,17 @@ class SimplifyComparisonFix(element: KtExpression, val value: Boolean) : KotlinQ override fun invoke(project: Project, editor: Editor?, file: KtFile) { val element = element ?: return - val parent = element.parent val replacement = KtPsiFactory(element).createExpression("$value") - element.replace(replacement) + val result = element.replaced(replacement) - val booleanExpression = parent.getNonStrictParentOfType() ?: return + val booleanExpression = result.getNonStrictParentOfType() val simplifyIntention = SimplifyBooleanWithConstantsIntention() - if (simplifyIntention.isApplicableTo(booleanExpression)) { + if (booleanExpression != null && simplifyIntention.isApplicableTo(booleanExpression)) { simplifyIntention.applyTo(booleanExpression, editor) } + else { + simplifyIntention.removeRedundantAssertion(result) + } } companion object : KotlinSingleIntentionActionFactory() { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/SurroundWithArrayOfWithSpreadOperatorInFunctionFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/SurroundWithArrayOfWithSpreadOperatorInFunctionFix.kt new file mode 100644 index 00000000000..5ab4096d6b0 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/SurroundWithArrayOfWithSpreadOperatorInFunctionFix.kt @@ -0,0 +1,60 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.quickfix + +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.diagnostics.Diagnostic +import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getParentOfType +import org.jetbrains.kotlin.resolve.CollectionLiteralResolver.Companion.ARRAY_OF_FUNCTION +import org.jetbrains.kotlin.resolve.CollectionLiteralResolver.Companion.PRIMITIVE_TYPE_TO_ARRAY + +class SurroundWithArrayOfWithSpreadOperatorInFunctionFix( + val wrapper: Name, + argument: KtExpression +) : KotlinQuickFixAction(argument) { + override fun getText() = "Surround with *$wrapper(...)" + + override fun getFamilyName() = text + + override fun invoke(project: Project, editor: Editor?, file: KtFile) { + val argument = element?.getParentOfType(false) ?: return + val argumentName = argument.getArgumentName()?.asName ?: return + val argumentExpression = argument.getArgumentExpression() ?: return + + val factory = KtPsiFactory(argumentExpression) + + val surroundedWithArrayOf = factory.createExpressionByPattern("$wrapper($0)", argumentExpression) + val newArgument = factory.createArgument(surroundedWithArrayOf, argumentName, isSpread = true) + + argument.replace(newArgument) + } + + companion object : KotlinSingleIntentionActionFactory() { + override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { + val actualDiagnostic = Errors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION.cast(diagnostic) + val parameterType = actualDiagnostic.a + + val wrapper = PRIMITIVE_TYPE_TO_ARRAY[KotlinBuiltIns.getPrimitiveArrayElementType(parameterType)] ?: ARRAY_OF_FUNCTION + return SurroundWithArrayOfWithSpreadOperatorInFunctionFix(wrapper, actualDiagnostic.psiElement) + } + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinDeclarationsHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinDeclarationsHandler.kt index 683cf6101e9..720bf2c3d2c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinDeclarationsHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinDeclarationsHandler.kt @@ -39,6 +39,8 @@ import com.intellij.util.IncorrectOperationException import com.intellij.util.containers.MultiMap import org.jetbrains.annotations.TestOnly import org.jetbrains.kotlin.idea.codeInsight.shorten.performDelayedRefactoringRequests +import org.jetbrains.kotlin.idea.core.getPackage +import org.jetbrains.kotlin.idea.core.packageMatchesDirectory import org.jetbrains.kotlin.idea.refactoring.checkConflictsInteractively import org.jetbrains.kotlin.idea.refactoring.createKotlinFile import org.jetbrains.kotlin.idea.refactoring.move.* @@ -63,8 +65,11 @@ class CopyKotlinDeclarationsHandler : CopyHandlerDelegateBase() { @set:TestOnly var Project.newName: String? by UserDataProperty(Key.create("NEW_NAME")) - private fun PsiElement.getElementsToCopy(): List { - val declarationOrFile = parentsWithSelf.firstOrNull { it is KtFile || (it is KtNamedDeclaration && it.parent is KtFile) } + private fun PsiElement.getCopyableElement() = + parentsWithSelf.firstOrNull { it is KtFile || (it is KtNamedDeclaration && it.parent is KtFile) } as? KtElement + + private fun PsiElement.getDeclarationsToCopy(): List { + val declarationOrFile = getCopyableElement() return when (declarationOrFile) { is KtFile -> declarationOrFile.declarations.filterIsInstance().ifEmpty { listOf(declarationOrFile) } is KtNamedDeclaration -> listOf(declarationOrFile) @@ -90,7 +95,7 @@ class CopyKotlinDeclarationsHandler : CopyHandlerDelegateBase() { private fun canCopyDeclarations(elements: Array): Boolean { val containingFile = elements - .flatMap { it.getElementsToCopy().ifEmpty { return false } } + .flatMap { it.getDeclarationsToCopy().ifEmpty { return false } } .distinctBy { it.containingFile } .singleOrNull() ?.containingFile ?: return false @@ -174,7 +179,7 @@ class CopyKotlinDeclarationsHandler : CopyHandlerDelegateBase() { return copyFilesHandler.doCopy(sourceFiles, defaultTargetDirectory) } - val elementsToCopy = elements.flatMap { it.getElementsToCopy() } + val elementsToCopy = elements.mapNotNull { it.getCopyableElement() } if (elementsToCopy.isEmpty()) return val singleElementToCopy = elementsToCopy.singleOrNull() @@ -182,6 +187,8 @@ class CopyKotlinDeclarationsHandler : CopyHandlerDelegateBase() { val originalFile = elementsToCopy.first().containingFile as KtFile val initialTargetDirectory = defaultTargetDirectory ?: originalFile.containingDirectory ?: return + val isSingleDeclarationInFile = singleElementToCopy is KtNamedDeclaration && originalFile.declarations.singleOrNull() == singleElementToCopy + val project = initialTargetDirectory.project val commandName = "Copy Declarations" @@ -244,19 +251,31 @@ class CopyKotlinDeclarationsHandler : CopyHandlerDelegateBase() { val oldToNewElementsMapping = HashMap() + val fileToCopy = when { + singleElementToCopy is KtFile -> singleElementToCopy + isSingleDeclarationInFile -> originalFile + else -> null + } + val targetFile: KtFile - if (singleElementToCopy is KtFile) { + val copiedDeclaration: KtNamedDeclaration? + if (fileToCopy != null) { targetFile = runWriteAction { - val copiedFile = targetDirectory.copyFileFrom(targetFileName, singleElementToCopy) as KtFile + val copiedFile = targetDirectory.copyFileFrom(targetFileName, fileToCopy) as KtFile + if (fileToCopy.packageMatchesDirectory()) { + targetDirectory.getPackage()?.qualifiedName?.let { copiedFile.packageFqName = FqName(it) } + } performDelayedRefactoringRequests(project) copiedFile } + copiedDeclaration = if (isSingleDeclarationInFile) targetFile.declarations.singleOrNull() as? KtNamedDeclaration else null } else { targetFile = getOrCreateTargetFile(originalFile, targetDirectory, targetFileName, commandName) ?: return@executeCommand runWriteAction { val newElements = elementsToCopy.map { targetFile.add(it.copy()) as KtNamedDeclaration } elementsToCopy.zip(newElements).toMap(oldToNewElementsMapping) + oldToNewElementsMapping[originalFile] = targetFile for (newElement in oldToNewElementsMapping.values) { restoredInternalUsages += restoreInternalUsages(newElement as KtElement, oldToNewElementsMapping, true) @@ -265,9 +284,10 @@ class CopyKotlinDeclarationsHandler : CopyHandlerDelegateBase() { performDelayedRefactoringRequests(project) } + copiedDeclaration = oldToNewElementsMapping.values.filterIsInstance().singleOrNull() } - (oldToNewElementsMapping.values.singleOrNull() as? KtNamedDeclaration)?.let { newDeclaration -> + copiedDeclaration?.let { newDeclaration -> if (newName == newDeclaration.name) return@let val selfReferences = ReferencesSearch.search(newDeclaration, LocalSearchScope(newDeclaration)).findAll() runWriteAction { @@ -293,7 +313,7 @@ class CopyKotlinDeclarationsHandler : CopyHandlerDelegateBase() { if (!(isUnitTestMode && BaseRefactoringProcessor.ConflictsInTestsException.isTestIgnore())) { val targetSourceRootPsi = targetSourceRoot?.toPsiDirectory(project) - if (targetSourceRootPsi != null) { + if (targetSourceRootPsi != null && project == originalFile.project) { val conflictChecker = MoveConflictChecker( project, elementsToCopy, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsCopyPasteProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsCopyPasteProcessor.kt index b1d63670ee2..0b3a2599afd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsCopyPasteProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsCopyPasteProcessor.kt @@ -21,6 +21,7 @@ import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.RangeMarker +import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.Project import com.intellij.openapi.util.Ref import com.intellij.openapi.util.TextRange @@ -56,6 +57,8 @@ class MoveDeclarationsCopyPasteProcessor : CopyPastePostProcessor { + if (DumbService.isDumb(file.project)) return emptyList() + if (file !is KtFile) return emptyList() if (startOffsets.size != 1) return emptyList() diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsProcessor.kt index 75a8da6e3d0..19119827944 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/cutPaste/MoveDeclarationsProcessor.kt @@ -23,11 +23,14 @@ import com.intellij.openapi.util.TextRange import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiManager +import com.intellij.refactoring.RefactoringBundle import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor import org.jetbrains.kotlin.idea.codeInsight.shorten.runRefactoringAndKeepDelayedRequests import org.jetbrains.kotlin.idea.conversion.copy.range import org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.* +import org.jetbrains.kotlin.idea.runSynchronouslyWithProgress import org.jetbrains.kotlin.idea.util.application.executeWriteCommand +import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.idea.util.getSourceRoot import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset @@ -117,7 +120,11 @@ class MoveDeclarationsProcessor( mover ) - val declarationUsages = declarationProcessor.findUsages().toList() + val declarationUsages = project.runSynchronouslyWithProgress(RefactoringBundle.message("progress.text"), true) { + runReadAction { + declarationProcessor.findUsages().toList() + } + } ?: return project.executeWriteCommand(commandName, commandGroupId) { project.runRefactoringAndKeepDelayedRequests { declarationProcessor.execute(declarationUsages) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt index daf216ec918..6cfa6460e88 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt @@ -149,7 +149,8 @@ fun PsiElement.getUsageContext(): PsiElement { this, KtPropertyAccessor::class.java, KtProperty::class.java, - KtFunction::class.java, + KtNamedFunction::class.java, + KtConstructor::class.java, KtClassOrObject::class.java ) ?: containingFile else -> ConflictsUtil.getContainer(this) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/KotlinChangePackageRefactoring.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/KotlinChangePackageRefactoring.kt index c3bbad637ae..b94f779c66c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/KotlinChangePackageRefactoring.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/changePackage/KotlinChangePackageRefactoring.kt @@ -16,18 +16,17 @@ package org.jetbrains.kotlin.idea.refactoring.move.changePackage -import com.intellij.openapi.vfs.VirtualFile -import com.intellij.psi.PsiDirectory -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiFile +import com.intellij.refactoring.RefactoringBundle import org.jetbrains.kotlin.idea.codeInsight.shorten.runRefactoringAndKeepDelayedRequests +import org.jetbrains.kotlin.idea.core.quoteIfNeeded import org.jetbrains.kotlin.idea.refactoring.move.ContainerChangeInfo import org.jetbrains.kotlin.idea.refactoring.move.ContainerInfo import org.jetbrains.kotlin.idea.refactoring.move.getInternalReferencesToUpdateOnPackageNameChange import org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.* import org.jetbrains.kotlin.idea.refactoring.move.postProcessMoveUsages -import org.jetbrains.kotlin.idea.core.quoteIfNeeded +import org.jetbrains.kotlin.idea.runSynchronouslyWithProgress import org.jetbrains.kotlin.idea.util.application.executeWriteCommand +import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtNamedDeclaration @@ -50,7 +49,11 @@ class KotlinChangePackageRefactoring(val file: KtFile) { Mover.Idle // we don't need to move any declarations physically ) - val declarationUsages = declarationProcessor.findUsages().toList() + val declarationUsages = project.runSynchronouslyWithProgress(RefactoringBundle.message("progress.text"), true) { + runReadAction { + declarationProcessor.findUsages().toList() + } + } ?: return val changeInfo = ContainerChangeInfo(ContainerInfo.Package(currentFqName), ContainerInfo.Package(newFqName)) val internalUsages = file.getInternalReferencesToUpdateOnPackageNameChange(changeInfo) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/MoveDeclarationToSeparateFileIntention.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/MoveDeclarationToSeparateFileIntention.kt index aa9cce1020f..55fe22d1eb1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/MoveDeclarationToSeparateFileIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/MoveDeclarationToSeparateFileIntention.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations -import com.intellij.codeInsight.actions.OptimizeImportsProcessor import com.intellij.codeInsight.intention.LowPriorityAction import com.intellij.codeInsight.navigation.NavigationUtil import com.intellij.openapi.application.ApplicationManager @@ -29,7 +28,6 @@ import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention import org.jetbrains.kotlin.idea.core.moveCaret import org.jetbrains.kotlin.idea.refactoring.createKotlinFile import org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.ui.MoveKotlinTopLevelDeclarationsDialog -import org.jetbrains.kotlin.idea.refactoring.runRefactoringWithPostprocessing import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.KtClassOrObject @@ -108,9 +106,6 @@ class MoveDeclarationToSeparateFileIntention : } ) - val move = { MoveKotlinDeclarationsProcessor(descriptor).run() } - val optimizeImports = { OptimizeImportsProcessor(project, file).run() } - - move.runRefactoringWithPostprocessing(project, MoveKotlinDeclarationsProcessor.REFACTORING_ID, optimizeImports) + MoveKotlinDeclarationsProcessor(descriptor).run() } } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/MoveKotlinDeclarationsProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/MoveKotlinDeclarationsProcessor.kt index bdd3d56eeae..c10a38dd99c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/MoveKotlinDeclarationsProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/MoveKotlinDeclarationsProcessor.kt @@ -41,6 +41,7 @@ import com.intellij.util.containers.MultiMap import gnu.trove.THashMap import gnu.trove.TObjectHashingStrategy import org.jetbrains.kotlin.asJava.elements.KtLightDeclaration +import org.jetbrains.kotlin.asJava.namedUnwrappedElement import org.jetbrains.kotlin.asJava.toLightElements import org.jetbrains.kotlin.idea.codeInsight.shorten.addToBeShortenedDescendantsToWaitingSet import org.jetbrains.kotlin.idea.core.deleteSingle @@ -48,6 +49,9 @@ import org.jetbrains.kotlin.idea.refactoring.fqName.getKotlinFqName import org.jetbrains.kotlin.idea.refactoring.move.* import org.jetbrains.kotlin.idea.refactoring.move.moveFilesOrDirectories.MoveKotlinClassHandler import org.jetbrains.kotlin.idea.search.projectScope +import org.jetbrains.kotlin.idea.util.projectStructure.getModule +import org.jetbrains.kotlin.idea.util.projectStructure.module +import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext @@ -92,7 +96,8 @@ class MoveDeclarationsDescriptor @JvmOverloads constructor( val deleteSourceFiles: Boolean = false, val moveCallback: MoveCallback? = null, val openInEditor: Boolean = false, - val allElementsToMove: List? = null + val allElementsToMove: List? = null, + val analyzeConflicts: Boolean = true ) class ConflictUsageInfo(element: PsiElement, val messages: Collection) : UsageInfo(element) @@ -149,8 +154,18 @@ class MoveKotlinDeclarationsProcessor( val newContainerName = descriptor.moveTarget.targetContainerFqName?.asString() ?: "" + fun canSkipUsages(element: PsiElement): Boolean { + val ktDeclaration = element.namedUnwrappedElement as? KtNamedDeclaration ?: return false + if (ktDeclaration.hasModifier(KtTokens.PRIVATE_KEYWORD)) return false + val (oldContainer, newContainer) = descriptor.delegate.getContainerChangeInfo(ktDeclaration, descriptor.moveTarget) + val targetModule = descriptor.moveTarget.targetFile?.getModule(project) ?: return false + return oldContainer == newContainer && ktDeclaration.module == targetModule + } + fun collectUsages(kotlinToLightElements: Map>, result: MutableCollection) { kotlinToLightElements.values.flatten().flatMapTo(result) { lightElement -> + if (canSkipUsages(lightElement)) return@flatMapTo emptyList() + val newFqName = StringUtil.getQualifiedName(newContainerName, lightElement.name) val foundReferences = HashSet() @@ -212,8 +227,10 @@ class MoveKotlinDeclarationsProcessor( internalUsages += descriptor.delegate.findInternalUsages(descriptor) collectUsages(kotlinToLightElements, externalUsages) - conflictChecker.checkAllConflicts(externalUsages, internalUsages, conflicts) - descriptor.delegate.collectConflicts(descriptor, internalUsages, conflicts) + if (descriptor.analyzeConflicts) { + conflictChecker.checkAllConflicts(externalUsages, internalUsages, conflicts) + descriptor.delegate.collectConflicts(descriptor, internalUsages, conflicts) + } usages += internalUsages usages += externalUsages diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/moveConflictUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/moveConflictUtils.kt index f5ce7703948..5239506bf37 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/moveConflictUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/moveConflictUtils.kt @@ -48,6 +48,8 @@ import org.jetbrains.kotlin.idea.refactoring.getUsageContext import org.jetbrains.kotlin.idea.refactoring.move.KotlinMoveUsage import org.jetbrains.kotlin.idea.search.and import org.jetbrains.kotlin.idea.search.not +import org.jetbrains.kotlin.idea.util.projectStructure.getModule +import org.jetbrains.kotlin.idea.util.projectStructure.module import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.contains @@ -164,11 +166,11 @@ class MoveConflictChecker( // Based on RefactoringConflictsUtil.analyzeModuleConflicts fun analyzeModuleConflictsInUsages(project: Project, usages: Collection, - sourceRoot: VirtualFile, + targetFile: VirtualFile, conflicts: MultiMap) { - val targetModule = ModuleUtilCore.findModuleForFile(sourceRoot, project) ?: return + val targetModule = targetFile.getModule(project) ?: return - val isInTestSources = ModuleRootManager.getInstance(targetModule).fileIndex.isInTestSourceContent(sourceRoot) + val isInTestSources = ModuleRootManager.getInstance(targetModule).fileIndex.isInTestSourceContent(targetFile) NextUsage@ for (usage in usages) { val element = usage.element ?: continue if (PsiTreeUtil.getParentOfType(element, PsiImportStatement::class.java, false) != null) continue @@ -177,9 +179,7 @@ class MoveConflictChecker( val resolveScope = element.resolveScope if (resolveScope.isSearchInModuleContent(targetModule, isInTestSources)) continue - val usageFile = element.containingFile - val usageVFile = usageFile.virtualFile ?: continue - val usageModule = ModuleUtilCore.findModuleForFile(usageVFile, project) ?: continue + val usageModule = element.module ?: continue val scopeDescription = RefactoringUIUtil.getDescription(element.getUsageContext(), true) val referencedElement = (if (usage is MoveRenameUsageInfo) usage.referencedElement else usage.element) ?: error(usage) val message = if (usageModule == targetModule && isInTestSources) { @@ -200,9 +200,9 @@ class MoveConflictChecker( fun checkModuleConflictsInUsages(externalUsages: MutableSet, conflicts: MultiMap) { val newConflicts = MultiMap() - val sourceRoot = moveTarget.targetFile ?: return + val targetFile = moveTarget.targetFile ?: return - analyzeModuleConflictsInUsages(project, externalUsages, sourceRoot, newConflicts) + analyzeModuleConflictsInUsages(project, externalUsages, targetFile, newConflicts) if (!newConflicts.isEmpty) { val referencedElementsToSkip = newConflicts.keySet().mapNotNullTo(HashSet()) { it.namedUnwrappedElement } externalUsages.removeIf { @@ -242,8 +242,8 @@ class MoveConflictChecker( internalUsages: MutableSet, conflicts: MultiMap ) { - val sourceRoot = moveTarget.targetFile ?: return - val targetModule = ModuleUtilCore.findModuleForFile(sourceRoot, project) ?: return + val targetFile = moveTarget.targetFile ?: return + val targetModule = targetFile.getModule(project) ?: return val resolveScope = targetModule.getScopeWithPlatformAwareDependencies() fun isInScope(targetElement: PsiElement, targetDescriptor: DeclarationDescriptor): Boolean { @@ -255,7 +255,7 @@ class MoveConflictChecker( val renderedImportableTarget = DESCRIPTOR_RENDERER_FOR_COMPARISON.render(importableDescriptor) val renderedTarget by lazy { DESCRIPTOR_RENDERER_FOR_COMPARISON.render(targetDescriptor) } - val targetModuleInfo = getModuleInfoByVirtualFile(project, sourceRoot) + val targetModuleInfo = getModuleInfoByVirtualFile(project, targetFile) val dummyFile = KtPsiFactory(targetElement.project).createFile("dummy.kt", "").apply { moduleInfo = targetModuleInfo targetPlatform = TargetPlatformDetector.getPlatform(targetModule) @@ -288,6 +288,8 @@ class MoveConflictChecker( val referencesToSkip = HashSet() for (declaration in elementsToMove - doNotGoIn) { + if (declaration.module == targetModule) continue + declaration.forEachDescendantOfType { refExpr -> val targetDescriptor = refExpr.analyze(BodyResolveMode.PARTIAL)[BindingContext.REFERENCE_TARGET, refExpr] ?: return@forEachDescendantOfType @@ -328,15 +330,19 @@ class MoveConflictChecker( val referencedElement = usage.referencedElement?.namedUnwrappedElement as? KtNamedDeclaration ?: continue val referencedDescriptor = resolutionFacade.resolveToDescriptor(referencedElement) + if (referencedDescriptor is DeclarationDescriptorWithVisibility + && referencedDescriptor.visibility == Visibilities.PUBLIC) continue + val container = element.getUsageContext() if (!declarationToContainers.getOrPut(referencedElement) { HashSet() }.add(container)) continue + val targetContainer = moveTarget.getContainerDescriptor() ?: continue + val referencingDescriptor = when (container) { is KtDeclaration -> container.unsafeResolveToDescriptor() is PsiMember -> container.getJavaMemberDescriptor() else -> null } ?: continue - val targetContainer = moveTarget.getContainerDescriptor() ?: continue val descriptorToCheck = referencedDescriptor.asPredicted(targetContainer) ?: continue if (referencedDescriptor.isVisibleIn(referencingDescriptor) && !descriptorToCheck.isVisibleIn(referencingDescriptor)) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveDirectoryWithClassesHelper.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveDirectoryWithClassesHelper.kt index b3c6b3896f6..de3600c69ae 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveDirectoryWithClassesHelper.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/KotlinMoveDirectoryWithClassesHelper.kt @@ -32,6 +32,8 @@ import org.jetbrains.kotlin.idea.refactoring.invokeOnceOnCommandFinish import org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.KotlinDirectoryMoveTarget import org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.MoveKotlinDeclarationsProcessor import org.jetbrains.kotlin.idea.refactoring.move.moveDeclarations.analyzeConflictsInFile +import org.jetbrains.kotlin.idea.runSynchronouslyWithProgress +import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtFile import java.util.* @@ -68,7 +70,7 @@ class KotlinMoveDirectoryWithClassesHelper : MoveDirectoryWithClassesHelper() { project: Project) { filesToMove .filterIsInstance() - .mapTo(result) { FileUsagesWrapper(it, fileHandler.findUsages(it, null, searchInComments, searchInNonJavaFiles), null) } + .mapTo(result) { FileUsagesWrapper(it, fileHandler.findUsages(it, null, false), null) } } override fun preprocessUsages( @@ -83,8 +85,12 @@ class KotlinMoveDirectoryWithClassesHelper : MoveDirectoryWithClassesHelper() { for ((index, usageInfo) in infos.withIndex()) { if (usageInfo !is FileUsagesWrapper) continue - analyzeConflictsInFile(usageInfo.psiFile, usageInfo.usages, moveTarget, files, conflicts) { - infos[index] = usageInfo.copy(usages = it) + project.runSynchronouslyWithProgress("Analyzing conflicts in ${usageInfo.psiFile.name}", false) { + runReadAction { + analyzeConflictsInFile(usageInfo.psiFile, usageInfo.usages, moveTarget, files, conflicts) { + infos[index] = usageInfo.copy(usages = it) + } + } } } } @@ -103,7 +109,7 @@ class KotlinMoveDirectoryWithClassesHelper : MoveDirectoryWithClassesHelper() { ): Boolean { if (file !is KtFile) return false - val moveDeclarationsProcessor = fileHandler.initMoveProcessor(file, moveDestination) + val moveDeclarationsProcessor = fileHandler.initMoveProcessor(file, moveDestination, false) val moveContextMap = getOrCreateMoveContextMap() moveContextMap[file] = MoveContext(moveDestination, moveDeclarationsProcessor) if (moveDeclarationsProcessor != null) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/MoveKotlinFileHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/MoveKotlinFileHandler.kt index cbc13a9c125..9dd34706fa2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/MoveKotlinFileHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveFilesOrDirectories/MoveKotlinFileHandler.kt @@ -73,7 +73,7 @@ class MoveKotlinFileHandler : MoveFileHandler() { return ContainerChangeInfo(ContainerInfo.Package(oldPackageName), ContainerInfo.Package(newPackageName.toSafe())) } - fun initMoveProcessor(psiFile: PsiFile, newParent: PsiDirectory?): MoveKotlinDeclarationsProcessor? { + fun initMoveProcessor(psiFile: PsiFile, newParent: PsiDirectory?, withConflicts: Boolean): MoveKotlinDeclarationsProcessor? { if (psiFile !is KtFile) return null val packageNameInfo = psiFile.getPackageNameInfo(newParent, false) ?: return null @@ -98,7 +98,8 @@ class MoveKotlinFileHandler : MoveFileHandler() { moveTarget = moveTarget, delegate = MoveDeclarationsDelegate.TopLevel, scanEntireFile = true, - allElementsToMove = psiFile.allElementsToMove + allElementsToMove = psiFile.allElementsToMove, + analyzeConflicts = withConflicts ), Mover.Idle ) @@ -114,11 +115,19 @@ class MoveKotlinFileHandler : MoveFileHandler() { newParent: PsiDirectory?, searchInComments: Boolean, searchInNonJavaFiles: Boolean + ): List { + return findUsages(psiFile, newParent, true) + } + + fun findUsages( + psiFile: PsiFile, + newParent: PsiDirectory?, + withConflicts: Boolean ): List { if (psiFile !is KtFile) return emptyList() val usages = arrayListOf(FileInfo(psiFile)) - initMoveProcessor(psiFile, newParent)?.let { + initMoveProcessor(psiFile, newParent, withConflicts)?.let { usages += it.findUsages() usages += it.getConflictsAsUsages() } @@ -127,7 +136,7 @@ class MoveKotlinFileHandler : MoveFileHandler() { override fun prepareMovedFile(file: PsiFile, moveDestination: PsiDirectory, oldToNewMap: MutableMap) { if (file !is KtFile) return - val moveProcessor = initMoveProcessor(file, moveDestination) ?: return + val moveProcessor = initMoveProcessor(file, moveDestination, false) ?: return val moveContext = MoveContext(file, moveProcessor) oldToNewMap[moveContext] = moveContext val packageNameInfo = file.getPackageNameInfo(moveDestination, true) ?: return diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt index 494e6e15152..c7e1671c5da 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt @@ -70,12 +70,20 @@ sealed class ContainerInfo { override fun matches(descriptor: DeclarationDescriptor): Boolean { return descriptor is PackageFragmentDescriptor && descriptor.fqName == fqName } + + override fun equals(other: Any?) = other is Package && other.fqName == fqName + + override fun hashCode() = fqName.hashCode() } class Class(override val fqName: FqName) : ContainerInfo() { override fun matches(descriptor: DeclarationDescriptor): Boolean { return descriptor is ClassDescriptor && descriptor.importableFqName == fqName } + + override fun equals(other: Any?) = other is Class && other.fqName == fqName + + override fun hashCode() = fqName.hashCode() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java b/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfiguration.java similarity index 88% rename from idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java rename to idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfiguration.java index 6c5a2b0fe70..ee51a0282a6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java +++ b/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfiguration.java @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.idea.run; +import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil; import com.intellij.diagnostic.logging.LogConfigurationPanel; import com.intellij.execution.*; import com.intellij.execution.application.BaseJavaApplicationCommandLineState; @@ -30,19 +31,20 @@ import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.options.SettingsEditor; import com.intellij.openapi.options.SettingsEditorGroup; +import com.intellij.openapi.project.DumbService; +import com.intellij.openapi.projectRoots.JavaSdkVersion; +import com.intellij.openapi.projectRoots.ex.JavaSdkUtil; import com.intellij.openapi.roots.*; import com.intellij.openapi.util.DefaultJDOMExternalizer; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiMethod; -import com.intellij.psi.PsiPackage; +import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.refactoring.listeners.RefactoringElementAdapter; import com.intellij.refactoring.listeners.RefactoringElementListener; +import com.intellij.util.PathsList; import kotlin.collections.ArraysKt; import kotlin.collections.CollectionsKt; import kotlin.jvm.functions.Function1; @@ -62,7 +64,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; import java.util.*; -public class JetRunConfiguration extends ModuleBasedConfiguration +public class KotlinRunConfiguration extends ModuleBasedConfiguration implements CommonJavaRunConfigurationParameters, RefactoringListenerProvider { public String MAIN_CLASS_NAME; @@ -75,7 +77,7 @@ public class JetRunConfiguration extends ModuleBasedConfiguration myEnvs = new LinkedHashMap(); public boolean PASS_PARENT_ENVS = true; - public JetRunConfiguration(String name, RunConfigurationModule runConfigurationModule, ConfigurationFactory factory) { + public KotlinRunConfiguration(String name, JavaRunConfigurationModule runConfigurationModule, ConfigurationFactory factory) { super(name, runConfigurationModule, factory); runConfigurationModule.init(); } @@ -94,10 +96,10 @@ public class JetRunConfiguration extends ModuleBasedConfiguration getConfigurationEditor() { - SettingsEditorGroup group = new SettingsEditorGroup(); - group.addEditor(ExecutionBundle.message("run.configuration.configuration.tab.title"), new JetRunConfigurationEditor(getProject())); + SettingsEditorGroup group = new SettingsEditorGroup(); + group.addEditor(ExecutionBundle.message("run.configuration.configuration.tab.title"), new KotlinRunConfigurationEditor(getProject())); JavaRunConfigurationExtensionManager.getInstance().appendEditors(this, group); - group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel()); + group.addEditor(ExecutionBundle.message("logs.tab.title"), new LogConfigurationPanel()); return group; } @@ -335,15 +337,15 @@ public class JetRunConfiguration extends ModuleBasedConfiguration { - public MyJavaCommandLineState(@NotNull JetRunConfiguration configuration, ExecutionEnvironment environment) { + private static class MyJavaCommandLineState extends BaseJavaApplicationCommandLineState { + public MyJavaCommandLineState(@NotNull KotlinRunConfiguration configuration, ExecutionEnvironment environment) { super(environment, configuration); } @Override protected JavaParameters createJavaParameters() throws ExecutionException { JavaParameters params = new JavaParameters(); - RunConfigurationModule module = myConfiguration.getConfigurationModule(); + JavaRunConfigurationModule module = myConfiguration.getConfigurationModule(); int classPathType = getClasspathType(module); @@ -352,6 +354,7 @@ public class JetRunConfiguration extends ModuleBasedConfiguration JavaModuleGraphUtil.findDescriptorByElement(module.findClass(params.getMainClass()))); + if (mainModule != null) { + params.setModuleName(mainModule.getName()); + PathsList classPath = params.getClassPath(); + PathsList modulePath = params.getModulePath(); + + modulePath.addAll(classPath.getPathList()); + classPath.clear(); + } + } + } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfigurationEditor.form b/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationEditor.form similarity index 97% rename from idea/src/org/jetbrains/kotlin/idea/run/JetRunConfigurationEditor.form rename to idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationEditor.form index 95c2ef7ca02..fa415648544 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfigurationEditor.form +++ b/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationEditor.form @@ -1,5 +1,5 @@ -
+ diff --git a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfigurationEditor.java b/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationEditor.java similarity index 91% rename from idea/src/org/jetbrains/kotlin/idea/run/JetRunConfigurationEditor.java rename to idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationEditor.java index 93b3dbd27b8..c0079a739c6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfigurationEditor.java +++ b/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationEditor.java @@ -35,7 +35,7 @@ import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -public class JetRunConfigurationEditor extends SettingsEditor implements PanelWithAnchor { +public class KotlinRunConfigurationEditor extends SettingsEditor implements PanelWithAnchor { private JPanel mainPanel; private LabeledComponent mainClass; @@ -46,7 +46,7 @@ public class JetRunConfigurationEditor extends SettingsEditor(JetRunConfigurationType.getInstance()) { +class KotlinRunConfigurationProducer : RunConfigurationProducer(KotlinRunConfigurationType.getInstance()) { - override fun setupConfigurationFromContext(configuration: JetRunConfiguration, + override fun setupConfigurationFromContext(configuration: KotlinRunConfiguration, context: ConfigurationContext, sourceElement: Ref): Boolean { val location = context.location ?: return false @@ -70,7 +70,7 @@ class KotlinRunConfigurationProducer : RunConfigurationProducer() + .map { it.moduleDeclaration } + .firstOrNull { it != null } +} + +fun findRequireDirective(module: PsiJavaModule, requiredName: String): PsiRequiresStatement? = + module.requires.find { it.moduleName == requiredName } diff --git a/idea/src/org/jetbrains/kotlin/idea/util/projectStructureUtil.kt b/idea/src/org/jetbrains/kotlin/idea/util/projectStructureUtil.kt index e2f012cb7c5..e260211694b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/util/projectStructureUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/util/projectStructureUtil.kt @@ -18,13 +18,18 @@ package org.jetbrains.kotlin.idea.util.projectStructure import com.intellij.openapi.module.Module import com.intellij.openapi.module.ModuleManager +import com.intellij.openapi.module.ModuleUtilCore import com.intellij.openapi.project.Project +import com.intellij.openapi.projectRoots.JavaSdk +import com.intellij.openapi.projectRoots.JavaSdkVersion import com.intellij.openapi.projectRoots.Sdk import com.intellij.openapi.roots.ModuleRootManager import com.intellij.openapi.roots.OrderEnumerator import com.intellij.openapi.roots.OrderRootType import com.intellij.openapi.roots.libraries.Library import com.intellij.openapi.vfs.VfsUtil +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.psi.PsiElement import java.io.File fun Project.allModules() = ModuleManager.getInstance(this).modules.toList() @@ -33,6 +38,8 @@ fun Module.findLibrary(predicate: (Library) -> Boolean): Library? = OrderEnumera val Module.sdk: Sdk? get() = ModuleRootManager.getInstance(this).sdk +val Sdk.version: JavaSdkVersion? get() = JavaSdk.getInstance().getVersion(this) + fun OrderEnumerator.findLibrary(predicate: (Library) -> Boolean): Library? { var lib: Library? = null forEachLibrary { library -> @@ -67,6 +74,7 @@ fun Library.ModifiableModel.replaceFileRoot(oldFile: File, newFile: File) { replaceInRootType(OrderRootType.SOURCES) } +fun VirtualFile.getModule(project: Project) = ModuleUtilCore.findModuleForFile(this, project) - - +val PsiElement.module + get() = ModuleUtilCore.findModuleForPsiElement(this) \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryUtil.kt b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryUtil.kt index 60096d5a03e..60de5ae83fc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryUtil.kt @@ -49,6 +49,7 @@ import org.jetbrains.kotlin.idea.framework.isExternalLibrary import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.idea.util.application.runWriteAction import org.jetbrains.kotlin.idea.util.projectStructure.allModules +import org.jetbrains.kotlin.idea.util.projectStructure.version import org.jetbrains.kotlin.idea.util.runWithAlternativeResolveEnabled import org.jetbrains.kotlin.idea.vfilefinder.KotlinJavaScriptMetaFileIndex import org.jetbrains.kotlin.idea.vfilefinder.hasSomethingInPackage @@ -334,7 +335,7 @@ fun getStdlibArtifactId(sdk: Sdk?, version: String): String { return MAVEN_STDLIB_ID } - val sdkVersion = sdk?.let { JavaSdk.getInstance().getVersion(it) } + val sdkVersion = sdk?.version return when (sdkVersion) { JavaSdkVersion.JDK_1_8, JavaSdkVersion.JDK_1_9 -> MAVEN_STDLIB_ID_JRE8 JavaSdkVersion.JDK_1_7 -> MAVEN_STDLIB_ID_JRE7 @@ -346,7 +347,7 @@ fun getDefaultJvmTarget(sdk: Sdk?, version: String): JvmTarget? { if (!hasJreSpecificRuntime(version)) { return null } - val sdkVersion = sdk?.let { JavaSdk.getInstance().getVersion(it) } + val sdkVersion = sdk?.version if (sdkVersion != null && sdkVersion.isAtLeast(JavaSdkVersion.JDK_1_8)) { return JvmTarget.JVM_1_8 } diff --git a/idea/src/org/jetbrains/kotlin/idea/versions/SuppressNotificationState.java b/idea/src/org/jetbrains/kotlin/idea/versions/SuppressNotificationState.java deleted file mode 100644 index 0fabbbfe030..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/versions/SuppressNotificationState.java +++ /dev/null @@ -1,38 +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.idea.versions; - -import com.intellij.openapi.components.PersistentStateComponent; -import com.intellij.openapi.components.State; -import com.intellij.openapi.components.Storage; -import com.intellij.openapi.components.StoragePathMacros; -import com.intellij.util.xmlb.XmlSerializerUtil; - -@State(name = "SuppressABINotification", storages = {@Storage(file = StoragePathMacros.PROJECT_FILE)}) -public class SuppressNotificationState implements PersistentStateComponent { - public boolean isSuppressed; - - @Override - public SuppressNotificationState getState() { - return this; - } - - @Override - public void loadState(SuppressNotificationState state) { - XmlSerializerUtil.copyBean(state, this); - } -} diff --git a/idea/src/org/jetbrains/kotlin/idea/versions/SuppressNotificationState.kt b/idea/src/org/jetbrains/kotlin/idea/versions/SuppressNotificationState.kt new file mode 100644 index 00000000000..890c1595daf --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/versions/SuppressNotificationState.kt @@ -0,0 +1,49 @@ +/* + * 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.idea.versions + +import com.intellij.openapi.components.* +import com.intellij.openapi.module.Module +import com.intellij.openapi.project.Project +import com.intellij.util.xmlb.XmlSerializerUtil +import org.jetbrains.kotlin.idea.configuration.ModuleSourceRootGroup +import org.jetbrains.kotlin.idea.configuration.toModuleGroup + +@State(name = "SuppressABINotification", storages = arrayOf(Storage(file = StoragePathMacros.PROJECT_FILE))) +class SuppressNotificationState : PersistentStateComponent { + var isSuppressed: Boolean = false + var modulesWithSuppressedNotConfigured = sortedSetOf() + + override fun getState(): SuppressNotificationState = this + + override fun loadState(state: SuppressNotificationState) { + XmlSerializerUtil.copyBean(state, this) + } + + companion object { + fun getInstance(project: Project) = ServiceManager.getService(project, SuppressNotificationState::class.java) + + fun isKotlinNotConfiguredSuppressed(moduleGroup: ModuleSourceRootGroup): Boolean { + val baseModule = moduleGroup.baseModule + return baseModule.name in getInstance(baseModule.project).modulesWithSuppressedNotConfigured + } + + fun suppressKotlinNotConfigured(module: Module) { + getInstance(module.project).modulesWithSuppressedNotConfigured.add(module.toModuleGroup().baseModule.name) + } + } +} diff --git a/idea/src/org/jetbrains/kotlin/idea/versions/UnsupportedAbiVersionNotificationPanelProvider.kt b/idea/src/org/jetbrains/kotlin/idea/versions/UnsupportedAbiVersionNotificationPanelProvider.kt index 4cd62634f77..7bf214d0e93 100644 --- a/idea/src/org/jetbrains/kotlin/idea/versions/UnsupportedAbiVersionNotificationPanelProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/versions/UnsupportedAbiVersionNotificationPanelProvider.kt @@ -231,7 +231,7 @@ class UnsupportedAbiVersionNotificationPanelProvider(private val project: Projec fun checkAndCreate(module: Module): EditorNotificationPanel? { val state = ServiceManager.getService(project, SuppressNotificationState::class.java).state - if (state != null && state.isSuppressed) { + if (state.isSuppressed) { return null } diff --git a/idea/testData/configuration/implementsDependency/module1/module1.iml b/idea/testData/configuration/implementsDependency/module1/module1.iml new file mode 100644 index 00000000000..952af62b5e9 --- /dev/null +++ b/idea/testData/configuration/implementsDependency/module1/module1.iml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/idea/testData/configuration/implementsDependency/module1/src/foo.kt b/idea/testData/configuration/implementsDependency/module1/src/foo.kt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/testData/configuration/implementsDependency/module2/module2.iml b/idea/testData/configuration/implementsDependency/module2/module2.iml new file mode 100644 index 00000000000..8856802fb74 --- /dev/null +++ b/idea/testData/configuration/implementsDependency/module2/module2.iml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + module1 + + + + + + + + \ No newline at end of file diff --git a/idea/testData/configuration/implementsDependency/module2/src/foo.kt b/idea/testData/configuration/implementsDependency/module2/src/foo.kt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/testData/configuration/implementsDependency/projectFile.ipr b/idea/testData/configuration/implementsDependency/projectFile.ipr new file mode 100644 index 00000000000..eb21fb4ea1a --- /dev/null +++ b/idea/testData/configuration/implementsDependency/projectFile.ipr @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/idea/testData/configuration/java9WithModuleInfo/module.iml b/idea/testData/configuration/java9WithModuleInfo/module.iml new file mode 100644 index 00000000000..c90834f2d60 --- /dev/null +++ b/idea/testData/configuration/java9WithModuleInfo/module.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/idea/testData/configuration/java9WithModuleInfo/projectFile.ipr b/idea/testData/configuration/java9WithModuleInfo/projectFile.ipr new file mode 100644 index 00000000000..10606d0eb8c --- /dev/null +++ b/idea/testData/configuration/java9WithModuleInfo/projectFile.ipr @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/idea/testData/configuration/java9WithModuleInfo/src/module-info.java b/idea/testData/configuration/java9WithModuleInfo/src/module-info.java new file mode 100644 index 00000000000..10e4b444089 --- /dev/null +++ b/idea/testData/configuration/java9WithModuleInfo/src/module-info.java @@ -0,0 +1,3 @@ +module MAIN { + +} \ No newline at end of file diff --git a/idea/testData/configuration/java9WithModuleInfoWithStdlibAlready/module.iml b/idea/testData/configuration/java9WithModuleInfoWithStdlibAlready/module.iml new file mode 100644 index 00000000000..c90834f2d60 --- /dev/null +++ b/idea/testData/configuration/java9WithModuleInfoWithStdlibAlready/module.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/idea/testData/configuration/java9WithModuleInfoWithStdlibAlready/projectFile.ipr b/idea/testData/configuration/java9WithModuleInfoWithStdlibAlready/projectFile.ipr new file mode 100644 index 00000000000..10606d0eb8c --- /dev/null +++ b/idea/testData/configuration/java9WithModuleInfoWithStdlibAlready/projectFile.ipr @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/idea/testData/configuration/java9WithModuleInfoWithStdlibAlready/src/module-info.java b/idea/testData/configuration/java9WithModuleInfoWithStdlibAlready/src/module-info.java new file mode 100644 index 00000000000..975b4781323 --- /dev/null +++ b/idea/testData/configuration/java9WithModuleInfoWithStdlibAlready/src/module-info.java @@ -0,0 +1,3 @@ +module MAIN { + requires kotlin.stdlib; +} \ No newline at end of file diff --git a/idea/testData/configuration/loadAndSaveProjectWithV2FacetConfig/module.iml b/idea/testData/configuration/loadAndSaveProjectWithV2FacetConfig/module.iml index f3f20b7cbfe..bf66cb0dbcc 100644 --- a/idea/testData/configuration/loadAndSaveProjectWithV2FacetConfig/module.iml +++ b/idea/testData/configuration/loadAndSaveProjectWithV2FacetConfig/module.iml @@ -20,6 +20,7 @@ + diff --git a/idea/testData/highlighterJsr305/project/Default.kt b/idea/testData/highlighterJsr305/project/Default.kt new file mode 100644 index 00000000000..11095962c0e --- /dev/null +++ b/idea/testData/highlighterJsr305/project/Default.kt @@ -0,0 +1,5 @@ +import foo.A + +fun main(a: A) { + a.field.length +} diff --git a/idea/testData/highlighterJsr305/project/Ignore.kt b/idea/testData/highlighterJsr305/project/Ignore.kt new file mode 100644 index 00000000000..ff4506b7ea3 --- /dev/null +++ b/idea/testData/highlighterJsr305/project/Ignore.kt @@ -0,0 +1,5 @@ +import foo.A + +fun main(a: A) { + a.field.length +} diff --git a/idea/testData/highlighterJsr305/project/A.kt b/idea/testData/highlighterJsr305/project/Strict.kt similarity index 100% rename from idea/testData/highlighterJsr305/project/A.kt rename to idea/testData/highlighterJsr305/project/Strict.kt diff --git a/idea/testData/highlighterJsr305/project/Warn.kt b/idea/testData/highlighterJsr305/project/Warn.kt new file mode 100644 index 00000000000..11095962c0e --- /dev/null +++ b/idea/testData/highlighterJsr305/project/Warn.kt @@ -0,0 +1,5 @@ +import foo.A + +fun main(a: A) { + a.field.length +} diff --git a/idea/testData/inspections/recursivePropertyAccessor/logger.kt b/idea/testData/inspections/recursivePropertyAccessor/logger.kt new file mode 100644 index 00000000000..b96b745ffa9 --- /dev/null +++ b/idea/testData/inspections/recursivePropertyAccessor/logger.kt @@ -0,0 +1,7 @@ +// See KT-20104 + +interface Logger + +fun logger(f: () -> Logger): Logger = object : Logger {} + +val logger: Logger get() = logger(::logger) \ No newline at end of file diff --git a/idea/testData/inspections/replaceArrayEqualityOpWithArraysEquals/inspectionData/expected.xml b/idea/testData/inspections/replaceArrayEqualityOpWithArraysEquals/inspectionData/expected.xml index 0bf7675fc66..5a16ebbe2d2 100644 --- a/idea/testData/inspections/replaceArrayEqualityOpWithArraysEquals/inspectionData/expected.xml +++ b/idea/testData/inspections/replaceArrayEqualityOpWithArraysEquals/inspectionData/expected.xml @@ -5,6 +5,14 @@ light_idea_test_case Replace '==' with 'Arrays.equals' - Replace '==' with 'Arrays.equals' + Replace '==' with 'contentEquals' + + + test.kt + 7 + light_idea_test_case + + Replace '!=' with 'Arrays.equals' + Replace '!=' with 'contentEquals' \ No newline at end of file diff --git a/idea/testData/inspections/replaceArrayEqualityOpWithArraysEquals/test.kt b/idea/testData/inspections/replaceArrayEqualityOpWithArraysEquals/test.kt index b0a0896a5da..c95b971be8e 100644 --- a/idea/testData/inspections/replaceArrayEqualityOpWithArraysEquals/test.kt +++ b/idea/testData/inspections/replaceArrayEqualityOpWithArraysEquals/test.kt @@ -4,4 +4,5 @@ fun foo() { val c: Any? = null a == b // YES a == c // NO + a != b } \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/.inspection b/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/.inspection new file mode 100644 index 00000000000..126a7575ae8 --- /dev/null +++ b/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/.inspection @@ -0,0 +1 @@ +org.jetbrains.kotlin.idea.inspections.MigrateDiagnosticSuppressionInspection diff --git a/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/base.kt b/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/base.kt new file mode 100644 index 00000000000..133ebf98310 --- /dev/null +++ b/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/base.kt @@ -0,0 +1,2 @@ +@Suppress("HEADER_WITHOUT_IMPLEMENTATION") +class Dummy \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/base.kt.after b/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/base.kt.after new file mode 100644 index 00000000000..65c720f79b2 --- /dev/null +++ b/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/base.kt.after @@ -0,0 +1,2 @@ +@Suppress("NO_ACTUAL_FOR_EXPECT") +class Dummy \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/multiple.kt b/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/multiple.kt new file mode 100644 index 00000000000..04783a4535e --- /dev/null +++ b/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/multiple.kt @@ -0,0 +1,6 @@ +@Suppress( + "HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL", + "HEADER_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER", + "HEADER_ENUM_CONSTRUCTOR" +) +class Dummy \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/multiple.kt.after b/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/multiple.kt.after new file mode 100644 index 00000000000..03acd40338f --- /dev/null +++ b/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/multiple.kt.after @@ -0,0 +1,6 @@ +@Suppress( + "HEADER_CLASS_CONSTRUCTOR_DELEGATION_CALL", + "EXPECTED_CLASS_CONSTRUCTOR_PROPERTY_PARAMETER", + "HEADER_ENUM_CONSTRUCTOR" +) +class Dummy \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/new.kt b/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/new.kt new file mode 100644 index 00000000000..25d477acbe3 --- /dev/null +++ b/idea/testData/inspectionsLocal/migrateDiagnosticSuppression/new.kt @@ -0,0 +1,4 @@ +// PROBLEM: none + +@Suppress("NO_ACTUAL_FOR_EXPECT") +class Dummy \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/vararg.kt.after b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/vararg.kt.after index 6b1e9b59e1b..294d3e0f3c9 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/vararg.kt.after +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/vararg.kt.after @@ -2,5 +2,5 @@ annotation class Some(vararg val strings: String) -@Some(strings = *["alpha", "beta", "omega"]) +@Some(strings = ["alpha", "beta", "omega"]) class My diff --git a/idea/testData/intentions/convertToBlockBody/getterTypeInferred.kt b/idea/testData/intentions/convertToBlockBody/getterTypeInferred.kt new file mode 100644 index 00000000000..328941e0811 --- /dev/null +++ b/idea/testData/intentions/convertToBlockBody/getterTypeInferred.kt @@ -0,0 +1 @@ +val foo get() = "abc" diff --git a/idea/testData/intentions/convertToBlockBody/getterTypeInferred.kt.after b/idea/testData/intentions/convertToBlockBody/getterTypeInferred.kt.after new file mode 100644 index 00000000000..7249e365513 --- /dev/null +++ b/idea/testData/intentions/convertToBlockBody/getterTypeInferred.kt.after @@ -0,0 +1,4 @@ +val foo: String + get() { + return "abc" + } diff --git a/idea/testData/intentions/moveOutOfCompanion/moveFunctionWithExternalRefs.kt b/idea/testData/intentions/moveOutOfCompanion/moveFunctionWithExternalRefs.kt index 050c44335cd..1f289152f1f 100644 --- a/idea/testData/intentions/moveOutOfCompanion/moveFunctionWithExternalRefs.kt +++ b/idea/testData/intentions/moveOutOfCompanion/moveFunctionWithExternalRefs.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// SHOULD_FAIL_WITH: 'foo' in class B will require class instance, 'foo' in function test() will require class instance, 'foo' in function test() will require class instance, 'foo' in lambda <anonymous>() will require class instance +// SHOULD_FAIL_WITH: 'foo' in class B will require class instance, 'foo' in function test() will require class instance, 'foo' in function test() will require class instance, 'foo' in function test() will require class instance class A { companion object { class B { diff --git a/idea/testData/intentions/moveOutOfCompanion/movePropertyWithExternalRefs.kt b/idea/testData/intentions/moveOutOfCompanion/movePropertyWithExternalRefs.kt index e583ca5ffe8..6b57efdd7b5 100644 --- a/idea/testData/intentions/moveOutOfCompanion/movePropertyWithExternalRefs.kt +++ b/idea/testData/intentions/moveOutOfCompanion/movePropertyWithExternalRefs.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// SHOULD_FAIL_WITH: 'foo' in class B will require class instance, 'foo' in function test() will require class instance, 'foo' in function test() will require class instance, 'foo' in lambda <anonymous>() will require class instance +// SHOULD_FAIL_WITH: 'foo' in class B will require class instance, 'foo' in function test() will require class instance, 'foo' in function test() will require class instance, 'foo' in function test() will require class instance class A { companion object { class B { diff --git a/idea/testData/intentions/removeCurlyBracesFromTemplate/necessaryBrackets6.kt b/idea/testData/intentions/removeCurlyBracesFromTemplate/necessaryBrackets6.kt new file mode 100644 index 00000000000..d2631e4010a --- /dev/null +++ b/idea/testData/intentions/removeCurlyBracesFromTemplate/necessaryBrackets6.kt @@ -0,0 +1,5 @@ +// IS_APPLICABLE: false +fun foo() { + val x = 3 + val y = "${x}コトリン" +} \ No newline at end of file diff --git a/idea/testData/intentions/removeUnnecessaryParentheses/elvisRhs.kt b/idea/testData/intentions/removeUnnecessaryParentheses/elvisRhs.kt new file mode 100644 index 00000000000..de82156154f --- /dev/null +++ b/idea/testData/intentions/removeUnnecessaryParentheses/elvisRhs.kt @@ -0,0 +1,5 @@ +// IS_APPLICABLE: false +// WITH_RUNTIME +fun foo(): Boolean { + return ("" ?: return false) in listOf("") +} \ No newline at end of file diff --git a/idea/testData/intentions/removeUnnecessaryParentheses/elvisRhsEmptyReturn.kt b/idea/testData/intentions/removeUnnecessaryParentheses/elvisRhsEmptyReturn.kt new file mode 100644 index 00000000000..0968e2bc96e --- /dev/null +++ b/idea/testData/intentions/removeUnnecessaryParentheses/elvisRhsEmptyReturn.kt @@ -0,0 +1,7 @@ +// IS_APPLICABLE: false +// WITH_RUNTIME +fun foo() { + bar(("" ?: return) in listOf("")) +} + +fun bar(arg: Boolean) {} \ No newline at end of file diff --git a/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEQEQ.kt b/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEQEQ.kt index 8bec0b11c05..62ad7d293b1 100644 --- a/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEQEQ.kt +++ b/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEQEQ.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// INTENTION_TEXT: Replace '==' with 'Arrays.equals' +// INTENTION_TEXT: Replace '==' with 'contentEquals' fun foo() { val a = arrayOf("a", "b", "c") val b = arrayOf("a", "b", "c") diff --git a/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEQEQ.kt.after b/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEQEQ.kt.after index 106dec0a540..336db699b6c 100644 --- a/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEQEQ.kt.after +++ b/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEQEQ.kt.after @@ -1,10 +1,8 @@ -import java.util.Arrays - // WITH_RUNTIME -// INTENTION_TEXT: Replace '==' with 'Arrays.equals' +// INTENTION_TEXT: Replace '==' with 'contentEquals' fun foo() { val a = arrayOf("a", "b", "c") val b = arrayOf("a", "b", "c") - if (Arrays.equals(a, b)) { + if (a.contentEquals(b)) { } } diff --git a/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEXCLEQ.kt b/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEXCLEQ.kt new file mode 100644 index 00000000000..3f58434033d --- /dev/null +++ b/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEXCLEQ.kt @@ -0,0 +1,8 @@ +// WITH_RUNTIME +// INTENTION_TEXT: Replace '!=' with 'contentEquals' +fun foo() { + val a = arrayOf("a", "b", "c") + val b = arrayOf("a", "b", "c") + if (a != b) { + } +} diff --git a/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEXCLEQ.kt.after b/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEXCLEQ.kt.after new file mode 100644 index 00000000000..0b53d65dbec --- /dev/null +++ b/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEXCLEQ.kt.after @@ -0,0 +1,8 @@ +// WITH_RUNTIME +// INTENTION_TEXT: Replace '!=' with 'contentEquals' +fun foo() { + val a = arrayOf("a", "b", "c") + val b = arrayOf("a", "b", "c") + if (!a.contentEquals(b)) { + } +} diff --git a/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/primitiveArrayEQEQ.kt b/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/primitiveArrayEQEQ.kt index ca7b072ad07..6556b587a6a 100644 --- a/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/primitiveArrayEQEQ.kt +++ b/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/primitiveArrayEQEQ.kt @@ -1,5 +1,5 @@ // WITH_RUNTIME -// INTENTION_TEXT: Replace '==' with 'Arrays.equals' +// INTENTION_TEXT: Replace '==' with 'contentEquals' fun foo() { val a = charArrayOf('a', 'b', 'c') val b = charArrayOf('a', 'b', 'c') diff --git a/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/primitiveArrayEQEQ.kt.after b/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/primitiveArrayEQEQ.kt.after index 920bfb782a9..8471bf494e8 100644 --- a/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/primitiveArrayEQEQ.kt.after +++ b/idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/primitiveArrayEQEQ.kt.after @@ -1,10 +1,8 @@ -import java.util.Arrays - // WITH_RUNTIME -// INTENTION_TEXT: Replace '==' with 'Arrays.equals' +// INTENTION_TEXT: Replace '==' with 'contentEquals' fun foo() { val a = charArrayOf('a', 'b', 'c') val b = charArrayOf('a', 'b', 'c') - if (Arrays.equals(a, b)) { + if (a.contentEquals(b)) { } } diff --git a/idea/testData/intentions/simplifyBooleanWithConstants/assert.kt b/idea/testData/intentions/simplifyBooleanWithConstants/assert.kt new file mode 100644 index 00000000000..6d484a39085 --- /dev/null +++ b/idea/testData/intentions/simplifyBooleanWithConstants/assert.kt @@ -0,0 +1,5 @@ +// WITH_RUNTIME + +fun foo() { + assert(true || false) +} \ No newline at end of file diff --git a/idea/testData/intentions/simplifyBooleanWithConstants/assert.kt.after b/idea/testData/intentions/simplifyBooleanWithConstants/assert.kt.after new file mode 100644 index 00000000000..f6a597af433 --- /dev/null +++ b/idea/testData/intentions/simplifyBooleanWithConstants/assert.kt.after @@ -0,0 +1,4 @@ +// WITH_RUNTIME + +fun foo() { +} \ No newline at end of file diff --git a/idea/testData/joinLines/removeBraces/FunctionWithOneLineReturn.kt b/idea/testData/joinLines/removeBraces/FunctionWithOneLineReturn.kt new file mode 100644 index 00000000000..b2c88f61b4e --- /dev/null +++ b/idea/testData/joinLines/removeBraces/FunctionWithOneLineReturn.kt @@ -0,0 +1,3 @@ +fun foo(): Int { + return 1 +} diff --git a/idea/testData/joinLines/removeBraces/FunctionWithOneLineReturn.kt.after b/idea/testData/joinLines/removeBraces/FunctionWithOneLineReturn.kt.after new file mode 100644 index 00000000000..a4647ee6f2d --- /dev/null +++ b/idea/testData/joinLines/removeBraces/FunctionWithOneLineReturn.kt.after @@ -0,0 +1 @@ +fun foo(): Int = 1 \ No newline at end of file diff --git a/idea/testData/multiModuleHighlighting/multiplatform/basic/common/common.kt b/idea/testData/multiModuleHighlighting/multiplatform/basic/common/common.kt index 49885064c03..abb6e871d85 100644 --- a/idea/testData/multiModuleHighlighting/multiplatform/basic/common/common.kt +++ b/idea/testData/multiModuleHighlighting/multiplatform/basic/common/common.kt @@ -1,3 +1,3 @@ -expect class My { +expect class My { } diff --git a/idea/testData/multiModuleHighlighting/multiplatform/basic/jvm/jvm.kt b/idea/testData/multiModuleHighlighting/multiplatform/basic/jvm/jvm.kt index 420dd83b9f8..2634e8e96bf 100644 --- a/idea/testData/multiModuleHighlighting/multiplatform/basic/jvm/jvm.kt +++ b/idea/testData/multiModuleHighlighting/multiplatform/basic/jvm/jvm.kt @@ -2,7 +2,7 @@ actual class His { +expect class His { } diff --git a/idea/testData/multiModuleHighlighting/multiplatform/headerWithoutImplForBoth/common/common.kt b/idea/testData/multiModuleHighlighting/multiplatform/headerWithoutImplForBoth/common/common.kt index 2cd06749bb5..517da8f706f 100644 --- a/idea/testData/multiModuleHighlighting/multiplatform/headerWithoutImplForBoth/common/common.kt +++ b/idea/testData/multiModuleHighlighting/multiplatform/headerWithoutImplForBoth/common/common.kt @@ -1,3 +1,3 @@ -expect class My { +expect class My { } diff --git a/idea/testData/multiModuleHighlighting/multiplatform/suppressHeaderWithoutImpl/common/common.kt b/idea/testData/multiModuleHighlighting/multiplatform/suppressHeaderWithoutImpl/common/common.kt index e090b7100e0..dbfd34ba892 100644 --- a/idea/testData/multiModuleHighlighting/multiplatform/suppressHeaderWithoutImpl/common/common.kt +++ b/idea/testData/multiModuleHighlighting/multiplatform/suppressHeaderWithoutImpl/common/common.kt @@ -4,4 +4,4 @@ expect interface Event @Suppress("SOMETHING_WRONG") -expect class Wrong +expect class Wrong diff --git a/idea/testData/multiModuleHighlighting/multiplatform/transitive/common/common.kt b/idea/testData/multiModuleHighlighting/multiplatform/transitive/common/common.kt new file mode 100644 index 00000000000..f6b60713910 --- /dev/null +++ b/idea/testData/multiModuleHighlighting/multiplatform/transitive/common/common.kt @@ -0,0 +1 @@ +expect fun foo(): Int \ No newline at end of file diff --git a/idea/testData/multiModuleHighlighting/multiplatform/transitive/jvm_base/base.kt b/idea/testData/multiModuleHighlighting/multiplatform/transitive/jvm_base/base.kt new file mode 100644 index 00000000000..3ec588cd03d --- /dev/null +++ b/idea/testData/multiModuleHighlighting/multiplatform/transitive/jvm_base/base.kt @@ -0,0 +1,3 @@ +fun bar(): Int { + return 42 +} \ No newline at end of file diff --git a/idea/testData/multiModuleHighlighting/multiplatform/transitive/jvm_user/user.kt b/idea/testData/multiModuleHighlighting/multiplatform/transitive/jvm_user/user.kt new file mode 100644 index 00000000000..55ccc114ba2 --- /dev/null +++ b/idea/testData/multiModuleHighlighting/multiplatform/transitive/jvm_user/user.kt @@ -0,0 +1,3 @@ +fun user(): Int { + return 2 * bar() +} \ No newline at end of file diff --git a/idea/testData/multiModuleLineMarker/transitive/common/common.kt b/idea/testData/multiModuleLineMarker/transitive/common/common.kt new file mode 100644 index 00000000000..cc1c972043c --- /dev/null +++ b/idea/testData/multiModuleLineMarker/transitive/common/common.kt @@ -0,0 +1 @@ +expect fun foo(): Int \ No newline at end of file diff --git a/idea/testData/multiModuleLineMarker/transitive/jvm_base/base.kt b/idea/testData/multiModuleLineMarker/transitive/jvm_base/base.kt new file mode 100644 index 00000000000..ed077971da3 --- /dev/null +++ b/idea/testData/multiModuleLineMarker/transitive/jvm_base/base.kt @@ -0,0 +1,3 @@ +// !CHECK_HIGHLIGHTING + +actual fun foo() = 42 \ No newline at end of file diff --git a/idea/testData/multiModuleLineMarker/transitive/jvm_user/user.kt b/idea/testData/multiModuleLineMarker/transitive/jvm_user/user.kt new file mode 100644 index 00000000000..230123f2b07 --- /dev/null +++ b/idea/testData/multiModuleLineMarker/transitive/jvm_user/user.kt @@ -0,0 +1,3 @@ +// !CHECK_HIGHLIGHTING + +fun bar() = foo() \ No newline at end of file diff --git a/idea/testData/multiModuleQuickFix/addActualToClass/header/header.kt b/idea/testData/multiModuleQuickFix/addActualToClass/header/header.kt new file mode 100644 index 00000000000..2a3a31a2dec --- /dev/null +++ b/idea/testData/multiModuleQuickFix/addActualToClass/header/header.kt @@ -0,0 +1 @@ +expect class Foo diff --git a/idea/testData/multiModuleQuickFix/addActualToClass/header/header.kt.after b/idea/testData/multiModuleQuickFix/addActualToClass/header/header.kt.after new file mode 100644 index 00000000000..2a3a31a2dec --- /dev/null +++ b/idea/testData/multiModuleQuickFix/addActualToClass/header/header.kt.after @@ -0,0 +1 @@ +expect class Foo diff --git a/idea/testData/multiModuleQuickFix/addActualToClass/jvm/jvm.kt b/idea/testData/multiModuleQuickFix/addActualToClass/jvm/jvm.kt new file mode 100644 index 00000000000..9b309e97108 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/addActualToClass/jvm/jvm.kt @@ -0,0 +1,4 @@ +// "Add 'actual' modifier" "true" +// ERROR: Declaration should be marked with 'actual' (suppress with -Xno-check-actual) + +class Foo diff --git a/idea/testData/multiModuleQuickFix/addActualToClass/jvm/jvm.kt.after b/idea/testData/multiModuleQuickFix/addActualToClass/jvm/jvm.kt.after new file mode 100644 index 00000000000..35ba8a5b671 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/addActualToClass/jvm/jvm.kt.after @@ -0,0 +1,4 @@ +// "Add 'actual' modifier" "true" +// ERROR: Declaration should be marked with 'actual' (suppress with -Xno-check-actual) + +actual class Foo diff --git a/idea/testData/multiModuleQuickFix/addActualToClassMember/header/header.kt b/idea/testData/multiModuleQuickFix/addActualToClassMember/header/header.kt new file mode 100644 index 00000000000..35615e686a1 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/addActualToClassMember/header/header.kt @@ -0,0 +1,3 @@ +expect class Foo { + fun foo() +} diff --git a/idea/testData/multiModuleQuickFix/addActualToClassMember/header/header.kt.after b/idea/testData/multiModuleQuickFix/addActualToClassMember/header/header.kt.after new file mode 100644 index 00000000000..35615e686a1 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/addActualToClassMember/header/header.kt.after @@ -0,0 +1,3 @@ +expect class Foo { + fun foo() +} diff --git a/idea/testData/multiModuleQuickFix/addActualToClassMember/jvm/jvm.kt b/idea/testData/multiModuleQuickFix/addActualToClassMember/jvm/jvm.kt new file mode 100644 index 00000000000..77c8881cde4 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/addActualToClassMember/jvm/jvm.kt @@ -0,0 +1,6 @@ +// "Add 'actual' modifier" "true" +// ERROR: Declaration should be marked with 'actual' (suppress with -Xno-check-actual) + +actual class Foo { + fun foo() {} +} diff --git a/idea/testData/multiModuleQuickFix/addActualToClassMember/jvm/jvm.kt.after b/idea/testData/multiModuleQuickFix/addActualToClassMember/jvm/jvm.kt.after new file mode 100644 index 00000000000..fc95413ae61 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/addActualToClassMember/jvm/jvm.kt.after @@ -0,0 +1,6 @@ +// "Add 'actual' modifier" "true" +// ERROR: Declaration should be marked with 'actual' (suppress with -Xno-check-actual) + +actual class Foo { + actual fun foo() {} +} diff --git a/idea/testData/multiModuleQuickFix/addActualToTopLevelMember/header/header.kt b/idea/testData/multiModuleQuickFix/addActualToTopLevelMember/header/header.kt new file mode 100644 index 00000000000..892bde13e9c --- /dev/null +++ b/idea/testData/multiModuleQuickFix/addActualToTopLevelMember/header/header.kt @@ -0,0 +1 @@ +expect fun foo() diff --git a/idea/testData/multiModuleQuickFix/addActualToTopLevelMember/header/header.kt.after b/idea/testData/multiModuleQuickFix/addActualToTopLevelMember/header/header.kt.after new file mode 100644 index 00000000000..892bde13e9c --- /dev/null +++ b/idea/testData/multiModuleQuickFix/addActualToTopLevelMember/header/header.kt.after @@ -0,0 +1 @@ +expect fun foo() diff --git a/idea/testData/multiModuleQuickFix/addActualToTopLevelMember/jvm/jvm.kt b/idea/testData/multiModuleQuickFix/addActualToTopLevelMember/jvm/jvm.kt new file mode 100644 index 00000000000..5e347ce8e07 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/addActualToTopLevelMember/jvm/jvm.kt @@ -0,0 +1,4 @@ +// "Add 'actual' modifier" "true" +// ERROR: Declaration should be marked with 'actual' (suppress with -Xno-check-actual) + +fun foo() {} diff --git a/idea/testData/multiModuleQuickFix/addActualToTopLevelMember/jvm/jvm.kt.after b/idea/testData/multiModuleQuickFix/addActualToTopLevelMember/jvm/jvm.kt.after new file mode 100644 index 00000000000..6aefcbd3230 --- /dev/null +++ b/idea/testData/multiModuleQuickFix/addActualToTopLevelMember/jvm/jvm.kt.after @@ -0,0 +1,4 @@ +// "Add 'actual' modifier" "true" +// ERROR: Declaration should be marked with 'actual' (suppress with -Xno-check-actual) + +actual fun foo() {} diff --git a/idea/testData/quickfix/addDataModifier/abstract.kt b/idea/testData/quickfix/addDataModifier/abstract.kt new file mode 100644 index 00000000000..5c795d6a1be --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/abstract.kt @@ -0,0 +1,14 @@ +// "Make 'Foo' data class" "false" +// ACTION: Create extension function 'Foo.component1' +// ACTION: Create extension function 'Foo.component2' +// ACTION: Create member function 'Foo.component1' +// ACTION: Create member function 'Foo.component2' +// ACTION: Put arguments on separate lines +// ERROR: Cannot create an instance of an abstract class +// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type Foo must have a 'component2()' function +abstract class Foo(val bar: String, val baz: Int) + +fun test() { + var (bar, baz) = Foo("A", 1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/inner.kt b/idea/testData/quickfix/addDataModifier/inner.kt new file mode 100644 index 00000000000..f7bac564dc3 --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/inner.kt @@ -0,0 +1,14 @@ +// "Make 'Foo' data class" "false" +// ACTION: Create extension function 'Test.Foo.component1' +// ACTION: Create extension function 'Test.Foo.component2' +// ACTION: Create member function 'Test.Foo.component1' +// ACTION: Create member function 'Test.Foo.component2' +// ACTION: Put arguments on separate lines +// ERROR: Destructuring declaration initializer of type Test.Foo must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type Test.Foo must have a 'component2()' function +class Test { + inner class Foo(val bar: String, val baz: Int) + fun test() { + var (bar, baz) = Foo("A", 1) + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/invisibleParameter.kt b/idea/testData/quickfix/addDataModifier/invisibleParameter.kt new file mode 100644 index 00000000000..02f99688ce9 --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/invisibleParameter.kt @@ -0,0 +1,13 @@ +// "Make 'Foo' data class" "false" +// ACTION: Create extension function 'Foo.component1' +// ACTION: Create extension function 'Foo.component2' +// ACTION: Create member function 'Foo.component1' +// ACTION: Create member function 'Foo.component2' +// ACTION: Put arguments on separate lines +// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type Foo must have a 'component2()' function +class Foo(private val bar: String, var baz: Int) + +fun test() { + var (bar, baz) = Foo("A", 1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/invisibleParameter2.kt b/idea/testData/quickfix/addDataModifier/invisibleParameter2.kt new file mode 100644 index 00000000000..de64d29e965 --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/invisibleParameter2.kt @@ -0,0 +1,13 @@ +// "Make 'Foo' data class" "false" +// ACTION: Create extension function 'Foo.component1' +// ACTION: Create extension function 'Foo.component2' +// ACTION: Create member function 'Foo.component1' +// ACTION: Create member function 'Foo.component2' +// ACTION: Put arguments on separate lines +// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type Foo must have a 'component2()' function +class Foo(protected val bar: String, var baz: Int) + +fun test() { + var (bar, baz) = Foo("A", 1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/noParameter.kt b/idea/testData/quickfix/addDataModifier/noParameter.kt new file mode 100644 index 00000000000..0dea8fafcef --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/noParameter.kt @@ -0,0 +1,12 @@ +// "Make 'Foo' data class" "false" +// ACTION: Create extension function 'Foo.component1' +// ACTION: Create extension function 'Foo.component2' +// ACTION: Create member function 'Foo.component1' +// ACTION: Create member function 'Foo.component2' +// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type Foo must have a 'component2()' function +class Foo() + +fun test() { + var (bar, baz) = Foo() +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/notVarVal.kt b/idea/testData/quickfix/addDataModifier/notVarVal.kt new file mode 100644 index 00000000000..f456180ae3c --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/notVarVal.kt @@ -0,0 +1,13 @@ +// "Make 'Foo' data class" "false" +// ACTION: Create extension function 'Foo.component1' +// ACTION: Create extension function 'Foo.component2' +// ACTION: Create member function 'Foo.component1' +// ACTION: Create member function 'Foo.component2' +// ACTION: Put arguments on separate lines +// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type Foo must have a 'component2()' function +class Foo(val bar: String, baz: Int) + +fun test() { + var (bar, baz) = Foo("A", 1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/open.kt b/idea/testData/quickfix/addDataModifier/open.kt new file mode 100644 index 00000000000..e14740afc03 --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/open.kt @@ -0,0 +1,13 @@ +// "Make 'Foo' data class" "false" +// ACTION: Create extension function 'Foo.component1' +// ACTION: Create extension function 'Foo.component2' +// ACTION: Create member function 'Foo.component1' +// ACTION: Create member function 'Foo.component2' +// ACTION: Put arguments on separate lines +// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type Foo must have a 'component2()' function +open class Foo(val bar: String, val baz: Int) + +fun test() { + var (bar, baz) = Foo("A", 1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/sealed.kt b/idea/testData/quickfix/addDataModifier/sealed.kt new file mode 100644 index 00000000000..8724e134c39 --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/sealed.kt @@ -0,0 +1,15 @@ +// "Make 'Foo' data class" "false" +// ACTION: Create extension function 'Foo.component1' +// ACTION: Create extension function 'Foo.component2' +// ACTION: Create member function 'Foo.component1' +// ACTION: Create member function 'Foo.component2' +// ACTION: Put arguments on separate lines +// ERROR: Cannot access '': it is private in 'Foo' +// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type Foo must have a 'component2()' function +// ERROR: Sealed types cannot be instantiated +sealed class Foo(val bar: String, val baz: Int) + +fun test() { + var (bar, baz) = Foo("A", 1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test1.kt b/idea/testData/quickfix/addDataModifier/test1.kt new file mode 100644 index 00000000000..c42253debfb --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test1.kt @@ -0,0 +1,6 @@ +// "Make 'Foo' data class" "true" +class Foo(val bar: String, var baz: Int) + +fun test() { + var (bar, baz) = Foo("A", 1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test1.kt.after b/idea/testData/quickfix/addDataModifier/test1.kt.after new file mode 100644 index 00000000000..e0cf499da01 --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test1.kt.after @@ -0,0 +1,6 @@ +// "Make 'Foo' data class" "true" +data class Foo(val bar: String, var baz: Int) + +fun test() { + var (bar, baz) = Foo("A", 1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test2.kt b/idea/testData/quickfix/addDataModifier/test2.kt new file mode 100644 index 00000000000..e208ba575ba --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test2.kt @@ -0,0 +1,7 @@ +// "Make 'Foo' data class" "true" +class Foo(val bar: String, var baz: Int) + +fun test() { + val foo = Foo("A", 1) + var (bar, baz) = foo +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test2.kt.after b/idea/testData/quickfix/addDataModifier/test2.kt.after new file mode 100644 index 00000000000..1cef42725b8 --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test2.kt.after @@ -0,0 +1,7 @@ +// "Make 'Foo' data class" "true" +data class Foo(val bar: String, var baz: Int) + +fun test() { + val foo = Foo("A", 1) + var (bar, baz) = foo +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test3.kt b/idea/testData/quickfix/addDataModifier/test3.kt new file mode 100644 index 00000000000..14c14fecc37 --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test3.kt @@ -0,0 +1,9 @@ +// "Make 'Foo' data class" "true" +// WITH_RUNTIME +class Foo(val bar: String, var baz: Int) + +fun test() { + val list = listOf(Foo("A", 1)) + list.forEach { (foo, bar) -> + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test3.kt.after b/idea/testData/quickfix/addDataModifier/test3.kt.after new file mode 100644 index 00000000000..2fec927848f --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test3.kt.after @@ -0,0 +1,9 @@ +// "Make 'Foo' data class" "true" +// WITH_RUNTIME +data class Foo(val bar: String, var baz: Int) + +fun test() { + val list = listOf(Foo("A", 1)) + list.forEach { (foo, bar) -> + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test4.kt b/idea/testData/quickfix/addDataModifier/test4.kt new file mode 100644 index 00000000000..9c631d5167f --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test4.kt @@ -0,0 +1,9 @@ +// "Make 'Foo' data class" "true" +// WITH_RUNTIME +class Foo(val bar: String, var baz: Int) + +fun test() { + val list = listOf(Foo("A", 1)) + for ((foo, bar) in list) { + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test4.kt.after b/idea/testData/quickfix/addDataModifier/test4.kt.after new file mode 100644 index 00000000000..1ad3a63978e --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test4.kt.after @@ -0,0 +1,9 @@ +// "Make 'Foo' data class" "true" +// WITH_RUNTIME +data class Foo(val bar: String, var baz: Int) + +fun test() { + val list = listOf(Foo("A", 1)) + for ((foo, bar) in list) { + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test5.kt b/idea/testData/quickfix/addDataModifier/test5.kt new file mode 100644 index 00000000000..2e02b43cd7a --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test5.kt @@ -0,0 +1,6 @@ +// "Make 'Foo' data class" "true" +class Foo(private val bar: String, protected var baz: Int) { + fun test() { + var (bar, baz) = Foo("A", 1) + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test5.kt.after b/idea/testData/quickfix/addDataModifier/test5.kt.after new file mode 100644 index 00000000000..b3761069e0a --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test5.kt.after @@ -0,0 +1,6 @@ +// "Make 'Foo' data class" "true" +data class Foo(private val bar: String, protected var baz: Int) { + fun test() { + var (bar, baz) = Foo("A", 1) + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test6.kt b/idea/testData/quickfix/addDataModifier/test6.kt new file mode 100644 index 00000000000..21f8ce91d78 --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test6.kt @@ -0,0 +1,8 @@ +// "Make 'Foo' data class" "true" +class Foo(private val bar: String, protected var baz: Int) { + class A { + fun test() { + var (bar, baz) = Foo("A", 1) + } + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test6.kt.after b/idea/testData/quickfix/addDataModifier/test6.kt.after new file mode 100644 index 00000000000..e55eb2fbe4e --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test6.kt.after @@ -0,0 +1,8 @@ +// "Make 'Foo' data class" "true" +data class Foo(private val bar: String, protected var baz: Int) { + class A { + fun test() { + var (bar, baz) = Foo("A", 1) + } + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test7.kt b/idea/testData/quickfix/addDataModifier/test7.kt new file mode 100644 index 00000000000..e6954b4dca6 --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test7.kt @@ -0,0 +1,6 @@ +// "Make 'Foo' data class" "true" +class Foo(internal val bar: String, var baz: Int) + +fun test() { + var (bar, baz) = Foo("A", 1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/test7.kt.after b/idea/testData/quickfix/addDataModifier/test7.kt.after new file mode 100644 index 00000000000..fac74f191bd --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/test7.kt.after @@ -0,0 +1,6 @@ +// "Make 'Foo' data class" "true" +data class Foo(internal val bar: String, var baz: Int) + +fun test() { + var (bar, baz) = Foo("A", 1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/addDataModifier/vararg.kt b/idea/testData/quickfix/addDataModifier/vararg.kt new file mode 100644 index 00000000000..ddcc7f25a73 --- /dev/null +++ b/idea/testData/quickfix/addDataModifier/vararg.kt @@ -0,0 +1,13 @@ +// "Make 'Foo' data class" "false" +// ACTION: Create extension function 'Foo.component1' +// ACTION: Create extension function 'Foo.component2' +// ACTION: Create member function 'Foo.component1' +// ACTION: Create member function 'Foo.component2' +// ACTION: Put arguments on separate lines +// ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type Foo must have a 'component2()' function +class Foo(val bar: String, vararg var baz: Int) + +fun test() { + var (bar, baz) = Foo("A", 1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/createFromUsage/createVariable/parameter/dataClassPropertyByDestructuringEntryWithSkippedIndex.kt b/idea/testData/quickfix/createFromUsage/createVariable/parameter/dataClassPropertyByDestructuringEntryWithSkippedIndex.kt index b4af5a79a02..1b357ee00bb 100644 --- a/idea/testData/quickfix/createFromUsage/createVariable/parameter/dataClassPropertyByDestructuringEntryWithSkippedIndex.kt +++ b/idea/testData/quickfix/createFromUsage/createVariable/parameter/dataClassPropertyByDestructuringEntryWithSkippedIndex.kt @@ -1,5 +1,6 @@ // "Create property 'address2' as constructor parameter" "false" // ACTION: Create property 'address' as constructor parameter +// ACTION: Make 'Person' data class // ERROR: Destructuring declaration initializer of type Person must have a 'component3()' function // ERROR: Destructuring declaration initializer of type Person must have a 'component4()' function data class Person(val name: String, val age: Int) diff --git a/idea/testData/quickfix/implement/doNotAddHeader.kt b/idea/testData/quickfix/implement/doNotAddHeader.kt index 76753f89b4f..46d35f003cf 100644 --- a/idea/testData/quickfix/implement/doNotAddHeader.kt +++ b/idea/testData/quickfix/implement/doNotAddHeader.kt @@ -1,6 +1,6 @@ // "Implement members" "true" // ENABLE_MULTIPLATFORM -// ERROR: Expected interface 'InterfaceWithFuns' has no actual in module light_idea_test_case for JVM +// ERROR: Expected interface 'InterfaceWithFuns' has no actual declaration in module light_idea_test_case for JVM fun TODO(s: String): Nothing = null!! diff --git a/idea/testData/quickfix/implement/doNotAddHeader.kt.after b/idea/testData/quickfix/implement/doNotAddHeader.kt.after index ca0abbf627a..6877b34b893 100644 --- a/idea/testData/quickfix/implement/doNotAddHeader.kt.after +++ b/idea/testData/quickfix/implement/doNotAddHeader.kt.after @@ -1,6 +1,6 @@ // "Implement members" "true" // ENABLE_MULTIPLATFORM -// ERROR: Expected interface 'InterfaceWithFuns' has no actual in module light_idea_test_case for JVM +// ERROR: Expected interface 'InterfaceWithFuns' has no actual declaration in module light_idea_test_case for JVM fun TODO(s: String): Nothing = null!! diff --git a/idea/testData/quickfix/modifiers/suspend/createCoroutine.kt b/idea/testData/quickfix/modifiers/suspend/createCoroutine.kt index 984458f7474..89d498d6b4a 100644 --- a/idea/testData/quickfix/modifiers/suspend/createCoroutine.kt +++ b/idea/testData/quickfix/modifiers/suspend/createCoroutine.kt @@ -1,8 +1,8 @@ // "Make block type suspend" "true" // WITH_RUNTIME -import kotlin.coroutines.suspendCoroutine -import kotlin.coroutines.createCoroutine +import kotlin.coroutines.experimental.suspendCoroutine +import kotlin.coroutines.experimental.createCoroutine suspend fun suspending(): T { val block: () -> T = { null!! } diff --git a/idea/testData/quickfix/modifiers/suspend/createCoroutine.kt.after b/idea/testData/quickfix/modifiers/suspend/createCoroutine.kt.after index 83cde5c4b0e..f9831d9518e 100644 --- a/idea/testData/quickfix/modifiers/suspend/createCoroutine.kt.after +++ b/idea/testData/quickfix/modifiers/suspend/createCoroutine.kt.after @@ -1,8 +1,8 @@ // "Make block type suspend" "true" // WITH_RUNTIME -import kotlin.coroutines.suspendCoroutine -import kotlin.coroutines.createCoroutine +import kotlin.coroutines.experimental.suspendCoroutine +import kotlin.coroutines.experimental.createCoroutine suspend fun suspending(): T { val block: suspend () -> T = { null!! } diff --git a/idea/testData/quickfix/modifiers/suspend/startCoroutine.kt b/idea/testData/quickfix/modifiers/suspend/startCoroutine.kt index f22becf7022..9649cc97386 100644 --- a/idea/testData/quickfix/modifiers/suspend/startCoroutine.kt +++ b/idea/testData/quickfix/modifiers/suspend/startCoroutine.kt @@ -1,7 +1,7 @@ // "Make block type suspend" "true" // WITH_RUNTIME -import kotlin.coroutines.suspendCoroutine -import kotlin.coroutines.startCoroutine +import kotlin.coroutines.experimental.suspendCoroutine +import kotlin.coroutines.experimental.startCoroutine suspend fun suspending(block: () -> T): T = suspendCoroutine { block.startCoroutine(it) } \ No newline at end of file diff --git a/idea/testData/quickfix/modifiers/suspend/startCoroutine.kt.after b/idea/testData/quickfix/modifiers/suspend/startCoroutine.kt.after index de1243cd7b7..f4d34393b5b 100644 --- a/idea/testData/quickfix/modifiers/suspend/startCoroutine.kt.after +++ b/idea/testData/quickfix/modifiers/suspend/startCoroutine.kt.after @@ -1,7 +1,7 @@ // "Make block type suspend" "true" // WITH_RUNTIME -import kotlin.coroutines.suspendCoroutine -import kotlin.coroutines.startCoroutine +import kotlin.coroutines.experimental.suspendCoroutine +import kotlin.coroutines.experimental.startCoroutine suspend fun suspending(block: suspend () -> T): T = suspendCoroutine { block.startCoroutine(it) } \ No newline at end of file diff --git a/idea/testData/quickfix/modifiers/suspend/startCoroutineNoImport.kt b/idea/testData/quickfix/modifiers/suspend/startCoroutineNoImport.kt index e2ebf7dc251..c14fef70ac7 100644 --- a/idea/testData/quickfix/modifiers/suspend/startCoroutineNoImport.kt +++ b/idea/testData/quickfix/modifiers/suspend/startCoroutineNoImport.kt @@ -2,6 +2,6 @@ // WITH_RUNTIME // DISABLE-ERRORS -import kotlin.coroutines.suspendCoroutine +import kotlin.coroutines.experimental.suspendCoroutine suspend fun suspending(block: () -> T): T = suspendCoroutine { block.startCoroutine(it) } \ No newline at end of file diff --git a/idea/testData/quickfix/modifiers/suspend/startCoroutineNoImport.kt.after b/idea/testData/quickfix/modifiers/suspend/startCoroutineNoImport.kt.after index fff8e1e7294..c5483dde2cf 100644 --- a/idea/testData/quickfix/modifiers/suspend/startCoroutineNoImport.kt.after +++ b/idea/testData/quickfix/modifiers/suspend/startCoroutineNoImport.kt.after @@ -2,6 +2,6 @@ // WITH_RUNTIME // DISABLE-ERRORS -import kotlin.coroutines.suspendCoroutine +import kotlin.coroutines.experimental.suspendCoroutine suspend fun suspending(block: suspend () -> T): T = suspendCoroutine { block.startCoroutine(it) } \ No newline at end of file diff --git a/idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets1.kt b/idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets1.kt new file mode 100644 index 00000000000..4724b5f36ed --- /dev/null +++ b/idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets1.kt @@ -0,0 +1,4 @@ +// "Remove 'toString()' call" "true" + +val foo = "test" +val bar = "${foo.toString()}_" \ No newline at end of file diff --git a/idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets1.kt.after b/idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets1.kt.after new file mode 100644 index 00000000000..0bd3e81b843 --- /dev/null +++ b/idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets1.kt.after @@ -0,0 +1,4 @@ +// "Remove 'toString()' call" "true" + +val foo = "test" +val bar = "${foo}_" \ No newline at end of file diff --git a/idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets2.kt b/idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets2.kt new file mode 100644 index 00000000000..e250e4ae303 --- /dev/null +++ b/idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets2.kt @@ -0,0 +1,4 @@ +// "Remove 'toString()' call" "true" + +val foo = "test" +val bar = "${foo.toString()}コトリン" \ No newline at end of file diff --git a/idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets2.kt.after b/idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets2.kt.after new file mode 100644 index 00000000000..532875ac3c0 --- /dev/null +++ b/idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets2.kt.after @@ -0,0 +1,4 @@ +// "Remove 'toString()' call" "true" + +val foo = "test" +val bar = "${foo}コトリン" \ No newline at end of file diff --git a/idea/testData/quickfix/replaceWithArrayCallInAnnotation/emptyLiteral.kt b/idea/testData/quickfix/replaceWithArrayCallInAnnotation/emptyLiteral.kt new file mode 100644 index 00000000000..728b5a3b81e --- /dev/null +++ b/idea/testData/quickfix/replaceWithArrayCallInAnnotation/emptyLiteral.kt @@ -0,0 +1,7 @@ +// "Replace with array call" "true" +// LANGUAGE_VERSION: 1.2 + +annotation class Some(vararg val strings: String) + +@Some(strings = *[]) +class My diff --git a/idea/testData/quickfix/replaceWithArrayCallInAnnotation/emptyLiteral.kt.after b/idea/testData/quickfix/replaceWithArrayCallInAnnotation/emptyLiteral.kt.after new file mode 100644 index 00000000000..93273c46e9c --- /dev/null +++ b/idea/testData/quickfix/replaceWithArrayCallInAnnotation/emptyLiteral.kt.after @@ -0,0 +1,7 @@ +// "Replace with array call" "true" +// LANGUAGE_VERSION: 1.2 + +annotation class Some(vararg val strings: String) + +@Some(strings = []) +class My diff --git a/idea/testData/quickfix/replaceWithArrayCallInAnnotation/literalWithValues.kt b/idea/testData/quickfix/replaceWithArrayCallInAnnotation/literalWithValues.kt new file mode 100644 index 00000000000..bcebbb9b558 --- /dev/null +++ b/idea/testData/quickfix/replaceWithArrayCallInAnnotation/literalWithValues.kt @@ -0,0 +1,7 @@ +// "Replace with array call" "true" +// LANGUAGE_VERSION: 1.2 + +annotation class Some(vararg val ints: Int) + +@Some(ints = *[1, 2, 3]) +class My diff --git a/idea/testData/quickfix/replaceWithArrayCallInAnnotation/literalWithValues.kt.after b/idea/testData/quickfix/replaceWithArrayCallInAnnotation/literalWithValues.kt.after new file mode 100644 index 00000000000..b440a6ab667 --- /dev/null +++ b/idea/testData/quickfix/replaceWithArrayCallInAnnotation/literalWithValues.kt.after @@ -0,0 +1,7 @@ +// "Replace with array call" "true" +// LANGUAGE_VERSION: 1.2 + +annotation class Some(vararg val ints: Int) + +@Some(ints = [1, 2, 3]) +class My diff --git a/idea/testData/quickfix/replaceWithArrayCallInAnnotation/replaceSingleElementInNamedForm.kt b/idea/testData/quickfix/replaceWithArrayCallInAnnotation/replaceSingleElementInNamedForm.kt new file mode 100644 index 00000000000..05b4db95035 --- /dev/null +++ b/idea/testData/quickfix/replaceWithArrayCallInAnnotation/replaceSingleElementInNamedForm.kt @@ -0,0 +1,7 @@ +// "Replace with array call" "true" +// LANGUAGE_VERSION: 1.2 + +annotation class Some(vararg val strings: String) + +@Some(strings = "value") +class My diff --git a/idea/testData/quickfix/replaceWithArrayCallInAnnotation/replaceSingleElementInNamedForm.kt.after b/idea/testData/quickfix/replaceWithArrayCallInAnnotation/replaceSingleElementInNamedForm.kt.after new file mode 100644 index 00000000000..afc80464996 --- /dev/null +++ b/idea/testData/quickfix/replaceWithArrayCallInAnnotation/replaceSingleElementInNamedForm.kt.after @@ -0,0 +1,7 @@ +// "Replace with array call" "true" +// LANGUAGE_VERSION: 1.2 + +annotation class Some(vararg val strings: String) + +@Some(strings = ["value"]) +class My diff --git a/idea/testData/quickfix/simplifyComparison/withAssertion.kt b/idea/testData/quickfix/simplifyComparison/withAssertion.kt new file mode 100644 index 00000000000..6ec41956ba2 --- /dev/null +++ b/idea/testData/quickfix/simplifyComparison/withAssertion.kt @@ -0,0 +1,6 @@ +// "Simplify comparison" "true" +// WITH_RUNTIME +fun test() { + val s = "" + assert(s != null) +} \ No newline at end of file diff --git a/idea/testData/quickfix/simplifyComparison/withAssertion.kt.after b/idea/testData/quickfix/simplifyComparison/withAssertion.kt.after new file mode 100644 index 00000000000..0e80094993f --- /dev/null +++ b/idea/testData/quickfix/simplifyComparison/withAssertion.kt.after @@ -0,0 +1,5 @@ +// "Simplify comparison" "true" +// WITH_RUNTIME +fun test() { + val s = "" +} \ No newline at end of file diff --git a/idea/testData/quickfix/simplifyComparison/withAssertion2.kt b/idea/testData/quickfix/simplifyComparison/withAssertion2.kt new file mode 100644 index 00000000000..223bba2b635 --- /dev/null +++ b/idea/testData/quickfix/simplifyComparison/withAssertion2.kt @@ -0,0 +1,6 @@ +// "Simplify comparison" "true" +// WITH_RUNTIME +fun test() { + val s = "" + assert(s != null && true) +} \ No newline at end of file diff --git a/idea/testData/quickfix/simplifyComparison/withAssertion2.kt.after b/idea/testData/quickfix/simplifyComparison/withAssertion2.kt.after new file mode 100644 index 00000000000..0e80094993f --- /dev/null +++ b/idea/testData/quickfix/simplifyComparison/withAssertion2.kt.after @@ -0,0 +1,5 @@ +// "Simplify comparison" "true" +// WITH_RUNTIME +fun test() { + val s = "" +} \ No newline at end of file diff --git a/idea/testData/quickfix/simplifyComparison/withAssertion3.kt b/idea/testData/quickfix/simplifyComparison/withAssertion3.kt new file mode 100644 index 00000000000..ac670bad4ab --- /dev/null +++ b/idea/testData/quickfix/simplifyComparison/withAssertion3.kt @@ -0,0 +1,6 @@ +// "Simplify comparison" "true" +// WITH_RUNTIME +fun test() { + val s = "" + assert(s != null && false) +} \ No newline at end of file diff --git a/idea/testData/quickfix/simplifyComparison/withAssertion3.kt.after b/idea/testData/quickfix/simplifyComparison/withAssertion3.kt.after new file mode 100644 index 00000000000..56a488d9a11 --- /dev/null +++ b/idea/testData/quickfix/simplifyComparison/withAssertion3.kt.after @@ -0,0 +1,6 @@ +// "Simplify comparison" "true" +// WITH_RUNTIME +fun test() { + val s = "" + assert(false) +} \ No newline at end of file diff --git a/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceForVarargOfAny.kt b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceForVarargOfAny.kt new file mode 100644 index 00000000000..002a7e9c10f --- /dev/null +++ b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceForVarargOfAny.kt @@ -0,0 +1,8 @@ +// "Surround with *arrayOf(...)" "true" +// LANGUAGE_VERSION: 1.2 + +fun anyFoo(vararg a: Any) {} + +fun test() { + anyFoo(a = intArrayOf(1)) +} \ No newline at end of file diff --git a/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceForVarargOfAny.kt.after b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceForVarargOfAny.kt.after new file mode 100644 index 00000000000..1742d81541d --- /dev/null +++ b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceForVarargOfAny.kt.after @@ -0,0 +1,8 @@ +// "Surround with *arrayOf(...)" "true" +// LANGUAGE_VERSION: 1.2 + +fun anyFoo(vararg a: Any) {} + +fun test() { + anyFoo(a = *arrayOf(intArrayOf(1))) +} \ No newline at end of file diff --git a/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceToArrayOfPrimitiveTypes.kt b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceToArrayOfPrimitiveTypes.kt new file mode 100644 index 00000000000..fd41853c89e --- /dev/null +++ b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceToArrayOfPrimitiveTypes.kt @@ -0,0 +1,8 @@ +// "Surround with *intArrayOf(...)" "true" +// LANGUAGE_VERSION: 1.2 + +fun foo(vararg s: Int) {} + +fun test() { + foo(s = 1) +} \ No newline at end of file diff --git a/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceToArrayOfPrimitiveTypes.kt.after b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceToArrayOfPrimitiveTypes.kt.after new file mode 100644 index 00000000000..e1baabbdd86 --- /dev/null +++ b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceToArrayOfPrimitiveTypes.kt.after @@ -0,0 +1,8 @@ +// "Surround with *intArrayOf(...)" "true" +// LANGUAGE_VERSION: 1.2 + +fun foo(vararg s: Int) {} + +fun test() { + foo(s = *intArrayOf(1)) +} \ No newline at end of file diff --git a/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/simpleNamedArgumentToVararg.kt b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/simpleNamedArgumentToVararg.kt new file mode 100644 index 00000000000..566dcba3857 --- /dev/null +++ b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/simpleNamedArgumentToVararg.kt @@ -0,0 +1,8 @@ +// "Surround with *arrayOf(...)" "true" +// LANGUAGE_VERSION: 1.2 + +fun foo(vararg s: String) {} + +fun test() { + foo(s = "value") +} \ No newline at end of file diff --git a/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/simpleNamedArgumentToVararg.kt.after b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/simpleNamedArgumentToVararg.kt.after new file mode 100644 index 00000000000..a6f4e7c2e10 --- /dev/null +++ b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/simpleNamedArgumentToVararg.kt.after @@ -0,0 +1,8 @@ +// "Surround with *arrayOf(...)" "true" +// LANGUAGE_VERSION: 1.2 + +fun foo(vararg s: String) {} + +fun test() { + foo(s = *arrayOf("value")) +} \ No newline at end of file diff --git a/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/surroundWithSpreadForConstructorCall.kt b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/surroundWithSpreadForConstructorCall.kt new file mode 100644 index 00000000000..a48ebe7f75c --- /dev/null +++ b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/surroundWithSpreadForConstructorCall.kt @@ -0,0 +1,8 @@ +// "Surround with *arrayOf(...)" "true" +// LANGUAGE_VERSION: 1.2 + +class Foo(vararg val p: T) + +fun test() { + Foo(p = 123) +} \ No newline at end of file diff --git a/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/surroundWithSpreadForConstructorCall.kt.after b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/surroundWithSpreadForConstructorCall.kt.after new file mode 100644 index 00000000000..d0dbf24d87f --- /dev/null +++ b/idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/surroundWithSpreadForConstructorCall.kt.after @@ -0,0 +1,8 @@ +// "Surround with *arrayOf(...)" "true" +// LANGUAGE_VERSION: 1.2 + +class Foo(vararg val p: T) + +fun test() { + Foo(p = *arrayOf(123)) +} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/arrayToCollection.kt b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToCollection.kt new file mode 100644 index 00000000000..d0e8923f091 --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToCollection.kt @@ -0,0 +1,8 @@ +// "Convert expression to 'Collection' by inserting '.toList()'" "true" +// WITH_RUNTIME + +fun foo(a: Array) { + bar(a) +} + +fun bar(a: Collection) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/arrayToCollection.kt.after b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToCollection.kt.after new file mode 100644 index 00000000000..4a86d1d875b --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToCollection.kt.after @@ -0,0 +1,8 @@ +// "Convert expression to 'Collection' by inserting '.toList()'" "true" +// WITH_RUNTIME + +fun foo(a: Array) { + bar(a.toList()) +} + +fun bar(a: Collection) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/arrayToIterable.kt b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToIterable.kt new file mode 100644 index 00000000000..1f67967c9c0 --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToIterable.kt @@ -0,0 +1,8 @@ +// "Convert expression to 'Iterable' by inserting '.toList()'" "true" +// WITH_RUNTIME + +fun foo(a: Array) { + bar(a) +} + +fun bar(a: Iterable) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/arrayToIterable.kt.after b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToIterable.kt.after new file mode 100644 index 00000000000..61ed32f3f17 --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToIterable.kt.after @@ -0,0 +1,8 @@ +// "Convert expression to 'Iterable' by inserting '.toList()'" "true" +// WITH_RUNTIME + +fun foo(a: Array) { + bar(a.toList()) +} + +fun bar(a: Iterable) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/arrayToList.kt b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToList.kt new file mode 100644 index 00000000000..72b65192953 --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToList.kt @@ -0,0 +1,8 @@ +// "Convert expression to 'List' by inserting '.toList()'" "true" +// WITH_RUNTIME + +fun foo(a: Array) { + bar(a) +} + +fun bar(a: List) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/arrayToList.kt.after b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToList.kt.after new file mode 100644 index 00000000000..4d8c86a20a8 --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToList.kt.after @@ -0,0 +1,8 @@ +// "Convert expression to 'List' by inserting '.toList()'" "true" +// WITH_RUNTIME + +fun foo(a: Array) { + bar(a.toList()) +} + +fun bar(a: List) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/arrayToSequence.kt b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToSequence.kt new file mode 100644 index 00000000000..67edc122ede --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToSequence.kt @@ -0,0 +1,8 @@ +// "Convert expression to 'Sequence' by inserting '.asSequence()'" "true" +// WITH_RUNTIME + +fun foo(a: Array) { + bar(a) +} + +fun bar(a: Sequence) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/arrayToSequence.kt.after b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToSequence.kt.after new file mode 100644 index 00000000000..9b68e153cc2 --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/arrayToSequence.kt.after @@ -0,0 +1,8 @@ +// "Convert expression to 'Sequence' by inserting '.asSequence()'" "true" +// WITH_RUNTIME + +fun foo(a: Array) { + bar(a.asSequence()) +} + +fun bar(a: Sequence) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/iterableToArray.kt b/idea/testData/quickfix/typeMismatch/convertCollection/iterableToArray.kt new file mode 100644 index 00000000000..15dfaa5be3e --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/iterableToArray.kt @@ -0,0 +1,8 @@ +// "Convert expression to 'Array' by inserting '.toList().toTypedArray()'" "true" +// WITH_RUNTIME + +fun foo(a: Iterable) { + bar(a) +} + +fun bar(a: Array) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/iterableToArray.kt.after b/idea/testData/quickfix/typeMismatch/convertCollection/iterableToArray.kt.after new file mode 100644 index 00000000000..008d19e3ef4 --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/iterableToArray.kt.after @@ -0,0 +1,8 @@ +// "Convert expression to 'Array' by inserting '.toList().toTypedArray()'" "true" +// WITH_RUNTIME + +fun foo(a: Iterable) { + bar(a.toList().toTypedArray()) +} + +fun bar(a: Array) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/listToArray.kt b/idea/testData/quickfix/typeMismatch/convertCollection/listToArray.kt new file mode 100644 index 00000000000..bb8385993aa --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/listToArray.kt @@ -0,0 +1,8 @@ +// "Convert expression to 'Array' by inserting '.toTypedArray()'" "true" +// WITH_RUNTIME + +fun foo(a: List) { + bar(a) +} + +fun bar(a: Array) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/listToArray.kt.after b/idea/testData/quickfix/typeMismatch/convertCollection/listToArray.kt.after new file mode 100644 index 00000000000..8c8e4ff851b --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/listToArray.kt.after @@ -0,0 +1,8 @@ +// "Convert expression to 'Array' by inserting '.toTypedArray()'" "true" +// WITH_RUNTIME + +fun foo(a: List) { + bar(a.toTypedArray()) +} + +fun bar(a: Array) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/listToArrayBinary.kt b/idea/testData/quickfix/typeMismatch/convertCollection/listToArrayBinary.kt new file mode 100644 index 00000000000..c1062860cee --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/listToArrayBinary.kt @@ -0,0 +1,8 @@ +// "Convert expression to 'Array' by inserting '.toTypedArray()'" "true" +// WITH_RUNTIME + +fun foo(a: List, b: List) { + bar(a + b) +} + +fun bar(a: Array) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/listToArrayBinary.kt.after b/idea/testData/quickfix/typeMismatch/convertCollection/listToArrayBinary.kt.after new file mode 100644 index 00000000000..fa8c5b2cde3 --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/listToArrayBinary.kt.after @@ -0,0 +1,8 @@ +// "Convert expression to 'Array' by inserting '.toTypedArray()'" "true" +// WITH_RUNTIME + +fun foo(a: List, b: List) { + bar((a + b).toTypedArray()) +} + +fun bar(a: Array) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/listToMutableList.kt b/idea/testData/quickfix/typeMismatch/convertCollection/listToMutableList.kt new file mode 100644 index 00000000000..ddf2bde056e --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/listToMutableList.kt @@ -0,0 +1,8 @@ +// "Convert expression to 'MutableList' by inserting '.toMutableList()'" "true" +// WITH_RUNTIME + +fun foo(a: List) { + bar(a) +} + +fun bar(a: MutableList) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/listToMutableList.kt.after b/idea/testData/quickfix/typeMismatch/convertCollection/listToMutableList.kt.after new file mode 100644 index 00000000000..4ac5aa13914 --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/listToMutableList.kt.after @@ -0,0 +1,8 @@ +// "Convert expression to 'MutableList' by inserting '.toMutableList()'" "true" +// WITH_RUNTIME + +fun foo(a: List) { + bar(a.toMutableList()) +} + +fun bar(a: MutableList) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/listToSequence.kt b/idea/testData/quickfix/typeMismatch/convertCollection/listToSequence.kt new file mode 100644 index 00000000000..339b6b8da7b --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/listToSequence.kt @@ -0,0 +1,8 @@ +// "Convert expression to 'Sequence' by inserting '.asSequence()'" "true" +// WITH_RUNTIME + +fun foo(a: List) { + bar(a) +} + +fun bar(a: Sequence) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/listToSequence.kt.after b/idea/testData/quickfix/typeMismatch/convertCollection/listToSequence.kt.after new file mode 100644 index 00000000000..0afe8d82740 --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/listToSequence.kt.after @@ -0,0 +1,8 @@ +// "Convert expression to 'Sequence' by inserting '.asSequence()'" "true" +// WITH_RUNTIME + +fun foo(a: List) { + bar(a.asSequence()) +} + +fun bar(a: Sequence) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/sequenceToArray.kt b/idea/testData/quickfix/typeMismatch/convertCollection/sequenceToArray.kt new file mode 100644 index 00000000000..036d0eec5de --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/sequenceToArray.kt @@ -0,0 +1,8 @@ +// "Convert expression to 'Array' by inserting '.toList().toTypedArray()'" "true" +// WITH_RUNTIME + +fun foo(a: Sequence) { + bar(a) +} + +fun bar(a: Array) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/sequenceToArray.kt.after b/idea/testData/quickfix/typeMismatch/convertCollection/sequenceToArray.kt.after new file mode 100644 index 00000000000..3101a221165 --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/sequenceToArray.kt.after @@ -0,0 +1,8 @@ +// "Convert expression to 'Array' by inserting '.toList().toTypedArray()'" "true" +// WITH_RUNTIME + +fun foo(a: Sequence) { + bar(a.toList().toTypedArray()) +} + +fun bar(a: Array) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/sequenceToList.kt b/idea/testData/quickfix/typeMismatch/convertCollection/sequenceToList.kt new file mode 100644 index 00000000000..9b12abf535c --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/sequenceToList.kt @@ -0,0 +1,8 @@ +// "Convert expression to 'List' by inserting '.toList()'" "true" +// WITH_RUNTIME + +fun foo(a: Sequence) { + bar(a) +} + +fun bar(a: List) {} \ No newline at end of file diff --git a/idea/testData/quickfix/typeMismatch/convertCollection/sequenceToList.kt.after b/idea/testData/quickfix/typeMismatch/convertCollection/sequenceToList.kt.after new file mode 100644 index 00000000000..344bce3d798 --- /dev/null +++ b/idea/testData/quickfix/typeMismatch/convertCollection/sequenceToList.kt.after @@ -0,0 +1,8 @@ +// "Convert expression to 'List' by inserting '.toList()'" "true" +// WITH_RUNTIME + +fun foo(a: Sequence) { + bar(a.toList()) +} + +fun bar(a: List) {} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/after/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/after/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/after/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/after/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/before/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/before/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/before/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/before/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructor/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/after/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/after/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/after/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/after/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/before/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/before/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/before/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/before/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headerPrimaryConstructorNoParams/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/after/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/after/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/after/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/after/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/before/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/before/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/before/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/before/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headerSecondaryConstructor/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/after/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/after/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/after/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/after/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/before/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/before/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/before/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/before/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderClassMemberFun/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/after/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/after/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/after/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/after/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/before/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/before/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/before/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/before/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByHeaderFun/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/after/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/after/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/after/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/after/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/before/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/before/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/before/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/before/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplClassMemberFun/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/after/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/after/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/after/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/after/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/before/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/before/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/before/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/before/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/headersAndImplsByImplFun/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/after/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/after/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/after/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/after/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/before/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/before/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/before/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/before/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructor/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/after/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/after/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/after/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/after/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/before/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/before/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/before/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/before/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/implPrimaryConstructorNoParams/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/after/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/after/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/after/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/after/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/before/JS/JS.iml b/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/before/JS/JS.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/before/JVM/JVM.iml b/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/before/JVM/JVM.iml +++ b/idea/testData/refactoring/changeSignatureMultiModule/implSecondaryConstructor/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/copy/copyFIleFromDefaultPackage/after/bar/test.kt b/idea/testData/refactoring/copy/copyFIleFromDefaultPackage/after/bar/test.kt new file mode 100644 index 00000000000..c299dd73002 --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleFromDefaultPackage/after/bar/test.kt @@ -0,0 +1,8 @@ +package bar + +val a = 42 + +// comment + +// some other comment +val s = "" \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyFIleFromDefaultPackage/after/test.kt b/idea/testData/refactoring/copy/copyFIleFromDefaultPackage/after/test.kt new file mode 100644 index 00000000000..71d1b354d30 --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleFromDefaultPackage/after/test.kt @@ -0,0 +1,6 @@ +val a = 42 + +// comment + +// some other comment +val s = "" \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyFIleFromDefaultPackage/before/test.kt b/idea/testData/refactoring/copy/copyFIleFromDefaultPackage/before/test.kt new file mode 100644 index 00000000000..71d1b354d30 --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleFromDefaultPackage/before/test.kt @@ -0,0 +1,6 @@ +val a = 42 + +// comment + +// some other comment +val s = "" \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyFIleFromDefaultPackage/copyFIleFromDefaultPackage.test b/idea/testData/refactoring/copy/copyFIleFromDefaultPackage/copyFIleFromDefaultPackage.test new file mode 100644 index 00000000000..a72ed185f0b --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleFromDefaultPackage/copyFIleFromDefaultPackage.test @@ -0,0 +1,4 @@ +{ + "mainFile": "test.kt", + "targetPackage": "bar" +} diff --git a/idea/testData/refactoring/copy/copyFIleRetainContent/after/bar/test.kt b/idea/testData/refactoring/copy/copyFIleRetainContent/after/bar/test.kt new file mode 100644 index 00000000000..c299dd73002 --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleRetainContent/after/bar/test.kt @@ -0,0 +1,8 @@ +package bar + +val a = 42 + +// comment + +// some other comment +val s = "" \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyFIleRetainContent/after/foo/test.kt b/idea/testData/refactoring/copy/copyFIleRetainContent/after/foo/test.kt new file mode 100644 index 00000000000..6cd7df7764e --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleRetainContent/after/foo/test.kt @@ -0,0 +1,8 @@ +package foo + +val a = 42 + +// comment + +// some other comment +val s = "" \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyFIleRetainContent/before/foo/test.kt b/idea/testData/refactoring/copy/copyFIleRetainContent/before/foo/test.kt new file mode 100644 index 00000000000..6cd7df7764e --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleRetainContent/before/foo/test.kt @@ -0,0 +1,8 @@ +package foo + +val a = 42 + +// comment + +// some other comment +val s = "" \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyFIleRetainContent/copyFIleRetainContent.test b/idea/testData/refactoring/copy/copyFIleRetainContent/copyFIleRetainContent.test new file mode 100644 index 00000000000..f169eabdfa3 --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleRetainContent/copyFIleRetainContent.test @@ -0,0 +1,4 @@ +{ + "mainFile": "foo/test.kt", + "targetPackage": "bar" +} diff --git a/idea/testData/refactoring/copy/copyFIleToDefaultPackage/after/foo/test.kt b/idea/testData/refactoring/copy/copyFIleToDefaultPackage/after/foo/test.kt new file mode 100644 index 00000000000..6cd7df7764e --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleToDefaultPackage/after/foo/test.kt @@ -0,0 +1,8 @@ +package foo + +val a = 42 + +// comment + +// some other comment +val s = "" \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyFIleToDefaultPackage/after/test.kt b/idea/testData/refactoring/copy/copyFIleToDefaultPackage/after/test.kt new file mode 100644 index 00000000000..71d1b354d30 --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleToDefaultPackage/after/test.kt @@ -0,0 +1,6 @@ +val a = 42 + +// comment + +// some other comment +val s = "" \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyFIleToDefaultPackage/before/foo/test.kt b/idea/testData/refactoring/copy/copyFIleToDefaultPackage/before/foo/test.kt new file mode 100644 index 00000000000..6cd7df7764e --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleToDefaultPackage/before/foo/test.kt @@ -0,0 +1,8 @@ +package foo + +val a = 42 + +// comment + +// some other comment +val s = "" \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyFIleToDefaultPackage/copyFIleToDefaultPackage.test b/idea/testData/refactoring/copy/copyFIleToDefaultPackage/copyFIleToDefaultPackage.test new file mode 100644 index 00000000000..49d37a24bfd --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleToDefaultPackage/copyFIleToDefaultPackage.test @@ -0,0 +1,4 @@ +{ + "mainFile": "foo/test.kt", + "targetPackage": "" +} diff --git a/idea/testData/refactoring/copy/copyFIleWithPackageAndDirUnmatched/after/bar/test.kt b/idea/testData/refactoring/copy/copyFIleWithPackageAndDirUnmatched/after/bar/test.kt new file mode 100644 index 00000000000..496b0552e62 --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleWithPackageAndDirUnmatched/after/bar/test.kt @@ -0,0 +1,8 @@ +package baz + +val a = 42 + +// comment + +// some other comment +val s = "" \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyFIleWithPackageAndDirUnmatched/after/foo/test.kt b/idea/testData/refactoring/copy/copyFIleWithPackageAndDirUnmatched/after/foo/test.kt new file mode 100644 index 00000000000..496b0552e62 --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleWithPackageAndDirUnmatched/after/foo/test.kt @@ -0,0 +1,8 @@ +package baz + +val a = 42 + +// comment + +// some other comment +val s = "" \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyFIleWithPackageAndDirUnmatched/before/foo/test.kt b/idea/testData/refactoring/copy/copyFIleWithPackageAndDirUnmatched/before/foo/test.kt new file mode 100644 index 00000000000..496b0552e62 --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleWithPackageAndDirUnmatched/before/foo/test.kt @@ -0,0 +1,8 @@ +package baz + +val a = 42 + +// comment + +// some other comment +val s = "" \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyFIleWithPackageAndDirUnmatched/copyFIleWithPackageAndDirUnmatched.test b/idea/testData/refactoring/copy/copyFIleWithPackageAndDirUnmatched/copyFIleWithPackageAndDirUnmatched.test new file mode 100644 index 00000000000..f169eabdfa3 --- /dev/null +++ b/idea/testData/refactoring/copy/copyFIleWithPackageAndDirUnmatched/copyFIleWithPackageAndDirUnmatched.test @@ -0,0 +1,4 @@ +{ + "mainFile": "foo/test.kt", + "targetPackage": "bar" +} diff --git a/idea/testData/refactoring/copy/copyMultiClassFile/after/bar/test.kt b/idea/testData/refactoring/copy/copyMultiClassFile/after/bar/test.kt index c52f950b8cf..958cf968c3d 100644 --- a/idea/testData/refactoring/copy/copyMultiClassFile/after/bar/test.kt +++ b/idea/testData/refactoring/copy/copyMultiClassFile/after/bar/test.kt @@ -8,4 +8,4 @@ class A { class B { val a: A = A() val b: B = B() -} \ No newline at end of file +} diff --git a/idea/testData/refactoring/copy/copySingleClass/after/bar/A.kt b/idea/testData/refactoring/copy/copySingleClass/after/bar/A.kt new file mode 100644 index 00000000000..39048f89611 --- /dev/null +++ b/idea/testData/refactoring/copy/copySingleClass/after/bar/A.kt @@ -0,0 +1,7 @@ +package bar + +// test + +class A + +// test2 \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copySingleClass/after/foo/A.kt b/idea/testData/refactoring/copy/copySingleClass/after/foo/A.kt new file mode 100644 index 00000000000..94311a5557d --- /dev/null +++ b/idea/testData/refactoring/copy/copySingleClass/after/foo/A.kt @@ -0,0 +1,7 @@ +package foo + +// test + +class A + +// test2 \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copySingleClass/before/foo/A.kt b/idea/testData/refactoring/copy/copySingleClass/before/foo/A.kt new file mode 100644 index 00000000000..c7a0543a544 --- /dev/null +++ b/idea/testData/refactoring/copy/copySingleClass/before/foo/A.kt @@ -0,0 +1,7 @@ +package foo + +// test + +class A + +// test2 \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copySingleClass/copySingleClass.test b/idea/testData/refactoring/copy/copySingleClass/copySingleClass.test new file mode 100644 index 00000000000..7b0c3015980 --- /dev/null +++ b/idea/testData/refactoring/copy/copySingleClass/copySingleClass.test @@ -0,0 +1,4 @@ +{ + "mainFile": "foo/A.kt", + "targetPackage": "bar" +} diff --git a/idea/testData/refactoring/copy/copySingleClassFile/after/bar/A.kt b/idea/testData/refactoring/copy/copySingleClassFile/after/bar/test.kt similarity index 100% rename from idea/testData/refactoring/copy/copySingleClassFile/after/bar/A.kt rename to idea/testData/refactoring/copy/copySingleClassFile/after/bar/test.kt diff --git a/idea/testData/refactoring/copy/copySingleClassWithRename/after/bar/B.kt b/idea/testData/refactoring/copy/copySingleClassWithRename/after/bar/B.kt new file mode 100644 index 00000000000..ad03099f823 --- /dev/null +++ b/idea/testData/refactoring/copy/copySingleClassWithRename/after/bar/B.kt @@ -0,0 +1,7 @@ +package bar + +// test + +class B + +// test2 \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copySingleClassWithRename/after/foo/A.kt b/idea/testData/refactoring/copy/copySingleClassWithRename/after/foo/A.kt new file mode 100644 index 00000000000..94311a5557d --- /dev/null +++ b/idea/testData/refactoring/copy/copySingleClassWithRename/after/foo/A.kt @@ -0,0 +1,7 @@ +package foo + +// test + +class A + +// test2 \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copySingleClassWithRename/before/foo/A.kt b/idea/testData/refactoring/copy/copySingleClassWithRename/before/foo/A.kt new file mode 100644 index 00000000000..c7a0543a544 --- /dev/null +++ b/idea/testData/refactoring/copy/copySingleClassWithRename/before/foo/A.kt @@ -0,0 +1,7 @@ +package foo + +// test + +class A + +// test2 \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copySingleClassWithRename/copySingleClassWithRename.test b/idea/testData/refactoring/copy/copySingleClassWithRename/copySingleClassWithRename.test new file mode 100644 index 00000000000..2c400988286 --- /dev/null +++ b/idea/testData/refactoring/copy/copySingleClassWithRename/copySingleClassWithRename.test @@ -0,0 +1,5 @@ +{ + "mainFile": "foo/A.kt", + "targetPackage": "bar", + "newName": "B" +} diff --git a/idea/testData/refactoring/copy/copyWithImportInsertion/after/bar/Bar.kt b/idea/testData/refactoring/copy/copyWithImportInsertion/after/bar/Bar.kt new file mode 100644 index 00000000000..213ed0b96c7 --- /dev/null +++ b/idea/testData/refactoring/copy/copyWithImportInsertion/after/bar/Bar.kt @@ -0,0 +1,3 @@ +package bar + +fun Any.bar() {} \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyWithImportInsertion/after/foo/Foo.kt b/idea/testData/refactoring/copy/copyWithImportInsertion/after/foo/Foo.kt new file mode 100644 index 00000000000..bcd2249246a --- /dev/null +++ b/idea/testData/refactoring/copy/copyWithImportInsertion/after/foo/Foo.kt @@ -0,0 +1,12 @@ +package foo + +import bar.bar + +class Foo { + init { + 42.bar() + } +} + +class Baz { +} diff --git a/idea/testData/refactoring/copy/copyWithImportInsertion/after/foo/Foo2.kt b/idea/testData/refactoring/copy/copyWithImportInsertion/after/foo/Foo2.kt new file mode 100644 index 00000000000..ec7061f4031 --- /dev/null +++ b/idea/testData/refactoring/copy/copyWithImportInsertion/after/foo/Foo2.kt @@ -0,0 +1,9 @@ +package foo + +import bar.bar + +class Foo2 { + init { + 42.bar() + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyWithImportInsertion/before/bar/Bar.kt b/idea/testData/refactoring/copy/copyWithImportInsertion/before/bar/Bar.kt new file mode 100644 index 00000000000..213ed0b96c7 --- /dev/null +++ b/idea/testData/refactoring/copy/copyWithImportInsertion/before/bar/Bar.kt @@ -0,0 +1,3 @@ +package bar + +fun Any.bar() {} \ No newline at end of file diff --git a/idea/testData/refactoring/copy/copyWithImportInsertion/before/foo/Foo.kt b/idea/testData/refactoring/copy/copyWithImportInsertion/before/foo/Foo.kt new file mode 100644 index 00000000000..dc9dac17444 --- /dev/null +++ b/idea/testData/refactoring/copy/copyWithImportInsertion/before/foo/Foo.kt @@ -0,0 +1,12 @@ +package foo + +import bar.bar + +class Foo { + init { + 42.bar() + } +} + +class Baz { +} diff --git a/idea/testData/refactoring/copy/copyWithImportInsertion/copyWithImportInsertion.test b/idea/testData/refactoring/copy/copyWithImportInsertion/copyWithImportInsertion.test new file mode 100644 index 00000000000..f1eb9731791 --- /dev/null +++ b/idea/testData/refactoring/copy/copyWithImportInsertion/copyWithImportInsertion.test @@ -0,0 +1,5 @@ +{ + "mainFile": "foo/Foo.kt", + "targetPackage": "foo", + "newName": "Foo2" +} diff --git a/idea/testData/refactoring/copy/kt18149/after/refactor/copy2/test.kt b/idea/testData/refactoring/copy/kt18149/after/refactor/copy2/test.kt index 1d1b84c733c..b2b214584a3 100644 --- a/idea/testData/refactoring/copy/kt18149/after/refactor/copy2/test.kt +++ b/idea/testData/refactoring/copy/kt18149/after/refactor/copy2/test.kt @@ -1,15 +1,14 @@ package refactor.copy2 import refactor.ParentJava -import refactor.copy.Company import kotlin.properties.Delegates enum class Possible { NO, YES } - data class Potable(val p1: String) class Insider(val peace: String) + class Init { fun referred() = 0 fun moved() = referred() @@ -28,6 +27,7 @@ class Simple { } annotation class MemAnn + class Variety { // object object ExtractedObject {} @@ -42,8 +42,7 @@ class Variety { private fun privateFun() = 0 fun genFunB(p: T): T = p fun genFunC(p: T): C where T : C = p - @MemAnn - fun annotatedFun() = 0 + @MemAnn fun annotatedFun() = 0 final fun finalFun() = 0 // property var publicProp = 0 @@ -56,8 +55,7 @@ class Variety { var List.genVarL: T where T : C get() = last() set(p) {} - @MemAnn - val annotatedVal = 0 + @MemAnn val annotatedVal = 0 var byVar by Delegates.notNull() lateinit var lateVal: String final val finalVal = 0 @@ -146,9 +144,9 @@ class CtorParameterChild(val pvc: String, var prc: String) : CtorParameter(pvc, class CtorParameterChild2: CtorParameter { constructor() : super("", "", "") } - class CtorParameterChild3(override val pv: String, override var pr: String) : CtorParameter(pv, pv, pr) data class CtorData(val pv: String, var pr: String) {} + class Company { companion object { val companyVal = 0 diff --git a/idea/testData/refactoring/copy/refToImportJavaStaticField/after/foo/test.kt b/idea/testData/refactoring/copy/refToImportJavaStaticField/after/foo/test.kt index 4e4fb32b49d..3b791a97bfa 100644 --- a/idea/testData/refactoring/copy/refToImportJavaStaticField/after/foo/test.kt +++ b/idea/testData/refactoring/copy/refToImportJavaStaticField/after/foo/test.kt @@ -5,3 +5,7 @@ import foo.J.JJJ fun test() { val x = JJJ } + +fun dummy() { + +} \ No newline at end of file diff --git a/idea/testData/refactoring/copy/refToImportJavaStaticField/before/foo/test.kt b/idea/testData/refactoring/copy/refToImportJavaStaticField/before/foo/test.kt index cbff5af4098..0759147e69e 100644 --- a/idea/testData/refactoring/copy/refToImportJavaStaticField/before/foo/test.kt +++ b/idea/testData/refactoring/copy/refToImportJavaStaticField/before/foo/test.kt @@ -5,3 +5,7 @@ import foo.J.JJJ fun test() { val x = JJJ } + +fun dummy() { + +} \ No newline at end of file diff --git a/idea/testData/refactoring/copy/refToImportJavaStaticMethod/after/foo/test.kt b/idea/testData/refactoring/copy/refToImportJavaStaticMethod/after/foo/test.kt index 708e4f52db0..8b92b427f04 100644 --- a/idea/testData/refactoring/copy/refToImportJavaStaticMethod/after/foo/test.kt +++ b/idea/testData/refactoring/copy/refToImportJavaStaticMethod/after/foo/test.kt @@ -5,3 +5,7 @@ import foo.J.jjj fun test() { jjj() } + +fun dummy() { + +} \ No newline at end of file diff --git a/idea/testData/refactoring/copy/refToImportJavaStaticMethod/before/foo/test.kt b/idea/testData/refactoring/copy/refToImportJavaStaticMethod/before/foo/test.kt index 5f4bcff8b61..d4562db4a78 100644 --- a/idea/testData/refactoring/copy/refToImportJavaStaticMethod/before/foo/test.kt +++ b/idea/testData/refactoring/copy/refToImportJavaStaticMethod/before/foo/test.kt @@ -5,3 +5,7 @@ import foo.J.jjj fun test() { jjj() } + +fun dummy() { + +} \ No newline at end of file diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClass/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFun/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberFunParameter/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassMemberVal/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassPrimaryConstructorParameter/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderClassSecondaryConstructorParameter/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFun/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderFunParameter/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByHeaderVal/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClass/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFun/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberFunParameter/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassMemberVal/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassPrimaryConstructorParameter/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplClassSecondaryConstructorParameter/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFun/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplFunParameter/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/after/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/after/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/after/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/after/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/before/JS/JS.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/before/JS/JS.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/before/JVM/JVM.iml b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/before/JVM/JVM.iml +++ b/idea/testData/refactoring/renameMultiModule/headersAndImplsByImplVal/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClass/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFun/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberFunParameter/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassMemberVal/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassPrimaryConstructorParameter/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructor/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderClassSecondaryConstructorParameter/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFun/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunParamerer/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderFunVarargParamerer/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byHeaderVal/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClass/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFun/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberFunParameterLiftingToHeader/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassMemberVal/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassPrimaryConstructorParameterLiftingToHeader/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructor/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplClassSecondaryConstructorParameterLiftingToHeader/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplFun/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererLiftingToHeader/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplFunParamererNoLiftingToHeader/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/after/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/after/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/after/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/after/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/after/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/after/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/after/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/after/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/before/JS/JS.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/before/JS/JS.iml index 82d3e6bdf49..3de270f43fa 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/before/JS/JS.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/before/JS/JS.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/before/JVM/JVM.iml b/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/before/JVM/JVM.iml index c3173af9ec7..76d2b885834 100644 --- a/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/before/JVM/JVM.iml +++ b/idea/testData/refactoring/safeDeleteMultiModule/byImplVal/before/JVM/JVM.iml @@ -3,6 +3,7 @@ + Common diff --git a/idea/testData/resolve/additionalLazyResolve/anonymousObjectInBaseConstructor.kt b/idea/testData/resolve/additionalLazyResolve/anonymousObjectInBaseConstructor.kt new file mode 100644 index 00000000000..b2ea7410131 --- /dev/null +++ b/idea/testData/resolve/additionalLazyResolve/anonymousObjectInBaseConstructor.kt @@ -0,0 +1,25 @@ +package test + +interface A { + fun get(x : Int) +} + +open class B(val a: A) + +class C : B(object : A { + override fun get(x : Int) {} +}) + +//package test +//public interface A defined in test +//public abstract fun get(x: kotlin.Int): kotlin.Unit defined in test.A +//value-parameter x: kotlin.Int defined in test.A.get +//public open class B defined in test +//public constructor B(a: test.A) defined in test.B +//value-parameter a: test.A defined in test.B. +//public final class C : test.B defined in test +//public constructor C() defined in test.C +//local final class : test.A defined in test.C. +//public constructor () defined in test.C.. +//public open fun get(x: kotlin.Int): kotlin.Unit defined in test.C.. +//value-parameter x: kotlin.Int defined in test.C...get \ No newline at end of file diff --git a/idea/testData/resolve/additionalLazyResolve/functionLiteralInBaseConstructor.kt b/idea/testData/resolve/additionalLazyResolve/functionLiteralInBaseConstructor.kt new file mode 100644 index 00000000000..3b86d19dae9 --- /dev/null +++ b/idea/testData/resolve/additionalLazyResolve/functionLiteralInBaseConstructor.kt @@ -0,0 +1,14 @@ +package test + +open class B(val foo: () -> Unit) + +class C : B({ + +}) + +//package test +//public open class B defined in test +//public constructor B(foo: () -> kotlin.Unit) defined in test.B +//value-parameter foo: () -> kotlin.Unit defined in test.B. +//public final class C : test.B defined in test +//public constructor C() defined in test.C \ No newline at end of file diff --git a/idea/testData/resolve/references/JavaParameter.kt b/idea/testData/resolve/references/JavaParameter.kt index 01e35444aa5..09415412879 100644 --- a/idea/testData/resolve/references/JavaParameter.kt +++ b/idea/testData/resolve/references/JavaParameter.kt @@ -3,4 +3,4 @@ lateinit var y: java.nio.CharBuffer val h = x.read(p0 = y) -// REF: CharBuffer var1 +// REF: java.nio.CharBuffer charBuffer diff --git a/idea/testData/resolve/references/fileRefInRawStringLiteral.kt b/idea/testData/resolve/references/fileRefInRawStringLiteral.kt index ee1097565d7..2856211dd1b 100644 --- a/idea/testData/resolve/references/fileRefInRawStringLiteral.kt +++ b/idea/testData/resolve/references/fileRefInRawStringLiteral.kt @@ -1,5 +1,5 @@ fun foo() { - val s = """idea/testData/resolve/references/fileRefInRawStringLiteral.Data.java""" + val s = """fileRefInRawStringLiteral.Data.java""" } -// REF: /src//resolve/references.fileRefInRawStringLiteral.Data.java \ No newline at end of file +// REF: /src.fileRefInRawStringLiteral.Data.java \ No newline at end of file diff --git a/idea/testData/resolve/references/fileRefInStringLiteral.kt b/idea/testData/resolve/references/fileRefInStringLiteral.kt index 384d4deac67..9273ccea55c 100644 --- a/idea/testData/resolve/references/fileRefInStringLiteral.kt +++ b/idea/testData/resolve/references/fileRefInStringLiteral.kt @@ -1,5 +1,5 @@ fun foo() { - val s = "idea/testData/resolve/references/fileRefInStringLiteral.Data.java" + val s = "fileRefInStringLiteral.Data.java" } -// REF: /src//resolve/references.fileRefInStringLiteral.Data.java \ No newline at end of file +// REF: /src.fileRefInStringLiteral.Data.java \ No newline at end of file diff --git a/idea/testData/run/WithModuleForJdk6/module/src/main.kt b/idea/testData/run/WithModuleForJdk6/module/src/main.kt new file mode 100644 index 00000000000..20f4f3a626f --- /dev/null +++ b/idea/testData/run/WithModuleForJdk6/module/src/main.kt @@ -0,0 +1,4 @@ +package some + +fun main(args: Array) { +} diff --git a/idea/testData/run/WithModuleForJdk6/module/src/module-info.java b/idea/testData/run/WithModuleForJdk6/module/src/module-info.java new file mode 100644 index 00000000000..975b4781323 --- /dev/null +++ b/idea/testData/run/WithModuleForJdk6/module/src/module-info.java @@ -0,0 +1,3 @@ +module MAIN { + requires kotlin.stdlib; +} \ No newline at end of file diff --git a/idea/testData/run/WithModuleForJdk9/module/src/main.kt b/idea/testData/run/WithModuleForJdk9/module/src/main.kt new file mode 100644 index 00000000000..20f4f3a626f --- /dev/null +++ b/idea/testData/run/WithModuleForJdk9/module/src/main.kt @@ -0,0 +1,4 @@ +package some + +fun main(args: Array) { +} diff --git a/idea/testData/run/WithModuleForJdk9/module/src/module-info.java b/idea/testData/run/WithModuleForJdk9/module/src/module-info.java new file mode 100644 index 00000000000..975b4781323 --- /dev/null +++ b/idea/testData/run/WithModuleForJdk9/module/src/module-info.java @@ -0,0 +1,3 @@ +module MAIN { + requires kotlin.stdlib; +} \ No newline at end of file diff --git a/idea/testData/run/WithModuleForJdk9WithoutModuleInfo/module/src/main.kt b/idea/testData/run/WithModuleForJdk9WithoutModuleInfo/module/src/main.kt new file mode 100644 index 00000000000..20f4f3a626f --- /dev/null +++ b/idea/testData/run/WithModuleForJdk9WithoutModuleInfo/module/src/main.kt @@ -0,0 +1,4 @@ +package some + +fun main(args: Array) { +} diff --git a/idea/tests/org/jetbrains/kotlin/asJava/KtLightAnnotationTest.kt b/idea/tests/org/jetbrains/kotlin/asJava/KtLightAnnotationTest.kt index 5286491bf15..8835b08849d 100644 --- a/idea/tests/org/jetbrains/kotlin/asJava/KtLightAnnotationTest.kt +++ b/idea/tests/org/jetbrains/kotlin/asJava/KtLightAnnotationTest.kt @@ -16,9 +16,14 @@ package org.jetbrains.kotlin.asJava +import com.intellij.openapi.application.WriteAction +import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl import com.intellij.psi.* import com.intellij.testFramework.LightProjectDescriptor import junit.framework.TestCase +import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.idea.facet.configureFacet +import org.jetbrains.kotlin.idea.facet.getOrCreateFacet import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor @@ -202,6 +207,25 @@ class KtLightAnnotationTest : KotlinLightCodeInsightFixtureTestCase() { assertTextAndRange("\"def\"", annotationAttributeVal.initializers[1]) } + fun testKotlinAnnotationWithStringArrayLiteral() { + configureKotlinVersion("1.2") + myFixture.configureByText("AnnotatedClass.kt", """ + annotation class Anno(val params: Array) + @Anno(params = ["abc", "def"]) + class AnnotatedClass + """.trimIndent()) + myFixture.testHighlighting("AnnotatedClass.kt") + + val annotations = myFixture.findClass("AnnotatedClass").expectAnnotations(1) + val annotationAttributeVal = annotations.first().findAttributeValue("params") as PsiElement + assertTextAndRange("[\"abc\", \"def\"]", annotationAttributeVal) + + annotationAttributeVal as PsiArrayInitializerMemberValue + assertTextAndRange("\"abc\"", annotationAttributeVal.initializers[0]) + assertTextAndRange("\"def\"", annotationAttributeVal.initializers[1]) + } + + fun testKotlinAnnotationsArray() { myFixture.configureByText("AnnotatedClass.kt", """ annotation class Anno1(val anno2: Array) @@ -376,4 +400,13 @@ class KtLightAnnotationTest : KotlinLightCodeInsightFixtureTestCase() { number, size) } + private fun configureKotlinVersion(version: String) { + WriteAction.run { + val modelsProvider = IdeModifiableModelsProviderImpl(project) + val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false) + facet.configureFacet(version, LanguageFeature.State.DISABLED, null, modelsProvider) + modelsProvider.commit() + } + } + } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleHighlightingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleHighlightingTest.kt index e4a4bc5a142..73d2dbc7b96 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleHighlightingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleHighlightingTest.kt @@ -40,7 +40,8 @@ abstract class AbstractMultiModuleHighlightingTest : AbstractMultiHighlightingTe configureModule: (Module, TargetPlatformKind<*>) -> Unit = { _, _ -> }, jdk: TestJdkKind = TestJdkKind.MOCK_JDK ) { - val commonModule = module("common", jdk) + val commonModuleName = "common" + val commonModule = module(commonModuleName, jdk) commonModule.createFacet(TargetPlatformKind.Common, false) if (withStdlibCommon) { commonModule.addLibrary(ForTestCompileRuntime.stdlibCommonForTests(), kind = CommonLibraryKind) @@ -53,7 +54,7 @@ abstract class AbstractMultiModuleHighlightingTest : AbstractMultiHighlightingTe else -> error("Unsupported platform: $platform") } val platformModule = module(path, jdk) - platformModule.createFacet(platform) + platformModule.createFacet(platform, implementedModuleName = commonModuleName) platformModule.enableMultiPlatform() platformModule.addDependency(commonModule) configureModule(platformModule, platform) diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleHighlightingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleHighlightingTest.kt index d41ae568127..83f84f17ddf 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleHighlightingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleHighlightingTest.kt @@ -30,14 +30,10 @@ import com.intellij.psi.util.PsiModificationTracker import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.analyzer.ResolverForModuleComputationTracker import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments -import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime -import org.jetbrains.kotlin.config.JvmTarget import org.jetbrains.kotlin.config.LanguageVersion -import org.jetbrains.kotlin.config.TargetPlatformKind import org.jetbrains.kotlin.idea.completion.test.withServiceRegistered import org.jetbrains.kotlin.idea.facet.KotlinFacetConfiguration import org.jetbrains.kotlin.idea.facet.KotlinFacetType -import org.jetbrains.kotlin.idea.framework.JSLibraryKind import org.jetbrains.kotlin.idea.project.KotlinCodeBlockModificationListener import org.jetbrains.kotlin.idea.project.KotlinModuleModificationTracker import org.jetbrains.kotlin.idea.test.PluginTestCaseBase @@ -227,68 +223,4 @@ open class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() { configuration.configure() } } - - // Some tests are ignored below. They fail because markers are not stripped correctly in multi-module highlighting tests. - // TODO: fix this in the test framework and unignore the tests - class MultiPlatform : AbstractMultiModuleHighlightingTest() { - override fun getTestDataPath() = "${PluginTestCaseBase.getTestDataPathBase()}/multiModuleHighlighting/multiplatform/" - - fun testBasic() { - doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) - } - - fun testHeaderClass() { - doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) - } - - fun testHeaderWithoutImplForBoth() { - doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], TargetPlatformKind.JavaScript) - } - - fun ignore_testHeaderPartiallyImplemented() { - doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) - } - - fun testHeaderFunctionProperty() { - doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) - } - - fun testSuppressHeaderWithoutImpl() { - doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) - } - - fun testCatchHeaderExceptionInPlatformModule() { - doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], withStdlibCommon = true) - } - - fun testWithOverrides() { - doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) - } - - fun testUseCorrectBuiltInsForCommonModule() { - doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_8], TargetPlatformKind.JavaScript, - withStdlibCommon = true, jdk = FULL_JDK, configureModule = { module, platform -> - if (platform == TargetPlatformKind.JavaScript) { - module.addLibrary(ForTestCompileRuntime.stdlibJsForTests(), kind = JSLibraryKind) - module.addLibrary(ForTestCompileRuntime.stdlibCommonForTests()) - } - }) - } - - fun testHeaderClassImplTypealias() { - doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) - } - - fun testHeaderFunUsesStdlibInSignature() { - doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], withStdlibCommon = true, configureModule = { module, platform -> - if (platform is TargetPlatformKind.Jvm) { - module.addLibrary(ForTestCompileRuntime.runtimeJarForTests()) - } - }) - } - - fun ignore_testNestedClassWithoutImpl() { - doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) - } - } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleLineMarkerTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleLineMarkerTest.kt index 5123127117a..47756505aba 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleLineMarkerTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleLineMarkerTest.kt @@ -20,7 +20,9 @@ import com.intellij.openapi.roots.CompilerModuleExtension import com.intellij.openapi.roots.ModuleRootModificationUtil import org.jetbrains.kotlin.config.JvmTarget import org.jetbrains.kotlin.config.TargetPlatformKind +import org.jetbrains.kotlin.idea.stubs.createFacet import org.jetbrains.kotlin.idea.test.PluginTestCaseBase +import org.jetbrains.kotlin.test.TestJdkKind class MultiModuleLineMarkerTest : AbstractMultiModuleHighlightingTest() { @@ -63,4 +65,23 @@ class MultiModuleLineMarkerTest : AbstractMultiModuleHighlightingTest() { } }) } + + fun testTransitive() { + val commonModule = module("common", TestJdkKind.MOCK_JDK) + commonModule.createFacet(TargetPlatformKind.Common, false) + val jvmPlatform = TargetPlatformKind.Jvm[JvmTarget.JVM_1_6] + + val baseModule = module("jvm_base", TestJdkKind.MOCK_JDK) + baseModule.createFacet(jvmPlatform, implementedModuleName = "common") + baseModule.enableMultiPlatform() + baseModule.addDependency(commonModule) + + val userModule = module("jvm_user", TestJdkKind.MOCK_JDK) + userModule.createFacet(jvmPlatform) + userModule.enableMultiPlatform() + userModule.addDependency(commonModule) + userModule.addDependency(baseModule) + + checkHighlightingInAllFiles() + } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiPlatformHighlightingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiPlatformHighlightingTest.kt new file mode 100644 index 00000000000..f742dd3d10c --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiPlatformHighlightingTest.kt @@ -0,0 +1,109 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.caches.resolve + +import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime +import org.jetbrains.kotlin.config.JvmTarget +import org.jetbrains.kotlin.config.TargetPlatformKind +import org.jetbrains.kotlin.idea.framework.JSLibraryKind +import org.jetbrains.kotlin.idea.stubs.createFacet +import org.jetbrains.kotlin.idea.test.PluginTestCaseBase +import org.jetbrains.kotlin.test.TestJdkKind + +// Some tests are ignored below. They fail because markers are not stripped correctly in multi-module highlighting tests. +// TODO: fix this in the test framework and unignore the tests +class MultiPlatformHighlightingTest : AbstractMultiModuleHighlightingTest() { + override fun getTestDataPath() = "${PluginTestCaseBase.getTestDataPathBase()}/multiModuleHighlighting/multiplatform/" + + fun testBasic() { + doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) + } + + fun testHeaderClass() { + doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) + } + + fun testHeaderWithoutImplForBoth() { + doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], TargetPlatformKind.JavaScript) + } + + fun ignore_testHeaderPartiallyImplemented() { + doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) + } + + fun testHeaderFunctionProperty() { + doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) + } + + fun testSuppressHeaderWithoutImpl() { + doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) + } + + fun testCatchHeaderExceptionInPlatformModule() { + doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], withStdlibCommon = true) + } + + fun testWithOverrides() { + doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) + } + + fun testUseCorrectBuiltInsForCommonModule() { + doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_8], TargetPlatformKind.JavaScript, + withStdlibCommon = true, jdk = TestJdkKind.FULL_JDK, configureModule = { module, platform -> + if (platform == TargetPlatformKind.JavaScript) { + module.addLibrary(ForTestCompileRuntime.stdlibJsForTests(), kind = JSLibraryKind) + module.addLibrary(ForTestCompileRuntime.stdlibCommonForTests()) + } + }) + } + + fun testHeaderClassImplTypealias() { + doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) + } + + fun testHeaderFunUsesStdlibInSignature() { + doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], withStdlibCommon = true, configureModule = { module, platform -> + if (platform is TargetPlatformKind.Jvm) { + module.addLibrary(ForTestCompileRuntime.runtimeJarForTests()) + } + }) + } + + fun ignore_testNestedClassWithoutImpl() { + doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]) + } + + fun testTransitive() { + val commonModule = module("common", TestJdkKind.MOCK_JDK) + commonModule.createFacet(TargetPlatformKind.Common, false) + val jvmPlatform = TargetPlatformKind.Jvm[JvmTarget.JVM_1_6] + + val baseModule = module("jvm_base", TestJdkKind.MOCK_JDK) + baseModule.createFacet(jvmPlatform, implementedModuleName = "common") + baseModule.enableMultiPlatform() + baseModule.addDependency(commonModule) + + val userModule = module("jvm_user", TestJdkKind.MOCK_JDK) + userModule.createFacet(jvmPlatform) + userModule.enableMultiPlatform() + userModule.addDependency(commonModule) + userModule.addDependency(baseModule) + + checkHighlightingInAllFiles() + } + +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureKotlinTest.kt b/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureKotlinTest.kt index 0cbc09cbe34..dd9edc4b6b2 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureKotlinTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/configuration/AbstractConfigureKotlinTest.kt @@ -16,21 +16,46 @@ package org.jetbrains.kotlin.idea.configuration +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.PathMacros import com.intellij.openapi.module.Module import com.intellij.openapi.module.ModuleManager import com.intellij.openapi.project.Project +import com.intellij.openapi.projectRoots.ProjectJdkTable +import com.intellij.openapi.projectRoots.Sdk +import com.intellij.openapi.roots.ProjectRootManager import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.FileUtilRt +import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess import com.intellij.testFramework.PlatformTestCase import com.intellij.testFramework.UsefulTestCase import junit.framework.TestCase import org.jetbrains.kotlin.idea.configuration.KotlinWithLibraryConfigurator.FileState +import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.utils.PathUtil import java.io.File import java.io.IOException abstract class AbstractConfigureKotlinTest : PlatformTestCase() { + override fun setUp() { + super.setUp() + + val distPaths = with(PathUtil.kotlinPathsForIdeaPlugin) { + listOf( + stdlibPath, + stdlibSourcesPath, + reflectPath, + kotlinTestPath, + jsKotlinTestJarPath, + jsStdLibJarPath, + jsStdLibSrcJarPath + ) + } + + for (path in distPaths) { + VfsRootAccess.allowRootAccess(testRootDisposable, path.absolutePath) + } + } @Throws(Exception::class) override fun tearDown() { @@ -43,6 +68,14 @@ abstract class AbstractConfigureKotlinTest : PlatformTestCase() { override fun initApplication() { super.initApplication() + ApplicationManager.getApplication().runWriteAction { + ProjectJdkTable.getInstance().addJdk(PluginTestCaseBase.mockJdk6()) + ProjectJdkTable.getInstance().addJdk(PluginTestCaseBase.mockJdk8()) + ProjectJdkTable.getInstance().addJdk(PluginTestCaseBase.mockJdk9()) + } + + PluginTestCaseBase.clearSdkTable(testRootDisposable) + val tempLibDir = FileUtil.createTempDirectory("temp", null) PathMacros.getInstance().setMacro(TEMP_DIR_MACRO_KEY, FileUtilRt.toSystemDependentName(tempLibDir.absolutePath)) } @@ -143,7 +176,7 @@ abstract class AbstractConfigureKotlinTest : PlatformTestCase() { jarFromDist: String, jarFromTemp: String ) { - val project = modules.iterator().next().project + val project = modules.first().project val collector = createConfigureKotlinNotificationCollector(project) val pathToJar = getPathToJar(runtimeState, jarFromDist, jarFromTemp) @@ -221,4 +254,9 @@ abstract class AbstractConfigureKotlinTest : PlatformTestCase() { return tempPath + '/' + relativePath } } + + override fun getTestProjectJdk(): Sdk { + val projectRootManager = ProjectRootManager.getInstance(project) + return projectRootManager.projectSdk ?: throw IllegalStateException("SDK ${projectRootManager.projectSdkName} was not found") + } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinTest.java b/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinTest.java index 1672f2469c9..490b8b7cdcf 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinTest.java @@ -18,11 +18,15 @@ package org.jetbrains.kotlin.idea.configuration; import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl; import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleManager; +import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.LibraryOrderEntry; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.RootPolicy; import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.psi.PsiJavaModule; +import com.intellij.psi.PsiRequiresStatement; import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments; import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments; import org.jetbrains.kotlin.config.*; @@ -30,11 +34,14 @@ import org.jetbrains.kotlin.idea.facet.FacetUtilsKt; import org.jetbrains.kotlin.idea.facet.KotlinFacet; import org.jetbrains.kotlin.idea.framework.JsLibraryStdDetectionUtil; import org.jetbrains.kotlin.idea.project.PlatformKt; +import org.jetbrains.kotlin.idea.util.Java9StructureUtilKt; import org.jetbrains.kotlin.idea.versions.KotlinRuntimeLibraryUtilKt; +import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleKt; import java.io.File; import java.io.IOException; import java.util.Collections; +import java.util.stream.StreamSupport; public class ConfigureKotlinTest extends AbstractConfigureKotlinTest { public void testNewLibrary_copyJar() { @@ -236,6 +243,49 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest { assertEquals("-version -Xallow-kotlin-package -Xskip-metadata-version-check", settings.getCompilerSettings().getAdditionalArguments()); } + public void testImplementsDependency() { + ModuleManager moduleManager = ModuleManager.getInstance(myProject); + + Module module1 = moduleManager.findModuleByName("module1"); + assert module1 != null; + + Module module2 = moduleManager.findModuleByName("module2"); + assert module2 != null; + + assertEquals(KotlinFacet.Companion.get(module1).getConfiguration().getSettings().getImplementedModuleName(), null); + assertEquals(KotlinFacet.Companion.get(module2).getConfiguration().getSettings().getImplementedModuleName(), "module1"); + } + + public void testJava9WithModuleInfo() { + checkAddStdlibModule(); + } + + public void testJava9WithModuleInfoWithStdlibAlready() { + checkAddStdlibModule(); + } + + private void checkAddStdlibModule() { + doTestOneJavaModule(KotlinWithLibraryConfigurator.FileState.COPY); + + Module module = getModule(); + Sdk moduleSdk = ModuleRootManager.getInstance(getModule()).getSdk(); + assertNotNull("Module SDK is not defined", moduleSdk); + + PsiJavaModule javaModule = Java9StructureUtilKt.findFirstPsiJavaModule(module); + assertNotNull(javaModule); + + PsiRequiresStatement stdlibDirective = + Java9StructureUtilKt.findRequireDirective(javaModule, JavaModuleKt.KOTLIN_STDLIB_MODULE_NAME); + assertNotNull("Require directive for " + JavaModuleKt.KOTLIN_STDLIB_MODULE_NAME + " is expected", + stdlibDirective); + + long numberOfStdlib = StreamSupport.stream(javaModule.getRequires().spliterator(), false) + .filter((statement) -> JavaModuleKt.KOTLIN_STDLIB_MODULE_NAME.equals(statement.getModuleName())) + .count(); + + assertTrue("Only one standard library directive is expected", numberOfStdlib == 1); + } + private void configureFacetAndCheckJvm(JvmTarget jvmTarget) { IdeModifiableModelsProviderImpl modelsProvider = new IdeModifiableModelsProviderImpl(getProject()); try { diff --git a/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinUtilTest.kt b/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinUtilTest.kt index 4b8af0399e4..fd31b9fa9d8 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinUtilTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinUtilTest.kt @@ -32,6 +32,8 @@ class ConfigureKotlinUtilTest : UsefulTestCase() { Assert.assertFalse(useEapRepository(1, "1.1.2")) Assert.assertFalse(useEapRepository(1, "1.1.2-3")) Assert.assertFalse(useEapRepository(1, "1.1.0-dev-1234")) + Assert.assertTrue(useEapRepository(1, "1.1.50-eap-28")) + Assert.assertFalse(useEapRepository(1, "1.1.50")) Assert.assertTrue(useEapRepository(2, "1.2-M01")) Assert.assertTrue(useEapRepository(2, "1.2-M1")) Assert.assertFalse(useEapRepository(2, "1.2")) diff --git a/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/AbstractQuickDocProviderTest.java b/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/AbstractQuickDocProviderTest.java index 68f09aefa32..fb39bf2319b 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/AbstractQuickDocProviderTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/editor/quickDoc/AbstractQuickDocProviderTest.java @@ -16,9 +16,7 @@ package org.jetbrains.kotlin.idea.editor.quickDoc; -import com.intellij.codeInsight.documentation.DocumentationComponent; import com.intellij.codeInsight.documentation.DocumentationManager; -import com.intellij.codeInsight.navigation.CtrlMouseHandler; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; @@ -35,7 +33,7 @@ import java.util.List; public abstract class AbstractQuickDocProviderTest extends KotlinLightCodeInsightFixtureTestCase { public void doTest(@NotNull String path) throws Exception { - IdeaTestUtilsKt.configureWithExtraFileAbs(myFixture, path, "_Data"); + IdeaTestUtilsKt.configureWithExtraFile(myFixture, path, "_Data"); PsiElement element = myFixture.getFile().findElementAt(myFixture.getEditor().getCaretModel().getOffset()); assertNotNull("Can't find element at caret in file: " + path, element); diff --git a/idea/tests/org/jetbrains/kotlin/idea/folding/AbstractKotlinFoldingTest.java b/idea/tests/org/jetbrains/kotlin/idea/folding/AbstractKotlinFoldingTest.java index 3234d8277ae..e2006ff13d3 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/folding/AbstractKotlinFoldingTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/folding/AbstractKotlinFoldingTest.java @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.idea.folding; -import com.google.common.base.Function; import com.intellij.codeInsight.folding.JavaCodeFoldingSettings; import com.intellij.codeInsight.folding.impl.JavaCodeFoldingSettingsImpl; import com.intellij.openapi.util.io.FileUtil; @@ -31,10 +30,10 @@ import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor; import org.jetbrains.kotlin.test.SettingsConfigurator; import org.junit.Assert; -import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; +import java.util.function.Consumer; public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFixtureTestCaseBase { protected void doTest(@NotNull String path) { @@ -47,14 +46,7 @@ public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFi String directText = fileText.replaceAll("~true~", "true").replaceAll("~false~", "false"); directText += "\n\n// Generated from: " + path; - Function doExpandSettingsTestFunction = new Function() { - @Nullable - @Override - public Void apply(@Nullable String fileText) { - doExpandSettingsTest(fileText); - return null; - } - }; + Consumer doExpandSettingsTestFunction = this::doExpandSettingsTest; doTestWithSettings(directText, doExpandSettingsTestFunction); @@ -68,7 +60,7 @@ public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFi doTestWithSettings(invertedText, doExpandSettingsTestFunction); } - protected static void doTestWithSettings(@NotNull String fileText, @NotNull Function runnable) { + protected static void doTestWithSettings(@NotNull String fileText, @NotNull Consumer runnable) { JavaCodeFoldingSettings settings = JavaCodeFoldingSettings.getInstance(); JavaCodeFoldingSettingsImpl restoreSettings = new JavaCodeFoldingSettingsImpl(); restoreSettings.loadState((JavaCodeFoldingSettingsImpl) settings); @@ -77,7 +69,7 @@ public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFi SettingsConfigurator configurator = new SettingsConfigurator(fileText, settings); configurator.configureSettings(); - runnable.apply(fileText); + runnable.accept(fileText); } finally { ((JavaCodeFoldingSettingsImpl) JavaCodeFoldingSettings.getInstance()).loadState(restoreSettings); @@ -87,7 +79,7 @@ public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFi private void doExpandSettingsTest(String fileText) { try { VirtualFile tempFile = PlatformTestCase.createTempFile("kt", null, fileText, Charset.defaultCharset()); - assertFoldingRegionsForFile(tempFile.getPath(), true); + assertFoldingRegionsForFile(tempFile.getPath()); } catch (IOException e) { throw new IllegalStateException(e); @@ -96,7 +88,7 @@ public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFi // Rewritten version of CodeInsightTestFixtureImpl.testFoldingRegions(verificationFileName, true). // Configure test with custom file name to force creating different editors for normal and inverted tests. - private void assertFoldingRegionsForFile(String verificationFileName, boolean doCheckCollapseStatus) { + private void assertFoldingRegionsForFile(String verificationFileName) { String START_FOLD = ""; String END_FOLD = ""; @@ -115,7 +107,7 @@ public abstract class AbstractKotlinFoldingTest extends KotlinLightCodeInsightFi String cleanContent = expectedContent.replaceAll(START_FOLD, "").replaceAll(END_FOLD, ""); myFixture.configureByText(file.getName(), cleanContent); - String actual = ((CodeInsightTestFixtureImpl)myFixture).getFoldingDescription(doCheckCollapseStatus); + String actual = ((CodeInsightTestFixtureImpl)myFixture).getFoldingDescription(true); Assert.assertEquals(expectedContent, actual); } diff --git a/idea/tests/org/jetbrains/kotlin/idea/highlighter/Jsr305HighlightingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/highlighter/Jsr305HighlightingTest.kt index 4ef3108388d..64ab3ef37d6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/highlighter/Jsr305HighlightingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/highlighter/Jsr305HighlightingTest.kt @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.idea.highlighter import com.intellij.openapi.module.Module import com.intellij.openapi.roots.ModifiableRootModel import com.intellij.testFramework.LightProjectDescriptor -import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime import org.jetbrains.kotlin.config.JvmTarget import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider @@ -29,6 +28,8 @@ import org.jetbrains.kotlin.idea.test.KotlinJdkAndLibraryProjectDescriptor import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import org.jetbrains.kotlin.test.MockLibraryUtil import org.jetbrains.kotlin.utils.Jsr305State +import org.jetbrains.kotlin.utils.ReportLevel +import org.jetbrains.kotlin.utils.ReportLevel.Companion.findByDescription class Jsr305HighlightingTest : KotlinLightCodeInsightFixtureTestCase() { override fun getProjectDescriptor(): LightProjectDescriptor { @@ -46,13 +47,36 @@ class Jsr305HighlightingTest : KotlinLightCodeInsightFixtureTestCase() { super.configureModule(module, model) module.createFacet(TargetPlatformKind.Jvm(JvmTarget.JVM_1_8)) val facetSettings = KotlinFacetSettingsProvider.getInstance(project).getInitializedSettings(module) - (facetSettings.compilerArguments as K2JVMCompilerArguments).jsr305 = Jsr305State.STRICT.description + + facetSettings.apply { + val jsrStateByTestName = + ReportLevel.findByDescription(getTestName(true)) ?: return@apply + + compilerSettings!!.additionalArguments += " -Xjsr305=${jsrStateByTestName.description}" + updateMergedArguments() + } } } } - fun testSimple() { - myFixture.configureByFile("A.kt") + fun testIgnore() { + doTest() + } + + fun testWarn() { + doTest() + } + + fun testStrict() { + doTest() + } + + fun testDefault() { + doTest() + } + + private fun doTest() { + myFixture.configureByFile("${getTestName(false)}.kt") myFixture.checkHighlighting() } diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt index 6f3e9b2775d..eb4d8753dbf 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt @@ -18,18 +18,14 @@ package org.jetbrains.kotlin.idea.inspections import com.google.common.collect.Lists import com.intellij.codeInspection.ProblemDescriptor -import com.intellij.openapi.application.WriteAction -import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.vfs.VirtualFile import junit.framework.ComparisonFailure import junit.framework.TestCase -import org.jetbrains.kotlin.config.LanguageFeature -import org.jetbrains.kotlin.idea.facet.configureFacet -import org.jetbrains.kotlin.idea.facet.getOrCreateFacet import org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase +import org.jetbrains.kotlin.idea.test.configureLanguageVersion import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.psiUtil.startOffset @@ -86,19 +82,7 @@ abstract class AbstractLocalInspectionTest : KotlinLightCodeInsightFixtureTestCa val fileText = FileUtil.loadFile(mainFile, true) TestCase.assertTrue("\"\" is missing in file \"$mainFile\"", fileText.contains("")) - val version = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// LANGUAGE_VERSION: ") - if (version != null) { - val accessToken = WriteAction.start() - try { - val modelsProvider = IdeModifiableModelsProviderImpl(project) - val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false) - facet.configureFacet(version, LanguageFeature.State.DISABLED, null, modelsProvider) - modelsProvider.commit() - } - finally { - accessToken.finish() - } - } + configureLanguageVersion(fileText, project, module) val minJavaVersion = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// MIN_JAVA_VERSION: ") if (minJavaVersion != null && !SystemInfo.isJavaVersionAtLeast(minJavaVersion)) return diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index 3d3562ed4cb..f78b909e7b3 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -1071,6 +1071,33 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { } } + @TestMetadata("idea/testData/inspectionsLocal/migrateDiagnosticSuppression") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MigrateDiagnosticSuppression extends AbstractLocalInspectionTest { + public void testAllFilesPresentInMigrateDiagnosticSuppression() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/migrateDiagnosticSuppression"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("base.kt") + public void testBase() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/migrateDiagnosticSuppression/base.kt"); + doTest(fileName); + } + + @TestMetadata("multiple.kt") + public void testMultiple() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/migrateDiagnosticSuppression/multiple.kt"); + doTest(fileName); + } + + @TestMetadata("new.kt") + public void testNew() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/migrateDiagnosticSuppression/new.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/inspectionsLocal/moveSuspiciousCallableReferenceIntoParentheses") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index e2f8d7298b8..2b59dad1718 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -6479,6 +6479,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("getterTypeInferred.kt") + public void testGetterTypeInferred() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertToBlockBody/getterTypeInferred.kt"); + doTest(fileName); + } + @TestMetadata("getterWithThrow.kt") public void testGetterWithThrow() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertToBlockBody/getterWithThrow.kt"); @@ -12614,6 +12620,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("necessaryBrackets6.kt") + public void testNecessaryBrackets6() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeCurlyBracesFromTemplate/necessaryBrackets6.kt"); + doTest(fileName); + } + @TestMetadata("unnecessaryBrackets1.kt") public void testUnnecessaryBrackets1() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeCurlyBracesFromTemplate/unnecessaryBrackets1.kt"); @@ -13412,6 +13424,18 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("elvisRhs.kt") + public void testElvisRhs() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryParentheses/elvisRhs.kt"); + doTest(fileName); + } + + @TestMetadata("elvisRhsEmptyReturn.kt") + public void testElvisRhsEmptyReturn() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryParentheses/elvisRhsEmptyReturn.kt"); + doTest(fileName); + } + @TestMetadata("necessaryParentheses1.kt") public void testNecessaryParentheses1() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryParentheses/necessaryParentheses1.kt"); @@ -13562,6 +13586,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("arrayEXCLEQ.kt") + public void testArrayEXCLEQ() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/arrayEXCLEQ.kt"); + doTest(fileName); + } + @TestMetadata("primitiveArrayEQEQ.kt") public void testPrimitiveArrayEQEQ() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/replaceArrayEqualityOpWithArraysEquals/primitiveArrayEQEQ.kt"); @@ -14675,6 +14705,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/simplifyBooleanWithConstants"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("assert.kt") + public void testAssert() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyBooleanWithConstants/assert.kt"); + doTest(fileName); + } + @TestMetadata("deeplyParenthesized.kt") public void testDeeplyParenthesized() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/simplifyBooleanWithConstants/deeplyParenthesized.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/declarations/JoinLinesTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/declarations/JoinLinesTestGenerated.java index d6cb192178d..d17ebbc20a1 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/declarations/JoinLinesTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/declarations/JoinLinesTestGenerated.java @@ -359,6 +359,12 @@ public class JoinLinesTestGenerated extends AbstractJoinLinesTest { doTest(fileName); } + @TestMetadata("FunctionWithOneLineReturn.kt") + public void testFunctionWithOneLineReturn() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/joinLines/removeBraces/FunctionWithOneLineReturn.kt"); + doTest(fileName); + } + @TestMetadata("If.kt") public void testIf() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/joinLines/removeBraces/If.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiFileTest.kt b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiFileTest.kt index 7c6e8b70acf..01491b5e9fc 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiFileTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiFileTest.kt @@ -17,23 +17,23 @@ package org.jetbrains.kotlin.idea.quickfix import com.intellij.codeInsight.CodeInsightSettings +import com.intellij.codeInsight.daemon.impl.HighlightInfo import com.intellij.codeInsight.daemon.quickFix.ActionHint import com.intellij.codeInsight.intention.IntentionAction import com.intellij.codeInspection.InspectionEP -import com.intellij.codeInspection.InspectionProfileEntry import com.intellij.codeInspection.LocalInspectionEP import com.intellij.ide.highlighter.JavaFileType import com.intellij.openapi.command.CommandProcessor +import com.intellij.openapi.editor.Editor import com.intellij.openapi.extensions.Extensions import com.intellij.openapi.fileTypes.FileType import com.intellij.openapi.fileTypes.PlainTextFileType import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.CharsetToolkit -import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.vfs.VirtualFile -import com.intellij.testFramework.VfsTestUtil +import com.intellij.psi.PsiFile import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl import com.intellij.util.ArrayUtil import com.intellij.util.containers.ContainerUtil @@ -47,12 +47,10 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.testFramework.runWriteAction import java.io.File -import java.io.IOException import java.util.* import java.util.regex.Pattern abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTestCase() { - @Throws(Exception::class) protected open fun doTestWithExtraFile(beforeFileName: String) { enableInspections(beforeFileName) @@ -64,7 +62,6 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest } } - @Throws(IOException::class, ClassNotFoundException::class) private fun enableInspections(beforeFileName: String) { val inspectionFile = findInspectionFile(File(beforeFileName).parentFile) if (inspectionFile != null) { @@ -79,15 +76,10 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest ContainerUtil.addAll>(eps, *Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION)) ContainerUtil.addAll>(eps, *Extensions.getExtensions(InspectionEP.GLOBAL_INSPECTION)) - var tool: InspectionProfileEntry? = null - for (ep in eps) { - if (klass.name == ep.implementationClass) { - tool = ep.instantiateTool() - } - } - assert(tool != null) { "Could not find inspection tool for class: " + klass } + val tool = eps.firstOrNull { it.implementationClass == klass.name }?.instantiateTool() + ?: error("Could not find inspection tool for class: $klass") - myFixture.enableInspections(tool!!) + myFixture.enableInspections(tool) } override fun setUp() { @@ -105,11 +97,8 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest * * * @param beforeFile will be added last, as subFiles are dependencies of it */ - protected fun configureMultiFileTest(subFiles: List, beforeFile: TestFile): List { - val vFiles = mutableListOf() - for (subFile in subFiles) { - vFiles.add(createTestFile(subFile)) - } + private fun configureMultiFileTest(subFiles: List, beforeFile: TestFile): List { + val vFiles = subFiles.map(this::createTestFile).toMutableList() val beforeVFile = createTestFile(beforeFile) vFiles.add(beforeVFile) myFixture.configureFromExistingVirtualFile(beforeVFile) @@ -122,14 +111,13 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest private fun createTestFile(testFile: TestFile): VirtualFile { return runWriteAction { val vFile = myFixture.tempDirFixture.createFile(testFile.path) - vFile.setCharset(CharsetToolkit.UTF8_CHARSET) + vFile.charset = CharsetToolkit.UTF8_CHARSET VfsUtil.saveText(vFile, testFile.content) vFile } } - @Throws(Exception::class) - protected fun doMultiFileTest(beforeFileName: String) { + private fun doMultiFileTest(beforeFileName: String) { val multifileText = FileUtil.loadFile(File(beforeFileName), true) val subFiles = KotlinTestUtils.createTestFiles( @@ -137,11 +125,9 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest multifileText, object : KotlinTestUtils.TestFileFactoryNoModules() { override fun create(fileName: String, text: String, directives: Map): TestFile { - var text = text if (text.startsWith("// FILE")) { - val firstLineDropped = StringUtil.substringAfter(text, "\n")!! - - text = firstLineDropped + // Drop the first line + return TestFile(fileName, StringUtil.substringAfter(text, "\n")!!) } return TestFile(fileName, text) } @@ -170,7 +156,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest DirectiveBasedActionUtils.checkForUnexpectedErrors(psiFile) } - doAction(text, actionShouldBeAvailable, getTestName(false)) + doAction(text, file, editor, actionShouldBeAvailable, getTestName(false), this::availableActions, myFixture::doHighlighting) val actualText = file.text val afterText = StringBuilder(actualText).insert(editor.caretModel.offset, "").toString() @@ -205,7 +191,6 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest }, "", "") } - @Throws(Exception::class) private fun doTest(beforeFileName: String) { val mainFile = File(beforeFileName) val originalFileText = FileUtil.loadFile(mainFile, true) @@ -213,7 +198,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest val mainFileDir = mainFile.parentFile!! val mainFileName = mainFile.name - val extraFiles = mainFileDir.listFiles { dir, name -> name.startsWith(extraFileNamePrefix(mainFileName)) && name != mainFileName }!! + val extraFiles = mainFileDir.listFiles { _, name -> name.startsWith(extraFileNamePrefix(mainFileName)) && name != mainFileName }!! val testFiles = ArrayList() testFiles.add(mainFile.name) @@ -234,7 +219,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest DirectiveBasedActionUtils.checkForUnexpectedErrors(psiFile) } - doAction(text, actionShouldBeAvailable, beforeFileName) + doAction(text, file, editor, actionShouldBeAvailable, beforeFileName, this::availableActions, myFixture::doHighlighting) if (actionShouldBeAvailable) { val afterFilePath = beforeFileName.replace(".before.Main.", ".after.") @@ -245,13 +230,11 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest KotlinTestUtils.assertEqualsToFile(File(afterFilePath), editor) } - val mainFile = myFixture.file - val mainFileName = mainFile.name - for (file in mainFile.containingDirectory.files) { + for (file in myFixture.file.containingDirectory.files) { val fileName = file.name - if (fileName == mainFileName || !fileName.startsWith(extraFileNamePrefix(myFixture.file.name))) continue + if (fileName == myFixture.file.name || !fileName.startsWith(extraFileNamePrefix(myFixture.file.name))) continue - val extraFileFullPath = beforeFileName.replace(mainFileName, fileName) + val extraFileFullPath = beforeFileName.replace(myFixture.file.name, fileName) val afterFile = File(extraFileFullPath.replace(".before.", ".after.")) if (afterFile.exists()) { KotlinTestUtils.assertEqualsToFile(afterFile, file.text) @@ -275,50 +258,6 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest }, "", "") } - @Throws(Exception::class) - fun doAction(text: String, actionShouldBeAvailable: Boolean, testFilePath: String) { - val pattern = if (text.startsWith("/")) - Pattern.compile(text.substring(1, text.length - 1)) - else - Pattern.compile(StringUtil.escapeToRegexp(text)) - - val availableActions = availableActions - val action = findActionByPattern(pattern, availableActions) - - if (action == null) { - if (actionShouldBeAvailable) { - val texts = getActionsTexts(availableActions) - val infos = myFixture.doHighlighting() - TestCase.fail("Action with text '" + text + "' is not available in test " + testFilePath + "\n" + - "Available actions (" + texts.size + "): \n" + - StringUtil.join(texts, "\n") + - "\nActions:\n" + - StringUtil.join(availableActions, "\n") + - "\nInfos:\n" + - StringUtil.join(infos, "\n")) - } - else { - DirectiveBasedActionUtils.checkAvailableActionsAreExpected(file, availableActions) - } - } - else { - if (!actionShouldBeAvailable) { - TestCase.fail("Action '$text' is available (but must not) in test $testFilePath") - } - - CodeInsightTestFixtureImpl.invokeIntention(action, file, editor, action.text) - - if (!shouldBeAvailableAfterExecution()) { - val afterAction = findActionByPattern(pattern, this.availableActions) - - if (afterAction != null) { - TestCase.fail("Action '$text' is still available after its invocation in test $testFilePath") - } - } - } - } - - private val availableActions: List get() { myFixture.doHighlighting() @@ -328,42 +267,70 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest class TestFile internal constructor(val path: String, val content: String) companion object { + private fun getActionsTexts(availableActions: List): List = + availableActions.map(IntentionAction::getText) - protected fun shouldBeAvailableAfterExecution(): Boolean { - return false + private fun extraFileNamePrefix(mainFileName: String): String = + mainFileName.replace(".Main.kt", ".").replace(".Main.java", ".") + + protected fun guessFileType(file: TestFile): FileType = when { + file.path.contains("." + KotlinFileType.EXTENSION) -> KotlinFileType.INSTANCE + file.path.contains("." + JavaFileType.DEFAULT_EXTENSION) -> JavaFileType.INSTANCE + else -> PlainTextFileType.INSTANCE } - private fun getActionsTexts(availableActions: List): List { - val texts = ArrayList() - for (intentionAction in availableActions) { - texts.add(intentionAction.text) - } - return texts - } + private fun findActionByPattern(pattern: Pattern, availableActions: List): IntentionAction? = + availableActions.firstOrNull { pattern.matcher(it.text).matches() } - private fun extraFileNamePrefix(mainFileName: String): String { - return mainFileName.replace(".Main.kt", ".").replace(".Main.java", ".") - } + fun doAction( + text: String, + file: PsiFile, + editor: Editor, + actionShouldBeAvailable: Boolean, + testFilePath: String, + getAvailableActions: () -> List, + doHighlighting: () -> List, + shouldBeAvailableAfterExecution: Boolean = false + ) { + val pattern = if (text.startsWith("/")) + Pattern.compile(text.substring(1, text.length - 1)) + else + Pattern.compile(StringUtil.escapeToRegexp(text)) - protected fun guessFileType(file: TestFile): FileType { - if (file.path.contains("." + KotlinFileType.EXTENSION)) { - return KotlinFileType.INSTANCE - } - else if (file.path.contains("." + JavaFileType.DEFAULT_EXTENSION)) { - return JavaFileType.INSTANCE - } - else { - return PlainTextFileType.INSTANCE - } - } + val availableActions = getAvailableActions() + val action = findActionByPattern(pattern, availableActions) - private fun findActionByPattern(pattern: Pattern, availableActions: List): IntentionAction? { - for (availableAction in availableActions) { - if (pattern.matcher(availableAction.text).matches()) { - return availableAction + if (action == null) { + if (actionShouldBeAvailable) { + val texts = getActionsTexts(availableActions) + val infos = doHighlighting() + TestCase.fail("Action with text '" + text + "' is not available in test " + testFilePath + "\n" + + "Available actions (" + texts.size + "): \n" + + StringUtil.join(texts, "\n") + + "\nActions:\n" + + StringUtil.join(availableActions, "\n") + + "\nInfos:\n" + + StringUtil.join(infos, "\n")) + } + else { + DirectiveBasedActionUtils.checkAvailableActionsAreExpected(file, availableActions) + } + } + else { + if (!actionShouldBeAvailable) { + TestCase.fail("Action '$text' is available (but must not) in test $testFilePath") + } + + CodeInsightTestFixtureImpl.invokeIntention(action, file, editor, action.text) + + if (!shouldBeAvailableAfterExecution) { + val afterAction = findActionByPattern(pattern, getAvailableActions()) + + if (afterAction != null) { + TestCase.fail("Action '$text' is still available after its invocation in test $testFilePath") + } } } - return null } } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiModuleTest.kt b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiModuleTest.kt index af5b95a1831..e3591c12713 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiModuleTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiModuleTest.kt @@ -19,10 +19,7 @@ package org.jetbrains.kotlin.idea.quickfix import com.intellij.codeInsight.daemon.quickFix.ActionHint import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase import com.intellij.codeInsight.intention.IntentionAction -import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler import com.intellij.openapi.command.CommandProcessor -import com.intellij.openapi.util.text.StringUtil -import com.intellij.util.ui.UIUtil import junit.framework.ComparisonFailure import junit.framework.TestCase import org.jetbrains.kotlin.idea.inspections.findExistingEditor @@ -34,17 +31,11 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.KotlinTestUtils import java.io.File -import java.util.regex.Pattern abstract class AbstractQuickFixMultiModuleTest : AbstractMultiModuleTest() { override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleQuickFix/" - protected fun shouldBeAvailableAfterExecution(file: KtFile) = - InTextDirectivesUtils.isDirectiveDefined(file.text, "// SHOULD_BE_AVAILABLE_AFTER_EXECUTION") - - private fun getActionsTexts(availableActions: List) = availableActions.map { it.text } - protected fun doQuickFixTest() { val allFilesInProject = PluginJetFilesProvider.allFilesInProject(myProject!!) val actionFile = allFilesInProject.single { file -> @@ -58,18 +49,19 @@ abstract class AbstractQuickFixMultiModuleTest : AbstractMultiModuleTest() { CommandProcessor.getInstance().executeCommand(project, { try { - val psiFile = actionFile - - val actionHint = ActionHint.parse(psiFile, actionFileText) + val actionHint = ActionHint.parse(actionFile, actionFileText) val text = actionHint.expectedText val actionShouldBeAvailable = actionHint.shouldPresent() - if (psiFile is KtFile) { - DirectiveBasedActionUtils.checkForUnexpectedErrors(psiFile) + if (actionFile is KtFile) { + DirectiveBasedActionUtils.checkForUnexpectedErrors(actionFile) } - doAction(text, actionShouldBeAvailable, actionFileName, actionFile) + AbstractQuickFixMultiFileTest.doAction( + text, file, editor, actionShouldBeAvailable, actionFileName, this::availableActions, this::doHighlighting, + InTextDirectivesUtils.isDirectiveDefined(actionFile.text, "// SHOULD_BE_AVAILABLE_AFTER_EXECUTION") + ) if (actionShouldBeAvailable) { val testDirectory = File(testDataPath) @@ -106,66 +98,11 @@ abstract class AbstractQuickFixMultiModuleTest : AbstractMultiModuleTest() { }, "", "") } - // TODO: merge with AbstractQuickFixMultiFileTest - - fun doAction(text: String, actionShouldBeAvailable: Boolean, testFilePath: String, actionFile: KtFile) { - val pattern = if (text.startsWith("/")) - Pattern.compile(text.substring(1, text.length - 1)) - else - Pattern.compile(StringUtil.escapeToRegexp(text)) - - val availableActions = getAvailableActions() - val action = findActionByPattern(pattern, availableActions) - - if (action == null) { - if (actionShouldBeAvailable) { - val texts = getActionsTexts(availableActions) - val infos = doHighlighting() - TestCase.fail("Action with text '" + text + "' is not available in test " + testFilePath + "\n" + - "Available actions (" + texts.size + "): \n" + - StringUtil.join(texts, "\n") + - "\nActions:\n" + - StringUtil.join(availableActions, "\n") + - "\nInfos:\n" + - StringUtil.join(infos, "\n")) - } - else { - DirectiveBasedActionUtils.checkAvailableActionsAreExpected(file, availableActions) - } + private val availableActions: List + get() { + doHighlighting() + return LightQuickFixTestCase.getAvailableActions(editor, file) } - else { - if (!actionShouldBeAvailable) { - TestCase.fail("Action '$text' is available (but must not) in test $testFilePath") - } - - ShowIntentionActionsHandler.chooseActionAndInvoke(file, editor, action, action.text) - - UIUtil.dispatchAllInvocationEvents() - - - if (!shouldBeAvailableAfterExecution(actionFile)) { - val afterAction = findActionByPattern(pattern, getAvailableActions()) - - if (afterAction != null) { - TestCase.fail("Action '$text' is still available after its invocation in test $testFilePath") - } - } - } - } - - private fun findActionByPattern(pattern: Pattern, availableActions: List): IntentionAction? { - for (availableAction in availableActions) { - if (pattern.matcher(availableAction.text).matches()) { - return availableAction - } - } - return null - } - - private fun getAvailableActions(): List { - doHighlighting() - return LightQuickFixTestCase.getAvailableActions(editor, file) - } override fun getTestProjectJdk() = PluginTestCaseBase.mockJdk() } diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.kt b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.kt index f62155200a5..323ca7e6276 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,10 @@ import java.io.IOException abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase() { @Throws(Exception::class) protected fun doTest(beforeFileName: String) { - enableInspections(beforeFileName) + val beforeFileText = FileUtil.loadFile(File(beforeFileName)) + configureLanguageVersion(beforeFileText, project, module) + + enableInspections(beforeFileName, beforeFileText) doKotlinQuickFixTest(beforeFileName) checkForUnexpectedErrors() @@ -140,8 +143,7 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase() { } } - private fun enableInspections(beforeFileName: String) { - val beforeFileText = FileUtil.loadFile(File(beforeFileName)) + private fun enableInspections(beforeFileName: String, beforeFileText: String) { val toolsStrings = InTextDirectivesUtils.findListWithPrefixes(beforeFileText, "TOOL:") if (toolsStrings.isNotEmpty()) { val inspections = toolsStrings.map { toolFqName -> diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AddRequireModuleTest.kt b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AddRequireModuleTest.kt new file mode 100644 index 00000000000..dd2025a2818 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AddRequireModuleTest.kt @@ -0,0 +1,104 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.quickfix + +import com.intellij.codeInsight.daemon.QuickFixBundle +import org.jetbrains.kotlin.idea.test.KotlinLightJava9ModulesCodeInsightFixtureTestCase +import org.jetbrains.kotlin.idea.test.KotlinMultiModuleJava9ProjectDescriptor.ModuleDescriptor.* + + +class KotlinAddRequiredModuleTest : KotlinLightJava9ModulesCodeInsightFixtureTestCase() { + private val messageM2 = QuickFixBundle.message("module.info.add.requires.name", "M_TWO")!! + + override fun setUp() { + super.setUp() + moduleInfo("module M_TWO { exports pkgA; }", M2) + addJavaFile("pkgA/A.java", "package pkgA; public class A {}", M2) + } + + fun testAddRequiresToModuleInfo() { + moduleInfo("module MAIN {}", MAIN) + val editedFile = addKotlinFile( + "pkgB/B.kt", + """ + package pkgB + import pkgA.A + class B(a: /*|*/A) + """, + MAIN) + myFixture.configureFromExistingVirtualFile(editedFile) + + findActionAndExecute(messageM2) + assertNoErrors() + + checkModuleInfo( + """ + module MAIN { + requires M_TWO; + } + """) + } + + fun testNoIdeaModuleDependency() { + moduleInfo("module M_THREE {}", M3) + val editedFile = addKotlinFile( + "pkgB/B.kt", + """ + package pkgB + import pkgA.A + class B(a: /*|*/A) + """, + M3) + myFixture.configureFromExistingVirtualFile(editedFile) + + val actions = myFixture.filterAvailableIntentions(messageM2) + assertEmpty(actions) + } + + fun testAddRequiresToInfoForJavaModule() { + moduleInfo("module MAIN {}", MAIN) + val editedFile = addKotlinFile( + "test.kt", + """ + fun test() { + java.util.logging./*|*/FileHandler() // <-- error; "add 'requires java.logging'" quick fix expected + } + """, + MAIN) + myFixture.configureFromExistingVirtualFile(editedFile) + + findActionAndExecute(QuickFixBundle.message("module.info.add.requires.name", "java.logging")!!) + + assertNoErrors() + checkModuleInfo( + """ + module MAIN { + requires java.logging; + } + """) + } + + private fun assertNoErrors() { + myFixture.checkHighlighting(false, false, false) + } + + private fun findActionAndExecute(message: String) { + val action = myFixture.findSingleIntention(message) + assertNotNull(action) + myFixture.launchAction(action) + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTest.kt b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTest.kt index ef5cdce7a5d..e1a8960d49b 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiModuleTest.kt @@ -32,7 +32,7 @@ class QuickFixMultiModuleTest : AbstractQuickFixMultiModuleTest() { impls.forEach { (implName, implKind) -> val implModule = module(implName, hasTestRoot = withTests) - implModule.createFacet(implKind) + implModule.createFacet(implKind, implementedModuleName = expectName) implModule.enableMultiPlatform() implModule.addDependency(commonModule) } @@ -189,4 +189,13 @@ class QuickFixMultiModuleTest : AbstractQuickFixMultiModuleTest() { @Test fun testImplementMembersInImplClassNonImplInheritor() = doMultiPlatformTest() -} \ No newline at end of file + + @Test + fun testAddActualToClass() = doMultiPlatformTest() + + @Test + fun testAddActualToClassMember() = doMultiPlatformTest() + + @Test + fun testAddActualToTopLevelMember() = doMultiPlatformTest() +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index 0562bbf9445..9c7ef95138d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -252,6 +252,111 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { } } + @TestMetadata("idea/testData/quickfix/addDataModifier") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AddDataModifier extends AbstractQuickFixTest { + @TestMetadata("abstract.kt") + public void testAbstract() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/abstract.kt"); + doTest(fileName); + } + + public void testAllFilesPresentInAddDataModifier() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/addDataModifier"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("inner.kt") + public void testInner() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/inner.kt"); + doTest(fileName); + } + + @TestMetadata("invisibleParameter.kt") + public void testInvisibleParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/invisibleParameter.kt"); + doTest(fileName); + } + + @TestMetadata("invisibleParameter2.kt") + public void testInvisibleParameter2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/invisibleParameter2.kt"); + doTest(fileName); + } + + @TestMetadata("noParameter.kt") + public void testNoParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/noParameter.kt"); + doTest(fileName); + } + + @TestMetadata("notVarVal.kt") + public void testNotVarVal() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/notVarVal.kt"); + doTest(fileName); + } + + @TestMetadata("open.kt") + public void testOpen() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/open.kt"); + doTest(fileName); + } + + @TestMetadata("sealed.kt") + public void testSealed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/sealed.kt"); + doTest(fileName); + } + + @TestMetadata("test1.kt") + public void testTest1() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/test1.kt"); + doTest(fileName); + } + + @TestMetadata("test2.kt") + public void testTest2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/test2.kt"); + doTest(fileName); + } + + @TestMetadata("test3.kt") + public void testTest3() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/test3.kt"); + doTest(fileName); + } + + @TestMetadata("test4.kt") + public void testTest4() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/test4.kt"); + doTest(fileName); + } + + @TestMetadata("test5.kt") + public void testTest5() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/test5.kt"); + doTest(fileName); + } + + @TestMetadata("test6.kt") + public void testTest6() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/test6.kt"); + doTest(fileName); + } + + @TestMetadata("test7.kt") + public void testTest7() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/test7.kt"); + doTest(fileName); + } + + @TestMetadata("vararg.kt") + public void testVararg() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/addDataModifier/vararg.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/quickfix/addExclExclCall") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -8774,6 +8879,18 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { doTest(fileName); } + @TestMetadata("necessaryBrackets1.kt") + public void testNecessaryBrackets1() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets1.kt"); + doTest(fileName); + } + + @TestMetadata("necessaryBrackets2.kt") + public void testNecessaryBrackets2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/removeToStringInStringTemplate/necessaryBrackets2.kt"); + doTest(fileName); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/removeToStringInStringTemplate/simple.kt"); @@ -9174,6 +9291,33 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { } } + @TestMetadata("idea/testData/quickfix/replaceWithArrayCallInAnnotation") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ReplaceWithArrayCallInAnnotation extends AbstractQuickFixTest { + public void testAllFilesPresentInReplaceWithArrayCallInAnnotation() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/replaceWithArrayCallInAnnotation"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("emptyLiteral.kt") + public void testEmptyLiteral() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/replaceWithArrayCallInAnnotation/emptyLiteral.kt"); + doTest(fileName); + } + + @TestMetadata("literalWithValues.kt") + public void testLiteralWithValues() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/replaceWithArrayCallInAnnotation/literalWithValues.kt"); + doTest(fileName); + } + + @TestMetadata("replaceSingleElementInNamedForm.kt") + public void testReplaceSingleElementInNamedForm() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/replaceWithArrayCallInAnnotation/replaceSingleElementInNamedForm.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/quickfix/replaceWithDotCall") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -9424,6 +9568,24 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/simplifyComparison/somethingAndNotNull.kt"); doTest(fileName); } + + @TestMetadata("withAssertion.kt") + public void testWithAssertion() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/simplifyComparison/withAssertion.kt"); + doTest(fileName); + } + + @TestMetadata("withAssertion2.kt") + public void testWithAssertion2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/simplifyComparison/withAssertion2.kt"); + doTest(fileName); + } + + @TestMetadata("withAssertion3.kt") + public void testWithAssertion3() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/simplifyComparison/withAssertion3.kt"); + doTest(fileName); + } } @TestMetadata("idea/testData/quickfix/specifyOverrideExplicitly") @@ -10278,6 +10440,39 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { } } + @TestMetadata("idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SurroundWithArrayOfForNamedArgumentsToVarargs extends AbstractQuickFixTest { + public void testAllFilesPresentInSurroundWithArrayOfForNamedArgumentsToVarargs() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("replaceForVarargOfAny.kt") + public void testReplaceForVarargOfAny() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceForVarargOfAny.kt"); + doTest(fileName); + } + + @TestMetadata("replaceToArrayOfPrimitiveTypes.kt") + public void testReplaceToArrayOfPrimitiveTypes() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/replaceToArrayOfPrimitiveTypes.kt"); + doTest(fileName); + } + + @TestMetadata("simpleNamedArgumentToVararg.kt") + public void testSimpleNamedArgumentToVararg() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/simpleNamedArgumentToVararg.kt"); + doTest(fileName); + } + + @TestMetadata("surroundWithSpreadForConstructorCall.kt") + public void testSurroundWithSpreadForConstructorCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/surroundWithArrayOfForNamedArgumentsToVarargs/surroundWithSpreadForConstructorCall.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/quickfix/surroundWithNullCheck") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -11138,6 +11333,81 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { } } + @TestMetadata("idea/testData/quickfix/typeMismatch/convertCollection") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConvertCollection extends AbstractQuickFixTest { + public void testAllFilesPresentInConvertCollection() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/typeMismatch/convertCollection"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("arrayToCollection.kt") + public void testArrayToCollection() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/convertCollection/arrayToCollection.kt"); + doTest(fileName); + } + + @TestMetadata("arrayToIterable.kt") + public void testArrayToIterable() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/convertCollection/arrayToIterable.kt"); + doTest(fileName); + } + + @TestMetadata("arrayToList.kt") + public void testArrayToList() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/convertCollection/arrayToList.kt"); + doTest(fileName); + } + + @TestMetadata("arrayToSequence.kt") + public void testArrayToSequence() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/convertCollection/arrayToSequence.kt"); + doTest(fileName); + } + + @TestMetadata("iterableToArray.kt") + public void testIterableToArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/convertCollection/iterableToArray.kt"); + doTest(fileName); + } + + @TestMetadata("listToArray.kt") + public void testListToArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/convertCollection/listToArray.kt"); + doTest(fileName); + } + + @TestMetadata("listToArrayBinary.kt") + public void testListToArrayBinary() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/convertCollection/listToArrayBinary.kt"); + doTest(fileName); + } + + @TestMetadata("listToMutableList.kt") + public void testListToMutableList() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/convertCollection/listToMutableList.kt"); + doTest(fileName); + } + + @TestMetadata("listToSequence.kt") + public void testListToSequence() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/convertCollection/listToSequence.kt"); + doTest(fileName); + } + + @TestMetadata("sequenceToArray.kt") + public void testSequenceToArray() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/convertCollection/sequenceToArray.kt"); + doTest(fileName); + } + + @TestMetadata("sequenceToList.kt") + public void testSequenceToList() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/typeMismatch/convertCollection/sequenceToList.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/quickfix/typeMismatch/fixOverloadedOperator") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/copy/CopyTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/copy/CopyTestGenerated.java index f4cb8bba240..dd94179ebe9 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/copy/CopyTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/copy/CopyTestGenerated.java @@ -72,6 +72,30 @@ public class CopyTestGenerated extends AbstractCopyTest { doTest(fileName); } + @TestMetadata("copyFIleFromDefaultPackage/copyFIleFromDefaultPackage.test") + public void testCopyFIleFromDefaultPackage_CopyFIleFromDefaultPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/copyFIleFromDefaultPackage/copyFIleFromDefaultPackage.test"); + doTest(fileName); + } + + @TestMetadata("copyFIleRetainContent/copyFIleRetainContent.test") + public void testCopyFIleRetainContent_CopyFIleRetainContent() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/copyFIleRetainContent/copyFIleRetainContent.test"); + doTest(fileName); + } + + @TestMetadata("copyFIleToDefaultPackage/copyFIleToDefaultPackage.test") + public void testCopyFIleToDefaultPackage_CopyFIleToDefaultPackage() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/copyFIleToDefaultPackage/copyFIleToDefaultPackage.test"); + doTest(fileName); + } + + @TestMetadata("copyFIleWithPackageAndDirUnmatched/copyFIleWithPackageAndDirUnmatched.test") + public void testCopyFIleWithPackageAndDirUnmatched_CopyFIleWithPackageAndDirUnmatched() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/copyFIleWithPackageAndDirUnmatched/copyFIleWithPackageAndDirUnmatched.test"); + doTest(fileName); + } + @TestMetadata("copyFunCallQualificationWithParentheses/copyFunCallQualificationWithParentheses.test") public void testCopyFunCallQualificationWithParentheses_CopyFunCallQualificationWithParentheses() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/copyFunCallQualificationWithParentheses/copyFunCallQualificationWithParentheses.test"); @@ -144,12 +168,24 @@ public class CopyTestGenerated extends AbstractCopyTest { doTest(fileName); } + @TestMetadata("copySingleClass/copySingleClass.test") + public void testCopySingleClass_CopySingleClass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/copySingleClass/copySingleClass.test"); + doTest(fileName); + } + @TestMetadata("copySingleClassFile/copySingleClassFile.test") public void testCopySingleClassFile_CopySingleClassFile() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/copySingleClassFile/copySingleClassFile.test"); doTest(fileName); } + @TestMetadata("copySingleClassWithRename/copySingleClassWithRename.test") + public void testCopySingleClassWithRename_CopySingleClassWithRename() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/copySingleClassWithRename/copySingleClassWithRename.test"); + doTest(fileName); + } + @TestMetadata("copyTopLevelFunction/copyTopLevelFunction.test") public void testCopyTopLevelFunction_CopyTopLevelFunction() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/copyTopLevelFunction/copyTopLevelFunction.test"); @@ -174,6 +210,12 @@ public class CopyTestGenerated extends AbstractCopyTest { doTest(fileName); } + @TestMetadata("copyWithImportInsertion/copyWithImportInsertion.test") + public void testCopyWithImportInsertion_CopyWithImportInsertion() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/copyWithImportInsertion/copyWithImportInsertion.test"); + doTest(fileName); + } + @TestMetadata("kt18149/kt18149.test") public void testKt18149_Kt18149() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/copy/kt18149/kt18149.test"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.kt b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.kt index a295326d041..72a1bb4fbf1 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.kt @@ -99,8 +99,6 @@ abstract class AbstractReferenceResolveTest : KotlinLightPlatformCodeInsightFixt override fun getProjectDescriptor(): LightProjectDescriptor? = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE - override fun getTestDataPath() = "./" - open val refMarkerText: String = "REF" companion object { diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/AdditionalResolveDescriptorRendererTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/resolve/AdditionalResolveDescriptorRendererTestGenerated.java index d958df69050..91b2141d772 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/AdditionalResolveDescriptorRendererTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/AdditionalResolveDescriptorRendererTestGenerated.java @@ -36,6 +36,12 @@ public class AdditionalResolveDescriptorRendererTestGenerated extends AbstractAd KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/resolve/additionalLazyResolve"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("anonymousObjectInBaseConstructor.kt") + public void testAnonymousObjectInBaseConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/additionalLazyResolve/anonymousObjectInBaseConstructor.kt"); + doTest(fileName); + } + @TestMetadata("anonymousObjectInClassInitializer.kt") public void testAnonymousObjectInClassInitializer() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/additionalLazyResolve/anonymousObjectInClassInitializer.kt"); @@ -48,6 +54,12 @@ public class AdditionalResolveDescriptorRendererTestGenerated extends AbstractAd doTest(fileName); } + @TestMetadata("functionLiteralInBaseConstructor.kt") + public void testFunctionLiteralInBaseConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/additionalLazyResolve/functionLiteralInBaseConstructor.kt"); + doTest(fileName); + } + @TestMetadata("localClassInClassInitializer.kt") public void testLocalClassInClassInitializer() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/additionalLazyResolve/localClassInClassInitializer.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt b/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt index 3af89d5ff44..b7bec3ab30d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt @@ -123,10 +123,10 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { ModuleRootModificationUtil.addDependency(moduleWithDependency, module) - val jetRunConfiguration = createConfigurationFromMain("some.test.main") - jetRunConfiguration.setModule(moduleWithDependency) + val kotlinRunConfiguration = createConfigurationFromMain("some.test.main") + kotlinRunConfiguration.setModule(moduleWithDependency) - val javaParameters = getJavaRunParameters(jetRunConfiguration) + val javaParameters = getJavaRunParameters(kotlinRunConfiguration) Assert.assertTrue(javaParameters.classPath.rootDirs.contains(dependencyModuleSrcDir)) Assert.assertTrue(javaParameters.classPath.rootDirs.contains(moduleWithDependencySrcDir)) @@ -166,6 +166,27 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { Assert.assertEquals("afterRenameTest.Foo", runConfiguration.MAIN_CLASS_NAME) } + fun testWithModuleForJdk6() { + checkModuleInfoName(null, PluginTestCaseBase.mockJdk()) + } + + fun testWithModuleForJdk9() { + checkModuleInfoName("MAIN", PluginTestCaseBase.mockJdk9()) + } + + fun testWithModuleForJdk9WithoutModuleInfo() { + checkModuleInfoName(null, PluginTestCaseBase.mockJdk9()) + } + + private fun checkModuleInfoName(moduleName: String?, sdk: Sdk) { + val module = configureModule(moduleDirPath("module"), getTestProject().baseDir!!).module + ConfigLibraryUtil.configureKotlinRuntimeAndSdk(module, sdk) + + val javaParameters = getJavaRunParameters(createConfigurationFromMain("some.main")) + + Assert.assertEquals(moduleName, javaParameters.moduleName) + } + private fun doTest(configureRuntime: (Module, Sdk) -> Unit) { val baseDir = getTestProject().baseDir!! val createModuleResult = configureModule(moduleDirPath("module"), baseDir) @@ -191,7 +212,7 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { val dataContext = MapDataContext() dataContext.put(Location.DATA_KEY, PsiLocation(getTestProject(), declaration)) val context = ConfigurationContext.getFromContext(dataContext) - val actualClass = (context.configuration?.configuration as? JetRunConfiguration)?.runClass + val actualClass = (context.configuration?.configuration as? KotlinRunConfiguration)?.runClass if (actualClass != null) { actualClasses.add(actualClass) } @@ -205,16 +226,16 @@ class RunConfigurationTest: KotlinCodeInsightTestCase() { } } - private fun createConfigurationFromMain(mainFqn: String): JetRunConfiguration { + private fun createConfigurationFromMain(mainFqn: String): KotlinRunConfiguration { val mainFunction = KotlinTopLevelFunctionFqnNameIndex.getInstance().get(mainFqn, getTestProject(), getTestProject().allScope()).first() - return createConfigurationFromElement(mainFunction) as JetRunConfiguration + return createConfigurationFromElement(mainFunction) as KotlinRunConfiguration } - private fun createConfigurationFromObject(objectFqn: String, save: Boolean = false): JetRunConfiguration { + private fun createConfigurationFromObject(objectFqn: String, save: Boolean = false): KotlinRunConfiguration { val obj = KotlinFullClassNameIndex.getInstance().get(objectFqn, getTestProject(), getTestProject().allScope()).single() val mainFunction = obj.declarations.single { it is KtFunction && it.getName() == "main" } - return createConfigurationFromElement(mainFunction, save) as JetRunConfiguration + return createConfigurationFromElement(mainFunction, save) as KotlinRunConfiguration } private fun configureModule(moduleDir: String, outputParentDir: VirtualFile, configModule: Module = module): CreateModuleResult { diff --git a/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiModuleTest.kt b/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiModuleTest.kt index cbc3a29d36f..107423f6e24 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiModuleTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiModuleTest.kt @@ -118,15 +118,24 @@ abstract class AbstractMultiModuleTest : DaemonAnalyzerTestCase() { } } -fun Module.createFacet(platformKind: TargetPlatformKind<*>? = null, useProjectSettings: Boolean = true) { +fun Module.createFacet( + platformKind: TargetPlatformKind<*>? = null, + useProjectSettings: Boolean = true, + implementedModuleName: String? = null +) { val accessToken = WriteAction.start() try { val modelsProvider = IdeModifiableModelsProviderImpl(project) - getOrCreateFacet(modelsProvider, useProjectSettings).configuration.settings.initializeIfNeeded( - this, - modelsProvider.getModifiableRootModel(this), - platformKind - ) + with (getOrCreateFacet(modelsProvider, useProjectSettings).configuration.settings) { + initializeIfNeeded( + this@createFacet, + modelsProvider.getModifiableRootModel(this@createFacet), + platformKind + ) + if (implementedModuleName != null) { + this.implementedModuleName = implementedModuleName + } + } modelsProvider.commit() } finally { diff --git a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt index cd7b295f01e..77c3968c5d7 100644 --- a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt +++ b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt @@ -24,7 +24,6 @@ import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.StandardFileSystems import com.intellij.testFramework.LightVirtualFile import com.intellij.testFramework.UsefulTestCase -import com.intellij.util.ArrayUtil import com.intellij.util.io.URLUtil import com.intellij.util.io.ZipUtil import org.jetbrains.jps.ModuleChunk @@ -43,6 +42,7 @@ import org.jetbrains.jps.incremental.ModuleLevelBuilder import org.jetbrains.jps.incremental.messages.BuildMessage import org.jetbrains.jps.incremental.messages.CompilerMessage import org.jetbrains.jps.model.JpsModuleRootModificationUtil +import org.jetbrains.jps.model.JpsProject import org.jetbrains.jps.model.java.JavaSourceRootType import org.jetbrains.jps.model.java.JpsJavaDependencyScope import org.jetbrains.jps.model.java.JpsJavaExtensionService @@ -337,7 +337,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { val buildResult = buildAllModules() buildResult.assertSuccessful() val warnings = buildResult.getMessages(BuildMessage.Kind.WARNING) - assertEquals("Warning about invalid package prefix in module 2 is expected: $warnings", 2, warnings.size) + assertEquals("Warning about invalid package prefix in module 2 is expected: $warnings", 1, warnings.size) assertEquals("Invalid package prefix name is ignored: invalid-prefix.test", warnings.first().messageText) } @@ -510,7 +510,14 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { assertFilesExistInOutput(module, "Foo.class", "Bar.class") assertFilesNotExistInOutput(module, *EXCLUDE_FILES) - checkWhen(touch("src/foo.kt"), null, arrayOf(klass("kotlinProject", "Foo"))) + if (IncrementalCompilation.isEnabled()) { + checkWhen(touch("src/foo.kt"), null, arrayOf(klass("kotlinProject", "Foo"))) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/foo.kt"), null, allClasses) + } + checkWhen(touch("src/Excluded.kt"), null, NOTHING) checkWhen(touch("src/dir/YetAnotherExcluded.kt"), null, NOTHING) } @@ -522,8 +529,15 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { assertFilesExistInOutput(module, "Foo.class", "Bar.class") assertFilesNotExistInOutput(module, *EXCLUDE_FILES) - checkWhen(touch("src/foo.kt"), null, arrayOf(klass("kotlinProject", "Foo"))) - checkWhen(touch("src/dir/subdir/bar.kt"), null, arrayOf(klass("kotlinProject", "Bar"))) + if (IncrementalCompilation.isEnabled()) { + checkWhen(touch("src/foo.kt"), null, arrayOf(klass("kotlinProject", "Foo"))) + checkWhen(touch("src/dir/subdir/bar.kt"), null, arrayOf(klass("kotlinProject", "Bar"))) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/foo.kt"), null, allClasses) + checkWhen(touch("src/dir/subdir/bar.kt"), null, allClasses) + } checkWhen(touch("src/dir/Excluded.kt"), null, NOTHING) checkWhen(touch("src/dir/subdir/YetAnotherExcluded.kt"), null, NOTHING) @@ -536,7 +550,13 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { assertFilesExistInOutput(module, "Foo.class", "Bar.class") assertFilesNotExistInOutput(module, *EXCLUDE_FILES) - checkWhen(touch("src/foo.kt"), null, arrayOf(klass("kotlinProject", "Foo"))) + if (IncrementalCompilation.isEnabled()) { + checkWhen(touch("src/foo.kt"), null, arrayOf(klass("kotlinProject", "Foo"))) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/foo.kt"), null, allClasses) + } checkWhen(touch("src/exclude/Excluded.kt"), null, NOTHING) checkWhen(touch("src/exclude/YetAnotherExcluded.kt"), null, NOTHING) @@ -547,8 +567,15 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { fun testKotlinProjectTwoFilesInOnePackage() { doTest() - checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "_DefaultPackage")) - checkWhen(touch("src/test2.kt"), null, packageClasses("kotlinProject", "src/test2.kt", "_DefaultPackage")) + if (IncrementalCompilation.isEnabled()) { + checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "_DefaultPackage")) + checkWhen(touch("src/test2.kt"), null, packageClasses("kotlinProject", "src/test2.kt", "_DefaultPackage")) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/test1.kt"), null, allClasses) + checkWhen(touch("src/test2.kt"), null, allClasses) + } checkWhen(arrayOf(del("src/test1.kt"), del("src/test2.kt")), NOTHING, arrayOf(packagePartClass("kotlinProject", "src/test1.kt", "_DefaultPackage"), @@ -596,8 +623,15 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { result.assertSuccessful() - checkWhen(touch("src/kt2.kt"), null, packageClasses("kotlinProject", "src/kt2.kt", "kt2.Kt2Kt")) - checkWhen(touch("module2/src/kt1.kt"), null, packageClasses("module2", "module2/src/kt1.kt", "kt1.Kt1Kt")) + if (IncrementalCompilation.isEnabled()) { + checkWhen(touch("src/kt2.kt"), null, packageClasses("kotlinProject", "src/kt2.kt", "kt2.Kt2Kt")) + checkWhen(touch("module2/src/kt1.kt"), null, packageClasses("module2", "module2/src/kt1.kt", "kt1.Kt1Kt")) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("src/kt2.kt"), null, allClasses) + checkWhen(touch("module2/src/kt1.kt"), null, allClasses) + } } fun testCircularDependenciesSamePackage() { @@ -611,8 +645,16 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithA), "", "a", "getA") UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithB), "", "b", "getB", "setB") - checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage")) - checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage")) + + if (IncrementalCompilation.isEnabled()) { + checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage")) + checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage")) + } + else { + val allClasses = myProject.outputPaths() + checkWhen(touch("module1/src/a.kt"), null, allClasses) + checkWhen(touch("module2/src/b.kt"), null, allClasses) + } } fun testCircularDependenciesSamePackageWithTests() { @@ -626,8 +668,15 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithA), "", "a", "funA", "getA") UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithB), "", "b", "funB", "getB", "setB") - checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage")) - checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage")) + if (IncrementalCompilation.isEnabled()) { + checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage")) + checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage")) + } + else { + val allProductionClasses = myProject.outputPaths(tests = false) + checkWhen(touch("module1/src/a.kt"), null, allProductionClasses) + checkWhen(touch("module2/src/b.kt"), null, allProductionClasses) + } } fun testInternalFromAnotherModule() { @@ -849,7 +898,13 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { initProject(JVM_MOCK_RUNTIME) buildAllModules().assertSuccessful() - checkWhen(touch("src/utils.kt"), null, packageClasses("kotlinProject", "src/utils.kt", "_DefaultPackage")) + if (IncrementalCompilation.isEnabled()) { + checkWhen(touch("src/utils.kt"), null, packageClasses("kotlinProject", "src/utils.kt", "_DefaultPackage")) + } + else { + val allClasses = findModule("kotlinProject").outputFilesPaths() + checkWhen(touch("src/utils.kt"), null, allClasses.toTypedArray()) + } val storageRoot = BuildDataPathsImpl(myDataStorageRoot).dataStorageRoot assertTrue(File(storageRoot, "targets/java-production/kotlinProject/kotlin").exists()) @@ -1074,6 +1129,29 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { return klass(moduleName, AsmUtil.internalNameByFqNameWithoutInnerClasses(packagePartFqName)) } + private fun JpsProject.outputPaths(production: Boolean = true, tests: Boolean = true) = + modules.flatMap { it.outputFilesPaths(production = production, tests = tests) }.toTypedArray() + + private fun JpsModule.outputFilesPaths(production: Boolean = true, tests: Boolean = true): List { + val outputFiles = arrayListOf() + if (production) { + prodOut.walk().filterTo(outputFiles) { it.isFile } + } + if (tests) { + testsOut.walk().filterTo(outputFiles) { it.isFile } + } + return outputFiles.map { it.relativeTo(workDir).path } + } + + private val JpsModule.prodOut: File + get() = outDir(forTests = false) + + private val JpsModule.testsOut: File + get() = outDir(forTests = true) + + private fun JpsModule.outDir(forTests: Boolean) = + JpsJavaExtensionService.getInstance().getOutputDirectory(this, forTests)!! + protected enum class Operation { CHANGE, DELETE diff --git a/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt b/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt index c32fe8ac171..1984d68caba 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt @@ -97,7 +97,7 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner() { setupK2JsArguments(outputFile, sourceFiles, libraries, friendModules, arguments) if (arguments.sourceMap) { - arguments.sourceMapSourceRoots = sourceRoots.joinToString(File.pathSeparator) { it.path } + arguments.sourceMapBaseDirs = sourceRoots.joinToString(File.pathSeparator) { it.path } } log.debug("K2JS: arguments after setup" + ArgumentUtils.convertArgumentsToStringList(arguments)) diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt index 3c1c5e223df..73780a77220 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt @@ -238,7 +238,13 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { val isChunkRebuilding = JavaBuilderUtil.isForcedRecompilationAllJavaModules(context) || targets.any { rebuildAfterCacheVersionChanged[it] == true } - if (!hasKotlinDirtyOrRemovedFiles(dirtyFilesHolder, chunk)) { + if (hasKotlinDirtyOrRemovedFiles(dirtyFilesHolder, chunk)) { + if (!isChunkRebuilding && !IncrementalCompilation.isEnabled()) { + targets.forEach { rebuildAfterCacheVersionChanged[it] = true } + return CHUNK_REBUILD_REQUIRED + } + } + else { if (isChunkRebuilding) { targets.forEach { hasKotlin[it] = false } } diff --git a/jps-plugin/testData/general/SourcePackageLongPrefix/module2/src/module2.kt b/jps-plugin/testData/general/SourcePackageLongPrefix/module2/src/module2.kt index 9204cc97b43..54cd6bd4c70 100644 --- a/jps-plugin/testData/general/SourcePackageLongPrefix/module2/src/module2.kt +++ b/jps-plugin/testData/general/SourcePackageLongPrefix/module2/src/module2.kt @@ -3,11 +3,9 @@ package some import bad.prefix.KotlinTestInBadPrefix import good.prefix.KotlinTestInGoodPrefix import good.prefix.JavaTest; -import test.JavaRef val goodTest = KotlinTestInGoodPrefix() val badTest = KotlinTestInBadPrefix() val javaTest = JavaTest().bar() -val javaRef = JavaRef().foo(null) diff --git a/jps-plugin/testData/incremental/changeIncrementalOption/incrementalOff/build.log b/jps-plugin/testData/incremental/changeIncrementalOption/incrementalOff/build.log index 141a6fc4b0e..337c3ad1c41 100644 --- a/jps-plugin/testData/incremental/changeIncrementalOption/incrementalOff/build.log +++ b/jps-plugin/testData/incremental/changeIncrementalOption/incrementalOff/build.log @@ -9,6 +9,12 @@ Cleaning output files: out/production/module2/META-INF/module2.kotlin_module out/production/module2/foo/AKt.class End of files +Exit code: CHUNK_REBUILD_REQUIRED +------------------------------------------ +Cleaning output files: + out/production/module2/foo/BKt.class + out/production/module2/foo/CKt.class +End of files Compiling files: module2/src/a.kt module2/src/b.kt @@ -33,6 +39,12 @@ Cleaning output files: out/production/module2/META-INF/module2.kotlin_module out/production/module2/foo/AKt.class End of files +Exit code: CHUNK_REBUILD_REQUIRED +------------------------------------------ +Cleaning output files: + out/production/module2/foo/BKt.class + out/production/module2/foo/CKt.class +End of files Compiling files: module2/src/a.kt module2/src/b.kt diff --git a/jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOn/build.log b/jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOn/build.log index fb1064db698..8a34d6e3f46 100644 --- a/jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOn/build.log +++ b/jps-plugin/testData/incremental/changeIncrementalOption/incrementalOffOn/build.log @@ -9,6 +9,12 @@ Cleaning output files: out/production/module2/META-INF/module2.kotlin_module out/production/module2/foo/AKt.class End of files +Exit code: CHUNK_REBUILD_REQUIRED +------------------------------------------ +Cleaning output files: + out/production/module2/foo/BKt.class + out/production/module2/foo/CKt.class +End of files Compiling files: module2/src/a.kt module2/src/b.kt diff --git a/jps-plugin/testData/incremental/lookupTracker/js/packageDeclarations/foo1.kt b/jps-plugin/testData/incremental/lookupTracker/js/packageDeclarations/foo1.kt index 3a3a5cf9edd..ff1447f6e8a 100644 --- a/jps-plugin/testData/incremental/lookupTracker/js/packageDeclarations/foo1.kt +++ b/jps-plugin/testData/incremental/lookupTracker/js/packageDeclarations/foo1.kt @@ -3,12 +3,12 @@ package foo import bar.* /*p:baz(C)*/import baz.C -/*p:foo*/val a = /*p:foo p:bar*/A() +/*p:foo*/val a = /*p:bar p:foo*/A() /*p:foo*/var b: /*p:foo p:bar*/baz./*p:baz*/B = /*p:foo p:bar p:baz(B)*/baz./*p:baz*/B() /*p:foo*/fun function(p: /*p:foo p:bar*/B): /*p:foo p:bar*/B /*p:kotlin(Nothing)*/{ /*p:foo p:bar(A)*/a - /*p:kotlin(Nothing)*/return /*p:foo p:bar*/B() + /*p:kotlin(Nothing)*/return /*p:bar p:foo*/B() } /*p:foo*/fun /*p:foo*/MyClass.extFunc(p: /**p:foo p:bar*//*p:foo p:bar*/Array, e: /*p:foo*/MyEnum, c: /**???*//*p:baz*/C): /*p:foo*/MyInterface /*p:kotlin(Nothing)*/{ diff --git a/jps-plugin/testData/incremental/lookupTracker/jvm/expressionType/inferredType.kt b/jps-plugin/testData/incremental/lookupTracker/jvm/expressionType/inferredType.kt index a64392dfd7a..2d908d375e0 100644 --- a/jps-plugin/testData/incremental/lookupTracker/jvm/expressionType/inferredType.kt +++ b/jps-plugin/testData/incremental/lookupTracker/jvm/expressionType/inferredType.kt @@ -6,8 +6,8 @@ package foo /*p:foo*/fun getA() = /*p:foo*/A() /*p:foo*/fun getB() = /*p:foo*/B() -/*p:foo*/fun getListOfA() = /*p:foo p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm p:kotlin.collections(List) p:foo(A)*/listOf(/*p:foo*/A()) -/*p:foo*/fun getListOfB() = /*p:foo p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm p:kotlin.collections(List) p:foo(B)*/listOf(/*p:foo*/B()) +/*p:foo*/fun getListOfA() = /*p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm p:foo p:kotlin.collections(List) p:foo(A)*/listOf(/*p:foo*/A()) +/*p:foo*/fun getListOfB() = /*p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm p:foo p:kotlin.collections(List) p:foo(B)*/listOf(/*p:foo*/B()) /*p:foo*/fun useListOfA(a: /*p:foo p:kotlin.collections*/List) {} /*p:foo*/fun useListOfB(b: /*p:foo p:kotlin.collections*/List) {} diff --git a/jps-plugin/testData/incremental/lookupTracker/jvm/java/usages.kt b/jps-plugin/testData/incremental/lookupTracker/jvm/java/usages.kt index fae7e925fd0..f147e9aec48 100644 --- a/jps-plugin/testData/incremental/lookupTracker/jvm/java/usages.kt +++ b/jps-plugin/testData/incremental/lookupTracker/jvm/java/usages.kt @@ -29,9 +29,9 @@ import baz.* /*p:foo p:baz p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm p:kotlin(String)*/I./*c:foo.I*/isfield /*p:foo p:baz p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm c:foo.I(IS)*/I./*c:foo.I*/IS() - /*p:foo p:baz p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm*/E./*c:baz.E*/F - /*p:foo p:baz p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm p:kotlin(Int)*/E./*c:baz.E*/F./*c:baz.E*/field - /*p:foo p:baz p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm*/E./*c:baz.E*/S./*c:baz.E*/func() + /*p:baz p:foo p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm*/E./*c:baz.E*/F + /*p:baz p:foo p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm p:kotlin(Int)*/E./*c:baz.E*/F./*c:baz.E*/field + /*p:baz p:foo p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm*/E./*c:baz.E*/S./*c:baz.E*/func() } /*p:foo*/fun classifiers( diff --git a/jps-plugin/testData/incremental/lookupTracker/jvm/packageDeclarations/foo1.kt b/jps-plugin/testData/incremental/lookupTracker/jvm/packageDeclarations/foo1.kt index 222fadbf956..1ade1504d79 100644 --- a/jps-plugin/testData/incremental/lookupTracker/jvm/packageDeclarations/foo1.kt +++ b/jps-plugin/testData/incremental/lookupTracker/jvm/packageDeclarations/foo1.kt @@ -3,12 +3,12 @@ package foo import bar.* /*p:baz(C)*/import baz.C -/*p:foo*/val a = /*p:foo p:bar*/A() +/*p:foo*/val a = /*p:bar p:foo*/A() /*p:foo*/var b: /*p:foo p:bar p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm*/baz./*p:baz*/B = /*p:foo p:bar p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm p:baz(B)*/baz./*p:baz*/B() /*p:foo*/fun function(p: /*p:foo p:bar*/B): /*p:foo p:bar*/B /*p:kotlin(Nothing)*/{ /*p:foo p:bar(A)*/a - /*p:kotlin(Nothing)*/return /*p:foo p:bar*/B() + /*p:kotlin(Nothing)*/return /*p:bar p:foo*/B() } /*p:foo*/fun /*p:foo*/MyClass.extFunc(p: /**p:foo p:bar*//*p:foo p:kotlin*/Array, e: /*p:foo*/MyEnum, c: /**???*//*p:baz*/C): /*p:foo*/MyInterface /*p:kotlin(Nothing)*/{ diff --git a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsVisitorWithContext.java b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsVisitorWithContext.java index 878f4d155f2..95c5dc6945d 100644 --- a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsVisitorWithContext.java +++ b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/JsVisitorWithContext.java @@ -59,19 +59,26 @@ public abstract class JsVisitorWithContext { doAcceptStatementList(statements); } + public void endVisit(@NotNull JsExpression x, @NotNull JsContext ctx) { + } + public void endVisit(@NotNull JsArrayAccess x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsArrayLiteral x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsBinaryOperation x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsBlock x, @NotNull JsContext ctx) { } public void endVisit(@NotNull JsBooleanLiteral x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsBreak x, @NotNull JsContext ctx) { @@ -84,6 +91,7 @@ public abstract class JsVisitorWithContext { } public void endVisit(@NotNull JsConditional x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsContinue x, @NotNull JsContext ctx) { @@ -111,12 +119,14 @@ public abstract class JsVisitorWithContext { } public void endVisit(@NotNull JsFunction x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsIf x, @NotNull JsContext ctx) { } public void endVisit(@NotNull JsInvocation x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsLabel x, @NotNull JsContext ctx) { @@ -126,27 +136,33 @@ public abstract class JsVisitorWithContext { } public void endVisit(@NotNull JsNameRef x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsNew x, @NotNull JsContext ctx) { } public void endVisit(@NotNull JsNullLiteral x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsNumberLiteral x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsObjectLiteral x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsParameter x, @NotNull JsContext ctx) { } public void endVisit(@NotNull JsPostfixOperation x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsPrefixOperation x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsProgram x, @NotNull JsContext ctx) { @@ -156,18 +172,21 @@ public abstract class JsVisitorWithContext { } public void endVisit(@NotNull JsRegExp x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsReturn x, @NotNull JsContext ctx) { } public void endVisit(@NotNull JsStringLiteral x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsSwitch x, @NotNull JsContext ctx) { } public void endVisit(@NotNull JsThisRef x, @NotNull JsContext ctx) { + endVisit((JsExpression) x, ctx); } public void endVisit(@NotNull JsThrow x, @NotNull JsContext ctx) { diff --git a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/metadata/metadataProperties.kt b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/metadata/metadataProperties.kt index 1a54f7ff717..718196510b7 100644 --- a/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/metadata/metadataProperties.kt +++ b/js/js.ast/src/org/jetbrains/kotlin/js/backend/ast/metadata/metadataProperties.kt @@ -53,6 +53,8 @@ var JsNameRef.psiElement: PsiElement? by MetadataProperty(default = null) var JsFunction.isLocal: Boolean by MetadataProperty(default = false) +var JsFunction.forcedReturnVariable: JsName? by MetadataProperty(default = null) + var JsParameter.hasDefaultValue: Boolean by MetadataProperty(default = false) var JsInvocation.typeCheck: TypeCheck? by MetadataProperty(default = null) @@ -147,6 +149,10 @@ enum class SpecialFunction(val suggestedName: String) { WRAP_FUNCTION("wrapFunction"), TO_BOXED_CHAR("toBoxedChar"), UNBOX_CHAR("unboxChar"), + SUSPEND_CALL("suspendCall"), + COROUTINE_RESULT("coroutineResult"), + COROUTINE_CONTROLLER("coroutineController"), + COROUTINE_RECEIVER("coroutineReceiver") } enum class BoxingKind { diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsCallChecker.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsCallChecker.kt index 07525f0df05..1f8b9bdf1b6 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsCallChecker.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsCallChecker.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticFactory1 import org.jetbrains.kotlin.js.backend.ast.JsFunctionScope import org.jetbrains.kotlin.js.backend.ast.JsProgram import org.jetbrains.kotlin.js.backend.ast.JsRootScope -import org.jetbrains.kotlin.js.parser.parse +import org.jetbrains.kotlin.js.parser.parseExpressionOrStatement import org.jetbrains.kotlin.js.patterns.DescriptorPredicate import org.jetbrains.kotlin.js.patterns.PatternBuilder import org.jetbrains.kotlin.js.resolve.LEXICAL_SCOPE_FOR_JS @@ -90,7 +90,8 @@ class JsCallChecker( try { val parserScope = JsFunctionScope(JsRootScope(JsProgram()), "") - val statements = parse(code, errorReporter, parserScope, reportOn.containingFile?.name ?: "") + val statements = parseExpressionOrStatement( + code, errorReporter, parserScope, CodePosition(0, 0), reportOn.containingFile?.name ?: "") if (statements == null || statements.isEmpty()) { context.trace.report(ErrorsJs.JSCODE_NO_JAVASCRIPT_PRODUCED.on(argument)) diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsNameClashChecker.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsNameClashChecker.kt index da62c9b60f8..71c48a391d8 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsNameClashChecker.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsNameClashChecker.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.diagnostics.DiagnosticSink import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.js.naming.NameSuggestion +import org.jetbrains.kotlin.js.naming.SuggestedName import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.resolve.BindingContext @@ -40,7 +41,7 @@ class JsNameClashChecker : SimpleDeclarationChecker { private val nameSuggestion = NameSuggestion() private val scopes = mutableMapOf>() private val clashedFakeOverrides = mutableMapOf>() - private val clashedDescriptors = mutableSetOf() + private val clashedDescriptors = mutableSetOf>() override fun check( declaration: KtDeclaration, @@ -61,28 +62,29 @@ class JsNameClashChecker : SimpleDeclarationChecker { ) { if (descriptor is ConstructorDescriptor && descriptor.isPrimary) return - val suggested = nameSuggestion.suggest(descriptor)!! - if (suggested.stable && suggested.scope is ClassOrPackageFragmentDescriptor && presentsInGeneratedCode(suggested.descriptor)) { - val scope = getScope(suggested.scope) - val name = suggested.names.last() - val existing = scope[name] - if (existing != null && - existing != descriptor && - existing.isActual == descriptor.isActual && - existing.isExpect == descriptor.isExpect && - !bindingContext.isCommonDiagnosticReported(declaration) - ) { - diagnosticHolder.report(ErrorsJs.JS_NAME_CLASH.on(declaration, name, existing)) - val existingDeclaration = existing.findPsi() - if (clashedDescriptors.add(existing) && existingDeclaration is KtDeclaration && existingDeclaration != declaration) { - diagnosticHolder.report(ErrorsJs.JS_NAME_CLASH.on(existingDeclaration, name, descriptor)) + for (suggested in nameSuggestion.suggestAllPossibleNames(descriptor)) { + if (suggested.stable && suggested.scope is ClassOrPackageFragmentDescriptor && presentsInGeneratedCode(suggested.descriptor)) { + val scope = getScope(suggested.scope) + val name = suggested.names.last() + val existing = scope[name] + if (existing != null && + existing != descriptor && + existing.isActual == descriptor.isActual && + existing.isExpect == descriptor.isExpect && + !bindingContext.isCommonDiagnosticReported(declaration) + ) { + diagnosticHolder.report(ErrorsJs.JS_NAME_CLASH.on(declaration, name, existing)) + val existingDeclaration = existing.findPsi() + if (clashedDescriptors.add(existing to name) && existingDeclaration is KtDeclaration && + existingDeclaration != declaration) { + diagnosticHolder.report(ErrorsJs.JS_NAME_CLASH.on(existingDeclaration, name, descriptor)) + } } } } - val fqnDescriptor = suggested.descriptor - if (fqnDescriptor is ClassDescriptor) { - val fakeOverrides = fqnDescriptor.defaultType.memberScope.getContributedDescriptors().asSequence() + if (descriptor is ClassDescriptor) { + val fakeOverrides = descriptor.unsubstitutedMemberScope.getContributedDescriptors().asSequence() .mapNotNull { it as? CallableMemberDescriptor } .filter { it.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE } for (override in fakeOverrides) { @@ -105,6 +107,25 @@ class JsNameClashChecker : SimpleDeclarationChecker { } } + private fun NameSuggestion.suggestAllPossibleNames(descriptor: DeclarationDescriptor): Collection = + if (descriptor is CallableMemberDescriptor) { + val primary = suggest(descriptor) + if (primary != null) { + val overriddenNames = descriptor.overriddenDescriptors.flatMap { + suggestAllPossibleNames(it).map { overridden -> + SuggestedName(overridden.names, overridden.stable, primary.descriptor, primary.scope) + } + } + (overriddenNames + primary).distinctBy { it.names } + } + else { + emptyList() + } + } + else { + listOfNotNull(suggest(descriptor)) + } + private fun BindingContext.isCommonDiagnosticReported(declaration: KtDeclaration): Boolean { return diagnostics.forElement(declaration).any { it.factory in COMMON_DIAGNOSTICS } } @@ -149,10 +170,11 @@ class JsNameClashChecker : SimpleDeclarationChecker { } } - val fqn = nameSuggestion.suggest(descriptor) ?: return - if (fqn.stable && presentsInGeneratedCode(fqn.descriptor)) { - target[fqn.names.last()] = fqn.descriptor - (fqn.descriptor as? CallableMemberDescriptor)?.let { checkOverrideClashes(it, target) } + for (fqn in nameSuggestion.suggestAllPossibleNames(descriptor)) { + if (fqn.stable && presentsInGeneratedCode(fqn.descriptor)) { + target[fqn.names.last()] = fqn.descriptor + (fqn.descriptor as? CallableMemberDescriptor)?.let { checkOverrideClashes(it, target) } + } } } diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/coroutine/CoroutineFunctionTransformer.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/coroutine/CoroutineFunctionTransformer.kt index 0ce69007a02..6ece38d8da0 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/coroutine/CoroutineFunctionTransformer.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/coroutine/CoroutineFunctionTransformer.kt @@ -43,11 +43,14 @@ class CoroutineFunctionTransformer(private val function: JsFunction, name: Strin val globalCatchBlockIndex = coroutineBlocks.indexOf(context.globalCatchBlock) coroutineBlocks.forEach { it.jsBlock.collectAdditionalLocalVariables() } - coroutineBlocks.forEach { it.jsBlock.replaceLocalVariables(context, localVariables) } + + val survivingLocalVars = coroutineBlocks.collectVariablesSurvivingBetweenBlocks( + localVariables, function.parameters.map { it.name }.toSet()) + coroutineBlocks.forEach { it.jsBlock.replaceLocalVariables(context, survivingLocalVars) } val additionalStatements = mutableListOf() generateDoResume(coroutineBlocks, context, additionalStatements) - generateContinuationConstructor(context, additionalStatements, globalCatchBlockIndex) + generateContinuationConstructor(context, additionalStatements, globalCatchBlockIndex, survivingLocalVars) generateCoroutineInstantiation(context) @@ -57,7 +60,8 @@ class CoroutineFunctionTransformer(private val function: JsFunction, name: Strin private fun generateContinuationConstructor( context: CoroutineTransformationContext, statements: MutableList, - globalCatchBlockIndex: Int + globalCatchBlockIndex: Int, + survivingLocalVars: Set ) { val psiElement = context.metadata.psiElement @@ -93,7 +97,7 @@ class CoroutineFunctionTransformer(private val function: JsFunction, name: Strin if (context.metadata.hasReceiver) { assignToField(context.receiverFieldName, context.receiverFieldName.makeRef(), psiElement) } - for (localVariable in localVariables) { + for (localVariable in survivingLocalVars) { val value = if (localVariable !in parameterNames) Namer.getUndefinedExpression() else localVariable.makeRef() assignToField(context.getFieldName(localVariable), value, psiElement) } diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/coroutine/CoroutinePasses.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/coroutine/CoroutinePasses.kt index 3b309b9396a..8fbba77946e 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/coroutine/CoroutinePasses.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/coroutine/CoroutinePasses.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.js.backend.ast.metadata.* import org.jetbrains.kotlin.js.inline.util.collectFreeVariables import org.jetbrains.kotlin.js.inline.util.replaceNames import org.jetbrains.kotlin.js.translate.utils.JsAstUtils +import org.jetbrains.kotlin.js.translate.utils.splitToRanges fun JsNode.collectNodesToSplit(breakContinueTargets: Map): Set { val root = this @@ -239,6 +240,79 @@ fun JsBlock.replaceSpecialReferences(context: CoroutineTransformationContext) { visitor.accept(this) } +fun List.collectVariablesSurvivingBetweenBlocks(localVariables: Set, parameters: Set): Set { + val varDefinedIn = localVariables.associate { it to mutableSetOf() } + val varDeclaredIn = localVariables.associate { it to mutableSetOf() } + val varUsedIn = localVariables.associate { it to mutableSetOf() } + + for ((blockIndex, block) in withIndex()) { + for (statement in block.statements) { + statement.accept(object : RecursiveJsVisitor() { + override fun visitNameRef(nameRef: JsNameRef) { + super.visitNameRef(nameRef) + varUsedIn[nameRef.name]?.add(blockIndex) + } + + override fun visit(x: JsVars.JsVar) { + varDeclaredIn[x.name]?.add(blockIndex) + if (x.initExpression != null) { + varDefinedIn[x.name]?.add(blockIndex) + } + super.visit(x) + + } + + override fun visitBinaryExpression(x: JsBinaryOperation) { + val lhs = x.arg1 + if (x.operator.isAssignment && lhs is JsNameRef) { + varDefinedIn[lhs.name]?.add(blockIndex)?.let { + accept(x.arg2) + return + } + } + super.visitBinaryExpression(x) + } + + override fun visitFunction(x: JsFunction) { + x.name?.let { + varDefinedIn[it]?.add(blockIndex) + } + } + + override fun visitLabel(x: JsLabel) { + accept(x.statement) + } + + override fun visitBreak(x: JsBreak) {} + + override fun visitContinue(x: JsContinue) {} + }) + } + } + + fun JsName.isLocalInBlock(): Boolean { + val def = varDefinedIn[this]!! + val use = varUsedIn[this]!! + val decl = varDeclaredIn[this]!! + if (def.size == 1 && use.size == 1) { + val singleDef = def.single() + val singleUse = use.single() + return singleDef == singleUse && decl.isNotEmpty() + } + return use.isEmpty() + } + + return localVariables.filterNot { localVar -> + if (localVar in parameters) { + varUsedIn[localVar]!!.isEmpty() && varDefinedIn[localVar]!!.isEmpty() && varDeclaredIn[localVar]!!.isEmpty() + } + else { + localVar.isLocalInBlock() + } + }.toSet() + +} + fun JsBlock.replaceLocalVariables(context: CoroutineTransformationContext, localVariables: Set) { replaceSpecialReferences(context) @@ -269,22 +343,36 @@ fun JsBlock.replaceLocalVariables(context: CoroutineTransformationContext, local } override fun endVisit(x: JsVars, ctx: JsContext) { - val assignments = x.vars.mapNotNull { - val fieldName = context.getFieldName(it.name) - val initExpression = it.initExpression - if (initExpression != null) { - JsAstUtils.assignment(JsNameRef(fieldName, JsThisRef()), it.initExpression) + if (x.vars.none { it.name in localVariables }) return + + val statements = mutableListOf() + for ((range, shouldReplace) in x.vars.splitToRanges { it.name in localVariables }) { + if (shouldReplace) { + val assignments = x.vars.mapNotNull { + val fieldName = context.getFieldName(it.name) + val initExpression = it.initExpression + if (initExpression != null) { + JsAstUtils.assignment(JsNameRef(fieldName, JsThisRef()), it.initExpression) + } + else { + null + } + } + if (assignments.isNotEmpty()) { + statements += JsExpressionStatement(JsAstUtils.newSequence(assignments)) + } } else { - null + statements += JsVars(*range.toTypedArray()) } } - if (assignments.isNotEmpty()) { - ctx.replaceMe(JsExpressionStatement(JsAstUtils.newSequence(assignments))) + if (statements.size == 1) { + ctx.replaceMe(statements[0]) } else { ctx.removeMe() + ctx.addPrevious(statements) } } } diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt index 8603df06d2e..aa1a6f34813 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.js.parser.parseFunction import org.jetbrains.kotlin.js.parser.sourcemaps.* import org.jetbrains.kotlin.js.translate.context.Namer import org.jetbrains.kotlin.js.translate.expression.InlineMetadata +import org.jetbrains.kotlin.js.translate.utils.JsAstUtils import org.jetbrains.kotlin.js.translate.utils.JsDescriptorUtils.getModuleName import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension import org.jetbrains.kotlin.resolve.inline.InlineStrategy @@ -48,7 +49,10 @@ private val JS_IDENTIFIER_PART = "$JS_IDENTIFIER_START\\p{Pc}\\p{Mc}\\p{Mn}\\d" private val JS_IDENTIFIER="[$JS_IDENTIFIER_START][$JS_IDENTIFIER_PART]*" private val DEFINE_MODULE_PATTERN = ("($JS_IDENTIFIER)\\.defineModule\\(\\s*(['\"])([^'\"]+)\\2\\s*,\\s*(\\w+)\\s*\\)").toRegex().toPattern() private val DEFINE_MODULE_FIND_PATTERN = ".defineModule(" -private val WRAP_FUNCTION_PATTERN = Regex("var\\s+($JS_IDENTIFIER)\\s*=\\s*($JS_IDENTIFIER)\\.wrapFunction\\s*;").toPattern() + +private val specialFunctions = enumValues().joinToString("|") { it.suggestedName } +private val specialFunctionsByName = enumValues().associateBy { it.suggestedName } +private val SPECIAL_FUNCTION_PATTERN = Regex("var\\s+($JS_IDENTIFIER)\\s*=\\s*($JS_IDENTIFIER)\\.($specialFunctions)\\s*;").toPattern() class FunctionReader( private val reporter: JsConfig.Reporter, @@ -71,13 +75,15 @@ class FunctionReader( val fileContent: String, val moduleVariable: String, val kotlinVariable: String, - val wrapFunctionVariable: String?, + val specialFunctions: Map, offsetToSourceMappingProvider: () -> OffsetToSourceMapping, val sourceMap: SourceMap? ) { val offsetToSourceMapping by lazy(offsetToSourceMappingProvider) - val wrapFunctionRegex = wrapFunctionVariable?.let { Regex("\\s*$it\\s*\\(\\s*").toPattern() } + val wrapFunctionRegex = specialFunctions.entries + .singleOrNull { (_, v) -> v == SpecialFunction.WRAP_FUNCTION }?.key + ?.let { Regex("\\s*$it\\s*\\(\\s*").toPattern() } } private val moduleNameToInfo by lazy { @@ -99,8 +105,12 @@ class FunctionReader( val moduleVariable = preciseMatcher.group(4) val kotlinVariable = preciseMatcher.group(1) - val wrapFunctionVariable = WRAP_FUNCTION_PATTERN.matcher(content).let { matcher -> - if (matcher.find() && matcher.group(2) == kotlinVariable) matcher.group(1) else null + val matcher = SPECIAL_FUNCTION_PATTERN.matcher(content) + val specialFunctions = mutableMapOf() + while (matcher.find()) { + if (matcher.group(2) == kotlinVariable) { + specialFunctions[matcher.group(1)] = specialFunctionsByName[matcher.group(3)]!! + } } val sourceMap = sourceMapContent?.let { @@ -119,7 +129,7 @@ class FunctionReader( fileContent = content, moduleVariable = moduleVariable, kotlinVariable = kotlinVariable, - wrapFunctionVariable = wrapFunctionVariable, + specialFunctions = specialFunctions, offsetToSourceMappingProvider = { OffsetToSourceMapping(content) }, sourceMap = sourceMap ) @@ -243,10 +253,11 @@ class FunctionReader( replaceExternalNames(function, replacements, allDefinedNames) wrapperStatements?.forEach { replaceExternalNames(it, replacements, allDefinedNames) } function.markInlineArguments(descriptor) + markDefaultParams(function) - info.wrapFunctionVariable.let { wrapFunction -> - for (externalName in (collectReferencedNames(function) - allDefinedNames).filter { it.ident == wrapFunction }) { - externalName.specialFunction = SpecialFunction.WRAP_FUNCTION + for (externalName in (collectReferencedNames(function) - allDefinedNames)) { + info.specialFunctions[externalName.ident]?.let { + externalName.specialFunction = it } } @@ -270,6 +281,26 @@ class FunctionReader( return FunctionWithWrapper(function, wrapper) } + + private fun markDefaultParams(function: JsFunction) { + val paramsByNames = function.parameters.associate { it.name to it } + for (ifStatement in function.body.statements) { + if (ifStatement !is JsIf || ifStatement.elseStatement != null) break + val thenStatement = ifStatement.thenStatement as? JsExpressionStatement ?: break + val testExpression = ifStatement.ifExpression as? JsBinaryOperation ?: break + + if (testExpression.operator != JsBinaryOperator.REF_EQ) break + val testLhs = testExpression.arg1 as? JsNameRef ?: break + val param = paramsByNames[testLhs.name] ?: break + if (testLhs.qualifier != null) break + if ((testExpression.arg2 as? JsPrefixOperation)?.operator != JsUnaryOperator.VOID) break + + val (assignLhs) = JsAstUtils.decomposeAssignmentToVariable(thenStatement.expression) ?: break + if (assignLhs != testLhs.name) break + + param.hasDefaultValue = true + } + } } private val Char.isWhitespaceOrComma: Boolean diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/JsInliner.java b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/JsInliner.java index 1b88c5d3267..33a09cc4b60 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/JsInliner.java +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/JsInliner.java @@ -43,6 +43,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import static org.jetbrains.kotlin.js.inline.util.CollectUtilsKt.getImportTag; +import static org.jetbrains.kotlin.js.translate.declaration.InlineCoroutineUtilKt.transformSpecialFunctionsToCoroutineMetadata; import static org.jetbrains.kotlin.js.translate.utils.JsAstUtils.flattenStatement; import static org.jetbrains.kotlin.js.translate.utils.JsAstUtils.pureFqn; @@ -348,6 +349,7 @@ public class JsInliner extends JsVisitorWithContextImpl { } JsFunction function = functionWithWrapper.getFunction().deepCopy(); + function.setBody(transformSpecialFunctionsToCoroutineMetadata(function.getBody())); if (functionWithWrapper.getWrapperBody() != null) { applyWrapper(functionWithWrapper.getWrapperBody(), function, functionWithWrapper.getFunction(), inliningContext); } @@ -359,6 +361,22 @@ public class JsInliner extends JsVisitorWithContextImpl { // body of inline function can contain call to lambdas that need to be inlined JsStatement inlineableBodyWithLambdasInlined = accept(inlineableBody); assert inlineableBody == inlineableBodyWithLambdasInlined; + + // Support non-local return from secondary constructor + // Returns from secondary constructors should return `$this` object. + JsFunction currentFunction = getCurrentNamedFunction(); + if (currentFunction != null) { + JsName returnVariable = MetadataProperties.getForcedReturnVariable(currentFunction); + if (returnVariable != null) { + inlineableBody.accept(new RecursiveJsVisitor() { + @Override + public void visitReturn(@NotNull JsReturn x) { + x.setExpression(returnVariable.makeRef()); + } + }); + } + } + statementContext.addPrevious(flattenStatement(inlineableBody)); /* diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/namingUtils.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/namingUtils.kt index 96b8060ced2..0e13ec1293c 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/namingUtils.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/namingUtils.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.js.backend.ast.metadata.staticRef import org.jetbrains.kotlin.js.inline.context.NamingContext import org.jetbrains.kotlin.js.inline.util.rewriters.LabelNameRefreshingVisitor +import org.jetbrains.kotlin.js.translate.utils.JsAstUtils fun aliasArgumentsIfNeeded( context: NamingContext, @@ -30,7 +31,12 @@ fun aliasArgumentsIfNeeded( ) { require(arguments.size <= parameters.size) { "arguments.size (${arguments.size}) should be less or equal to parameters.size (${parameters.size})" } + val defaultParams = mutableListOf() for ((arg, param) in arguments.zip(parameters)) { + if (JsAstUtils.isUndefinedExpression(arg)) { + defaultParams += param + continue + } val paramName = param.name val replacement = JsScope.declareTemporaryName(paramName.ident).apply { @@ -42,7 +48,7 @@ fun aliasArgumentsIfNeeded( context.replaceName(paramName, replacement) } - val defaultParams = parameters.subList(arguments.size, parameters.size) + defaultParams += parameters.subList(arguments.size, parameters.size) for (defaultParam in defaultParams) { val paramName = defaultParam.name val freshName = JsScope.declareTemporaryName(paramName.ident) diff --git a/js/js.libraries/src/js/markerFunctions.js b/js/js.libraries/src/js/markerFunctions.js index eab19252910..e02aaafb26e 100644 --- a/js/js.libraries/src/js/markerFunctions.js +++ b/js/js.libraries/src/js/markerFunctions.js @@ -61,3 +61,16 @@ Kotlin.andPredicate = function (a, b) { Kotlin.kotlinModuleMetadata = function (abiVersion, moduleName, data) { }; + +Kotlin.suspendCall = function(value) { + return value; +}; + +Kotlin.coroutineResult = function(qualifier) { +}; + +Kotlin.coroutineController = function(qualifier) { +}; + +Kotlin.coroutineReceiver = function(qualifier) { +}; \ No newline at end of file diff --git a/js/js.parser/src/com/google/gwt/dev/js/JsAstMapper.java b/js/js.parser/src/com/google/gwt/dev/js/JsAstMapper.java index 5893b4f2dc5..b75d37f61e8 100644 --- a/js/js.parser/src/com/google/gwt/dev/js/JsAstMapper.java +++ b/js/js.parser/src/com/google/gwt/dev/js/JsAstMapper.java @@ -392,9 +392,7 @@ public class JsAstMapper { JsUnaryOperator.DELETE, to); } else { - throw createParserException( - "'delete' can only operate on property names and array elements", - from); + return new JsNullLiteral(); } } @@ -464,7 +462,7 @@ public class JsAstMapper { } } - private JsExpression mapExpression(Node exprNode) throws JsParserException { + public JsExpression mapExpression(Node exprNode) throws JsParserException { JsNode unknown = map(exprNode); if (unknown instanceof JsExpression) { diff --git a/js/js.parser/src/com/google/gwt/dev/js/rhino/MessagesBundle.java b/js/js.parser/src/com/google/gwt/dev/js/rhino/MessagesBundle.java index 7a9e976b7c2..dfe4d5f189a 100644 --- a/js/js.parser/src/com/google/gwt/dev/js/rhino/MessagesBundle.java +++ b/js/js.parser/src/com/google/gwt/dev/js/rhino/MessagesBundle.java @@ -81,5 +81,7 @@ public class MessagesBundle extends ListResourceBundle { {"msg.catch.unreachable", "any catch clauses following an unqualified catch are unreachable"}, {"msg.no.name.after.dot", "missing name after . operator"}, {"msg.jsni.expected.identifier", "Expected an identifier in JSNI reference"}, + {"msg.wrong.delete argument", "Wrong argument for ''delete'' operation. " + + "Must be either property reference or array subscript expression."}, }; } \ No newline at end of file diff --git a/js/js.parser/src/com/google/gwt/dev/js/rhino/Parser.java b/js/js.parser/src/com/google/gwt/dev/js/rhino/Parser.java index ec226b44311..466a15391b8 100644 --- a/js/js.parser/src/com/google/gwt/dev/js/rhino/Parser.java +++ b/js/js.parser/src/com/google/gwt/dev/js/rhino/Parser.java @@ -37,6 +37,8 @@ package com.google.gwt.dev.js.rhino; +import org.jetbrains.annotations.NotNull; + import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -725,7 +727,7 @@ public class Parser { return pn; } - private Node expr(TokenStream ts, boolean inForInit) throws IOException, JavaScriptException { + public Node expr(TokenStream ts, boolean inForInit) throws IOException, JavaScriptException { Node pn = assignExpr(ts, inForInit); while (ts.matchToken(TokenStream.COMMA)) { CodePosition position = ts.tokenPosition; @@ -890,8 +892,13 @@ public class Parser { case TokenStream.DEC: return nf.createUnary(tt, TokenStream.PRE, memberExpr(ts, true), position); - case TokenStream.DELPROP: - return nf.createUnary(TokenStream.DELPROP, unaryExpr(ts), position); + case TokenStream.DELPROP: { + Node argument = unaryExpr(ts); + if (!isValidDeleteArgument(argument)) { + Context.reportError("msg.wrong.delete argument", argument.getPosition(), ts.lastPosition); + } + return nf.createUnary(TokenStream.DELPROP, argument, position); + } case TokenStream.ERROR: break; @@ -922,6 +929,10 @@ public class Parser { return nf.createName("err", position); // Only reached on error. Try to continue. } + private static boolean isValidDeleteArgument(@NotNull Node node) { + return node.type == TokenStream.GETPROP || node.type == TokenStream.GETELEM; + } + private Node argumentList(TokenStream ts, Node listNode) throws IOException, JavaScriptException { boolean matched; ts.flags |= TokenStream.TSF_REGEXP; diff --git a/js/js.parser/src/org/jetbrains/kotlin/js/parser/parserUtils.kt b/js/js.parser/src/org/jetbrains/kotlin/js/parser/parserUtils.kt index 58ab8a27c22..f76615ceb10 100644 --- a/js/js.parser/src/org/jetbrains/kotlin/js/parser/parserUtils.kt +++ b/js/js.parser/src/org/jetbrains/kotlin/js/parser/parserUtils.kt @@ -30,6 +30,42 @@ fun parse(code: String, reporter: ErrorReporter, scope: JsScope, fileName: Strin } } +fun parseExpressionOrStatement( + code: String, + reporter: ErrorReporter, scope: JsScope, + startPosition: CodePosition, fileName: String +): List? { + val accumulatingReporter = AccumulatingReporter() + val exprNode = try { + parse(code, startPosition, 0, accumulatingReporter, true) { + val result = expr(it, false) + if (it.token != TokenStream.EOF) { + accumulatingReporter.hasErrors = true + } + result + } + } + catch (e: JavaScriptException) { + null + } + + return if (!accumulatingReporter.hasErrors) { + for (warning in accumulatingReporter.warnings) { + reporter.warning(warning.message, warning.startPosition, warning.endPosition) + } + val expr = exprNode?.toJsAst(scope, fileName) { + mapExpression(it) + } + expr?.let { listOf(JsExpressionStatement(it)) } + } + else { + val node = parse(code, startPosition, 0, reporter, true, Parser::parse) + node?.toJsAst(scope, fileName) { + mapStatements(it) + } + } +} + fun parseFunction(code: String, fileName: String, position: CodePosition, offset: Int, reporter: ErrorReporter, scope: JsScope): JsFunction? { val rootNode = parse(code, position, offset, reporter, insideFunction = false) { addListener(FunctionParsingObserver()) @@ -80,4 +116,20 @@ private fun StringReader(string: String, offset: Int): Reader { val reader = StringReader(string) reader.skip(offset.toLong()) return reader -} \ No newline at end of file +} + +private class AccumulatingReporter : ErrorReporter { + var hasErrors = false + val warnings = mutableListOf() + + override fun warning(message: String, startPosition: CodePosition, endPosition: CodePosition) { + warnings += Warning(message, startPosition, endPosition) + } + + override fun error(message: String, startPosition: CodePosition, endPosition: CodePosition) { + hasErrors = true + } + + class Warning(val message: String, val startPosition: CodePosition, val endPosition: CodePosition) +} + diff --git a/js/js.serializer/src/js-ast.proto b/js/js.serializer/src/js-ast.proto index 6a904c7dee3..9635474d45d 100644 --- a/js/js.serializer/src/js-ast.proto +++ b/js/js.serializer/src/js-ast.proto @@ -435,6 +435,10 @@ enum SpecialFunction { WRAP_FUNCTION = 2; TO_BOXED_CHAR = 3; UNBOX_CHAR = 4; + SUSPEND_CALL = 5; + COROUTINE_RESULT = 6; + COROUTINE_CONTROLLER = 7; + COROUTINE_RECEIVER = 8; } diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinFileMetadata.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinFileMetadata.kt new file mode 100644 index 00000000000..160860048b0 --- /dev/null +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinFileMetadata.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.serialization.js + +import org.jetbrains.kotlin.psi.KtFile + +sealed class KotlinFileMetadata + +data class KotlinPsiFileMetadata(val ktFile: KtFile) : KotlinFileMetadata() + +data class KotlinDeserializedFileMetadata( + val packageFragment: KotlinJavascriptPackageFragment, + val fileId: Int +) : KotlinFileMetadata() \ No newline at end of file diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinFileRegistry.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinFileRegistry.kt index d80cc8a4994..48a5a7ba4c5 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinFileRegistry.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinFileRegistry.kt @@ -16,13 +16,11 @@ package org.jetbrains.kotlin.serialization.js -import org.jetbrains.kotlin.psi.KtFile - class KotlinFileRegistry { - private val fileIdsImpl = mutableMapOf() + private val fileIdsImpl = mutableMapOf() - fun lookup(file: KtFile) = fileIdsImpl.getOrPut(file) { fileIdsImpl.size } + fun lookup(file: KotlinFileMetadata) = fileIdsImpl.getOrPut(file) { fileIdsImpl.size } - val fileIds: Map + val fileIds: Map get() = fileIdsImpl } diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptPackageFragment.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptPackageFragment.kt index 3257b25b2b7..e61e07c3deb 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptPackageFragment.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptPackageFragment.kt @@ -29,10 +29,7 @@ import org.jetbrains.kotlin.serialization.deserialization.AnnotationDeserializer import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration import org.jetbrains.kotlin.serialization.deserialization.DeserializedPackageFragmentImpl import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData -import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource -import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor -import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.storage.getValue @@ -44,7 +41,7 @@ class KotlinJavascriptPackageFragment( header: JsProtoBuf.Header, configuration: DeserializationConfiguration ) : DeserializedPackageFragmentImpl(fqName, storageManager, module, proto, JsContainerSource(fqName, header, configuration)) { - private val fileMap: Map by storageManager.createLazyValue { + val fileMap: Map by storageManager.createLazyValue { this.proto.getExtension(JsProtoBuf.packageFragmentFiles).fileList.withIndex().associate { (index, file) -> (if (file.hasId()) file.id else index) to FileHolder(file.annotationList) } @@ -58,17 +55,12 @@ class KotlinJavascriptPackageFragment( if (DescriptorUtils.getParentOfType(descriptor, PackageFragmentDescriptor::class.java) != this) { throw IllegalArgumentException("Provided descriptor $descriptor does not belong to this package $this") } - val fileId = when (descriptor) { - is DeserializedClassDescriptor -> descriptor.classProto.getExtension(JsProtoBuf.classContainingFileId) - is DeserializedSimpleFunctionDescriptor -> descriptor.proto.getExtension(JsProtoBuf.functionContainingFileId) - is DeserializedPropertyDescriptor -> descriptor.proto.getExtension(JsProtoBuf.propertyContainingFileId) - else -> null - } + val fileId = descriptor.extractFileId() return fileId?.let { fileMap[it] }?.annotations.orEmpty() } - private inner class FileHolder(val annotationsProto: List) { + inner class FileHolder(private val annotationsProto: List) { val annotations: List by storageManager.createLazyValue { annotationsProto.map { annotationDeserializer.deserializeAnnotation(it, nameResolver) } } diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializationUtil.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializationUtil.kt index 8fa0d7013f2..18fc957c476 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializationUtil.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializationUtil.kt @@ -29,6 +29,9 @@ import org.jetbrains.kotlin.serialization.AnnotationSerializer import org.jetbrains.kotlin.serialization.DescriptorSerializer import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.utils.JsMetadataVersion import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils @@ -130,7 +133,9 @@ object KotlinJavascriptSerializationUtil { val builder = ProtoBuf.PackageFragment.newBuilder() // TODO: ModuleDescriptor should be able to return the package only with the contents of that module, without dependencies - val skip: (DeclarationDescriptor) -> Boolean = { DescriptorUtils.getContainingModule(it) != module || (it is MemberDescriptor && it.isExpect) } + val skip: (DeclarationDescriptor) -> Boolean = { + DescriptorUtils.getContainingModule(it) != module || (it is MemberDescriptor && it.isExpect) + } val fileRegistry = KotlinFileRegistry() val serializerExtension = KotlinJavascriptSerializerExtension(fileRegistry) @@ -183,8 +188,11 @@ object KotlinJavascriptSerializationUtil { if (id != filesProto.fileCount) { fileProto.id = id } - for (annotationPsi in file.annotationEntries) { - val annotation = bindingContext[BindingContext.ANNOTATION, annotationPsi]!! + val annotations = when (file) { + is KotlinPsiFileMetadata -> file.ktFile.annotationEntries.map { bindingContext[BindingContext.ANNOTATION, it]!! } + is KotlinDeserializedFileMetadata -> file.packageFragment.fileMap[file.fileId]!!.annotations + } + for (annotation in annotations) { fileProto.addAnnotation(serializer.serializeAnnotation(annotation)) } filesProto.addFile(fileProto) @@ -282,4 +290,11 @@ object KotlinJavascriptSerializationUtil { } } -data class KotlinJavaScriptLibraryParts(val header: JsProtoBuf.Header, val body: List) \ No newline at end of file +data class KotlinJavaScriptLibraryParts(val header: JsProtoBuf.Header, val body: List) + +internal fun DeclarationDescriptor.extractFileId(): Int? = when (this) { + is DeserializedClassDescriptor -> classProto.getExtension(JsProtoBuf.classContainingFileId) + is DeserializedSimpleFunctionDescriptor -> proto.getExtension(JsProtoBuf.functionContainingFileId) + is DeserializedPropertyDescriptor -> proto.getExtension(JsProtoBuf.propertyContainingFileId) + else -> null +} \ No newline at end of file diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt index 24aef0aa4b8..452282931d9 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt @@ -64,11 +64,17 @@ class KotlinJavascriptSerializerExtension( private fun getFileId(descriptor: DeclarationDescriptor): Int? { if (!DescriptorUtils.isTopLevelDeclaration(descriptor) || descriptor !is DeclarationDescriptorWithSource) return null - val file = descriptor.source.containingFile - if (file !is PsiSourceFile) return null + val fileId = descriptor.extractFileId() + if (fileId != null) { + (descriptor.containingDeclaration as? KotlinJavascriptPackageFragment)?.let { packageFragment -> + return fileRegistry.lookup(KotlinDeserializedFileMetadata(packageFragment, fileId)) + } + } + + val file = descriptor.source.containingFile as? PsiSourceFile ?: return null val psiFile = file.psiFile - return (psiFile as? KtFile)?.let { fileRegistry.lookup(it) } + return (psiFile as? KtFile)?.let { fileRegistry.lookup(KotlinPsiFileMetadata(it)) } } } diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ast/JsAstDeserializer.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ast/JsAstDeserializer.kt index 686dbe9c8c7..06ccb635204 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ast/JsAstDeserializer.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ast/JsAstDeserializer.kt @@ -522,6 +522,10 @@ class JsAstDeserializer(program: JsProgram, private val sourceRoots: Iterable SpecialFunction.WRAP_FUNCTION JsAstProtoBuf.SpecialFunction.TO_BOXED_CHAR -> SpecialFunction.TO_BOXED_CHAR JsAstProtoBuf.SpecialFunction.UNBOX_CHAR -> SpecialFunction.UNBOX_CHAR + JsAstProtoBuf.SpecialFunction.SUSPEND_CALL -> SpecialFunction.SUSPEND_CALL + JsAstProtoBuf.SpecialFunction.COROUTINE_RESULT -> SpecialFunction.COROUTINE_RESULT + JsAstProtoBuf.SpecialFunction.COROUTINE_CONTROLLER -> SpecialFunction.COROUTINE_CONTROLLER + JsAstProtoBuf.SpecialFunction.COROUTINE_RECEIVER -> SpecialFunction.COROUTINE_RECEIVER } private fun withLocation(fileId: Int?, location: Location?, action: () -> T): T { diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ast/JsAstProtoBuf.java b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ast/JsAstProtoBuf.java index 21c70d3290c..cb5593bd162 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ast/JsAstProtoBuf.java +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ast/JsAstProtoBuf.java @@ -159,6 +159,22 @@ public final class JsAstProtoBuf { * UNBOX_CHAR = 4; */ UNBOX_CHAR(3, 4), + /** + * SUSPEND_CALL = 5; + */ + SUSPEND_CALL(4, 5), + /** + * COROUTINE_RESULT = 6; + */ + COROUTINE_RESULT(5, 6), + /** + * COROUTINE_CONTROLLER = 7; + */ + COROUTINE_CONTROLLER(6, 7), + /** + * COROUTINE_RECEIVER = 8; + */ + COROUTINE_RECEIVER(7, 8), ; /** @@ -177,6 +193,22 @@ public final class JsAstProtoBuf { * UNBOX_CHAR = 4; */ public static final int UNBOX_CHAR_VALUE = 4; + /** + * SUSPEND_CALL = 5; + */ + public static final int SUSPEND_CALL_VALUE = 5; + /** + * COROUTINE_RESULT = 6; + */ + public static final int COROUTINE_RESULT_VALUE = 6; + /** + * COROUTINE_CONTROLLER = 7; + */ + public static final int COROUTINE_CONTROLLER_VALUE = 7; + /** + * COROUTINE_RECEIVER = 8; + */ + public static final int COROUTINE_RECEIVER_VALUE = 8; public final int getNumber() { return value; } @@ -187,6 +219,10 @@ public final class JsAstProtoBuf { case 2: return WRAP_FUNCTION; case 3: return TO_BOXED_CHAR; case 4: return UNBOX_CHAR; + case 5: return SUSPEND_CALL; + case 6: return COROUTINE_RESULT; + case 7: return COROUTINE_CONTROLLER; + case 8: return COROUTINE_RECEIVER; default: return null; } } diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ast/JsAstSerializer.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ast/JsAstSerializer.kt index 46ac9253136..a6275fc2f62 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ast/JsAstSerializer.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ast/JsAstSerializer.kt @@ -558,6 +558,10 @@ class JsAstSerializer(private val pathResolver: (File) -> String) { SpecialFunction.WRAP_FUNCTION -> JsAstProtoBuf.SpecialFunction.WRAP_FUNCTION SpecialFunction.TO_BOXED_CHAR -> JsAstProtoBuf.SpecialFunction.TO_BOXED_CHAR SpecialFunction.UNBOX_CHAR -> JsAstProtoBuf.SpecialFunction.UNBOX_CHAR + SpecialFunction.SUSPEND_CALL -> JsAstProtoBuf.SpecialFunction.SUSPEND_CALL + SpecialFunction.COROUTINE_RESULT -> JsAstProtoBuf.SpecialFunction.COROUTINE_RESULT + SpecialFunction.COROUTINE_CONTROLLER -> JsAstProtoBuf.SpecialFunction.COROUTINE_CONTROLLER + SpecialFunction.COROUTINE_RECEIVER -> JsAstProtoBuf.SpecialFunction.COROUTINE_RECEIVER } private fun serialize(name: JsName): Int = nameMap.getOrPut(name) { diff --git a/js/js.tests/build.gradle.kts b/js/js.tests/build.gradle.kts index 161b003359b..41d511ac476 100644 --- a/js/js.tests/build.gradle.kts +++ b/js/js.tests/build.gradle.kts @@ -44,3 +44,8 @@ projectTest { testsJar {} +projectTest("quickTest") { + dependsOn(*testDistProjects.map { "$it:dist" }.toTypedArray()) + workingDir = rootDir + systemProperty("kotlin.js.skipMinificationTest", "true") +} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt index 6417f6da46d..7e626bcb86e 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt @@ -298,7 +298,8 @@ abstract class BasicBoxTest( val outputFile = File(outputFileName) val incrementalData = IncrementalData() - translateFiles(psiFiles.map(TranslationUnit::SourceFile), outputFile, config, outputPrefixFile, outputPostfixFile, mainCallParameters, incrementalData) + translateFiles(psiFiles.map(TranslationUnit::SourceFile), outputFile, config, outputPrefixFile, outputPostfixFile, + mainCallParameters, incrementalData) if (module.hasFilesToRecompile) { checkIncrementalCompilation(sourceDirs, module, kotlinFiles, dependencies, friends, multiModule, outputFile, @@ -334,7 +335,7 @@ abstract class BasicBoxTest( .sortedBy { it.canonicalPath } .map { sourceToTranslationUnit[it]!! } - val recompiledConfig = createConfig(sourceDirs,module, dependencies, friends, multiModule, incrementalData) + val recompiledConfig = createConfig(sourceDirs, module, dependencies, friends, multiModule, incrementalData) val recompiledOutputFile = File(outputFile.parentFile, outputFile.nameWithoutExtension + "-recompiled.js") translateFiles(translationUnits, recompiledOutputFile, recompiledConfig, outputPrefixFile, outputPostfixFile, @@ -348,6 +349,13 @@ abstract class BasicBoxTest( val recompiledSourceMap = removeRecompiledSuffix( FileUtil.loadFile(File(recompiledOutputFile.parentFile, recompiledOutputFile.name + ".map"))) TestCase.assertEquals("Source map file changed after recompilation", originalSourceMap, recompiledSourceMap) + + if (multiModule) { + val originalMetadata = FileUtil.loadFile(File(outputFile.parentFile, outputFile.nameWithoutExtension + ".meta.js")) + val recompiledMetadata = removeRecompiledSuffix( + FileUtil.loadFile(File(recompiledOutputFile.parentFile, recompiledOutputFile.nameWithoutExtension + ".meta.js"))) + TestCase.assertEquals("Metadata file changed after recompilation", originalMetadata, recompiledMetadata) + } } private fun removeRecompiledSuffix(text: String): String = text.replace("-recompiled.js", ".js") @@ -475,7 +483,8 @@ abstract class BasicBoxTest( private fun createPsiFiles(fileNames: List): List = fileNames.map(this::createPsiFile) private fun createConfig( - sourceDirs: List,module: TestModule, dependencies: List, friends: List, multiModule: Boolean, incrementalData: IncrementalData? + sourceDirs: List,module: TestModule, dependencies: List, friends: List, + multiModule: Boolean, incrementalData: IncrementalData? ): JsConfig { val configuration = environment.configuration.copy() diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/JsLineNumberTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/JsLineNumberTestGenerated.java index ced2d2bc304..56233d66562 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/JsLineNumberTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/JsLineNumberTestGenerated.java @@ -90,6 +90,12 @@ public class JsLineNumberTestGenerated extends AbstractJsLineNumberTest { doTest(fileName); } + @TestMetadata("coroutineNullAssertion.kt") + public void testCoroutineNullAssertion() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/coroutineNullAssertion.kt"); + doTest(fileName); + } + @TestMetadata("dataClass.kt") public void testDataClass() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/dataClass.kt"); @@ -210,6 +216,12 @@ public class JsLineNumberTestGenerated extends AbstractJsLineNumberTest { doTest(fileName); } + @TestMetadata("jsCode.kt") + public void testJsCode() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/jsCode.kt"); + doTest(fileName); + } + @TestMetadata("lambdaWithClosure.kt") public void testLambdaWithClosure() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/lineNumbers/lambdaWithClosure.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java index 49ad27ab878..9e92b830d3d 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java @@ -912,6 +912,27 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { } } + @TestMetadata("js/js.translator/testData/box/coroutines") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Coroutines extends AbstractBoxJsTest { + public void testAllFilesPresentInCoroutines() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/coroutines"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true); + } + + @TestMetadata("localVarOptimization.kt") + public void testLocalVarOptimization() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/coroutines/localVarOptimization.kt"); + doTest(fileName); + } + + @TestMetadata("nativeExceptions.kt") + public void testNativeExceptions() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/coroutines/nativeExceptions.kt"); + doTest(fileName); + } + } + @TestMetadata("js/js.translator/testData/box/crossModuleRef") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -3175,6 +3196,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/stringTemplates"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true); } + @TestMetadata("nonStrings.kt") + public void testNonStrings() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/expression/stringTemplates/nonStrings.kt"); + doTest(fileName); + } + @TestMetadata("objectWithToString.kt") public void testObjectWithToString() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/expression/stringTemplates/objectWithToString.kt"); @@ -3686,6 +3713,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { doTest(fileName); } + @TestMetadata("jsModule.kt") + public void testJsModule() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/jsModule.kt"); + doTest(fileName); + } + @TestMetadata("multipleExport.kt") public void testMultipleExport() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/multipleExport.kt"); @@ -5096,6 +5129,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { doTest(fileName); } + @TestMetadata("multiModuleDefaultArgsCleanup.kt") + public void testMultiModuleDefaultArgsCleanup() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inlineSizeReduction/multiModuleDefaultArgsCleanup.kt"); + doTest(fileName); + } + @TestMetadata("noDuplicateVariableDeclaration.kt") public void testNoDuplicateVariableDeclaration() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inlineSizeReduction/noDuplicateVariableDeclaration.kt"); @@ -5477,6 +5516,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { doTest(fileName); } + @TestMetadata("objectExpression.kt") + public void testObjectExpression() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/jsCode/objectExpression.kt"); + doTest(fileName); + } + @TestMetadata("objectScopes.kt") public void testObjectScopes() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/jsCode/objectScopes.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index a71dd67d870..445d959cd07 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -4905,6 +4905,15 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/constructorCall") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConstructorCall extends AbstractJsCodegenBoxTest { + public void testAllFilesPresentInConstructorCall() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/constructorCall"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); + } + } + @TestMetadata("compiler/testData/codegen/box/controlStructures") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -6415,6 +6424,24 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { doTest(fileName); } + @TestMetadata("inlineMultiModule.kt") + public void testInlineMultiModule() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModule.kt"); + doTest(fileName); + } + + @TestMetadata("inlineMultiModuleOverride.kt") + public void testInlineMultiModuleOverride() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleOverride.kt"); + doTest(fileName); + } + + @TestMetadata("inlineMultiModuleWithController.kt") + public void testInlineMultiModuleWithController() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithController.kt"); + doTest(fileName); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/multiModule/simple.kt"); @@ -7142,6 +7169,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { doTest(fileName); } + @TestMetadata("inheritedFromInterfaceViaAbstractSuperclass.kt") + public void testInheritedFromInterfaceViaAbstractSuperclass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/inheritedFromInterfaceViaAbstractSuperclass.kt"); + doTest(fileName); + } + @TestMetadata("kt6382.kt") public void testKt6382() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/kt6382.kt"); @@ -7610,6 +7643,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); } + @TestMetadata("genericSetValueViaSyntheticAccessor.kt") + public void testGenericSetValueViaSyntheticAccessor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/genericSetValueViaSyntheticAccessor.kt"); + doTest(fileName); + } + @TestMetadata("getAsExtensionFun.kt") public void testGetAsExtensionFun() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/getAsExtensionFun.kt"); @@ -13445,6 +13484,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { doTest(fileName); } + @TestMetadata("kt20387.kt") + public void testKt20387() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt20387.kt"); + doTest(fileName); + } + @TestMetadata("kt4152.kt") public void testKt4152() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); @@ -15203,6 +15248,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { doTest(fileName); } + @TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt") + public void testForInRangeLiteralWithMixedTypeBounds() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt"); + doTest(fileName); + } + @TestMetadata("forInRangeToConstWithOverflow.kt") public void testForInRangeToConstWithOverflow() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInRangeToConstWithOverflow.kt"); @@ -21833,13 +21884,7 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { @TestMetadata("withNonLocalReturn.kt") public void testWithNonLocalReturn() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/secondaryConstructors/withNonLocalReturn.kt"); - try { - doTest(fileName); - } - catch (Throwable ignore) { - return; - } - throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + doTest(fileName); } @TestMetadata("withReturn.kt") @@ -22834,6 +22879,24 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class SyntheticAccessors extends AbstractJsCodegenBoxTest { + @TestMetadata("accessorForGenericConstructor.kt") + public void testAccessorForGenericConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericConstructor.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethod.kt") + public void testAccessorForGenericMethod() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethod.kt"); + doTest(fileName); + } + + @TestMetadata("accessorForGenericMethodWithDefaults.kt") + public void testAccessorForGenericMethodWithDefaults() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForGenericMethodWithDefaults.kt"); + doTest(fileName); + } + @TestMetadata("accessorForProtected.kt") public void testAccessorForProtected() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/syntheticAccessors/accessorForProtected.kt"); @@ -23651,6 +23714,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); } + @TestMetadata("doNotCopyImmediatelyCreatedArrays.kt") + public void testDoNotCopyImmediatelyCreatedArrays() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/vararg/doNotCopyImmediatelyCreatedArrays.kt"); + doTest(fileName); + } + @TestMetadata("kt1978.kt") public void testKt1978() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/vararg/kt1978.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/DirectiveTestUtils.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/DirectiveTestUtils.java index 8213e8a0c7d..7adc4c22a16 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/DirectiveTestUtils.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/DirectiveTestUtils.java @@ -299,6 +299,27 @@ public class DirectiveTestUtils { } }; + private static final DirectiveHandler DECLARES_VARIABLE = new DirectiveHandler("DECLARES_VARIABLE") { + @Override + void processEntry(@NotNull JsNode ast, @NotNull ArgumentsHelper arguments) throws Exception { + String functionName = arguments.getNamedArgument("function"); + String varName = arguments.getNamedArgument("name"); + JsFunction function = AstSearchUtil.getFunction(ast, functionName); + boolean[] varDeclared = new boolean[1]; + function.accept(new RecursiveJsVisitor() { + @Override + public void visit(@NotNull JsVars.JsVar x) { + super.visit(x); + if (x.getName().getIdent().equals(varName)) { + varDeclared[0] = true; + } + } + }); + + assertTrue("Function " + functionName + " does not declare variable " + varName, varDeclared[0]); + } + }; + private static final List DIRECTIVE_HANDLERS = Arrays.asList( FUNCTION_CONTAINS_NO_CALLS, FUNCTION_NOT_CALLED, @@ -319,7 +340,8 @@ public class DirectiveTestUtils { NOT_REFERENCED, HAS_INLINE_METADATA, HAS_NO_INLINE_METADATA, - HAS_NO_CAPTURED_VARS + HAS_NO_CAPTURED_VARS, + DECLARES_VARIABLE ); public static void processDirectives(@NotNull JsNode ast, @NotNull String sourceCode) throws Exception { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.java index a615cca820f..7f6edf31e10 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.java @@ -128,7 +128,11 @@ public final class K2JSTranslator { ModuleDescriptor moduleDescriptor = analysisResult.getModuleDescriptor(); Diagnostics diagnostics = bindingTrace.getBindingContext().getDiagnostics(); - AstGenerationResult translationResult = Translation.generateAst(bindingTrace, units, mainCallParameters, moduleDescriptor, config); + List sourceRoots = config.getSourceMapRoots().stream().map(File::new).collect(Collectors.toList()); + SourceFilePathResolver pathResolver = new SourceFilePathResolver(sourceRoots); + + AstGenerationResult translationResult = Translation.generateAst( + bindingTrace, units, mainCallParameters, moduleDescriptor, config, pathResolver); ProgressIndicatorAndCompilationCanceledStatus.checkCanceled(); if (hasError(diagnostics)) return new TranslationResult.Fail(diagnostics); @@ -152,9 +156,6 @@ public final class K2JSTranslator { ExpandIsCallsKt.expandIsCalls(newFragments); ProgressIndicatorAndCompilationCanceledStatus.checkCanceled(); - List sourceRoots = config.getSourceMapRoots().stream().map(File::new).collect(Collectors.toList()); - SourceFilePathResolver pathResolver = new SourceFilePathResolver(sourceRoots); - JsAstSerializer serializer = new JsAstSerializer(file -> { try { return pathResolver.getPathRelativeToSourceRoots(file); diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/facade/SourceMapBuilderConsumer.java b/js/js.translator/src/org/jetbrains/kotlin/js/facade/SourceMapBuilderConsumer.java index 4f3f1a1e458..74aaee2553c 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/facade/SourceMapBuilderConsumer.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/facade/SourceMapBuilderConsumer.java @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.js.facade; -import com.intellij.openapi.editor.Document; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; @@ -26,6 +25,7 @@ import org.jetbrains.kotlin.js.backend.ast.JsLocation; import org.jetbrains.kotlin.js.backend.ast.JsLocationWithSource; import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver; import org.jetbrains.kotlin.js.sourceMap.SourceMapMappingConsumer; +import org.jetbrains.kotlin.js.translate.utils.PsiUtils; import java.io.*; import java.nio.charset.Charset; @@ -82,15 +82,10 @@ public class SourceMapBuilderConsumer implements SourceLocationConsumer { } if (sourceInfo instanceof PsiElement) { PsiElement element = (PsiElement) sourceInfo; - PsiFile psiFile = element.getContainingFile(); - int offset = element.getNode().getStartOffset(); - Document document = psiFile.getViewProvider().getDocument(); - assert document != null; - int sourceLine = document.getLineNumber(offset); - int sourceColumn = offset - document.getLineStartOffset(sourceLine); - - File file = new File(psiFile.getViewProvider().getVirtualFile().getPath()); try { + JsLocation location = PsiUtils.extractLocationFromPsi(element, pathResolver); + PsiFile psiFile = element.getContainingFile(); + File file = new File(psiFile.getViewProvider().getVirtualFile().getPath()); Supplier contentSupplier; if (provideCurrentModuleContent) { contentSupplier = () -> { @@ -105,8 +100,7 @@ public class SourceMapBuilderConsumer implements SourceLocationConsumer { else { contentSupplier = () -> null; } - mappingConsumer.addMapping(pathResolver.getPathRelativeToSourceRoots(file), null, contentSupplier, - sourceLine, sourceColumn); + mappingConsumer.addMapping(location.getFile(), null, contentSupplier, location.getStartLine(), location.getStartChar()); } catch (IOException e) { throw new RuntimeException("IO error occurred generating source maps", e); diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/Namer.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/Namer.java index 1e5ae3c551b..5db760caffe 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/Namer.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/Namer.java @@ -38,7 +38,6 @@ import org.jetbrains.kotlin.js.resolve.JsPlatform; import org.jetbrains.kotlin.js.translate.intrinsic.functions.factories.ArrayFIF; import org.jetbrains.kotlin.js.translate.utils.JsAstUtils; import org.jetbrains.kotlin.js.translate.utils.JsDescriptorUtils; -import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.name.FqNameUnsafe; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.DescriptorUtils; @@ -87,16 +86,15 @@ public final class Namer { private static final String RECEIVER_PARAMETER_NAME = "$receiver"; public static final String ANOTHER_THIS_PARAMETER_NAME = "$this"; - private static final String THROW_NPE_FUN_NAME = "throwNPE"; - private static final String THROW_CLASS_CAST_EXCEPTION_FUN_NAME = "throwCCE"; - private static final String THROW_ILLEGAL_STATE_EXCEPTION_FUN_NAME = "throwISE"; - private static final String THROW_UNINITIALIZED_PROPERTY_ACCESS_EXCEPTION = "throwUPAE"; + public static final String THROW_NPE_FUN_NAME = "throwNPE"; + public static final String THROW_CLASS_CAST_EXCEPTION_FUN_NAME = "throwCCE"; + public static final String THROW_ILLEGAL_STATE_EXCEPTION_FUN_NAME = "throwISE"; + public static final String THROW_UNINITIALIZED_PROPERTY_ACCESS_EXCEPTION = "throwUPAE"; private static final String PROTOTYPE_NAME = "prototype"; private static final String CAPTURED_VAR_FIELD = "v"; public static final JsNameRef IS_ARRAY_FUN_REF = new JsNameRef("isArray", "Array"); public static final String DEFINE_INLINE_FUNCTION = "defineInlineFunction"; - public static final String WRAP_FUNCTION = "wrapFunction"; public static final String DEFAULT_PARAMETER_IMPLEMENTOR_SUFFIX = "$default"; private static final JsNameRef JS_OBJECT = new JsNameRef("Object"); @@ -221,26 +219,6 @@ public final class Namer { return suggested.getNames().get(0); } - @NotNull - public static JsExpression throwNPEFunctionRef() { - return new JsNameRef(THROW_NPE_FUN_NAME, kotlinObject()); - } - - @NotNull - public static JsExpression throwClassCastExceptionFunRef() { - return new JsNameRef(THROW_CLASS_CAST_EXCEPTION_FUN_NAME, kotlinObject()); - } - - @NotNull - public static JsExpression throwIllegalStateExceptionFunRef() { - return new JsNameRef(THROW_ILLEGAL_STATE_EXCEPTION_FUN_NAME, kotlinObject()); - } - - @NotNull - public static JsExpression throwUninitializedPropertyAccessExceptionFunRef() { - return new JsNameRef(THROW_UNINITIALIZED_PROPERTY_ACCESS_EXCEPTION, kotlinObject()); - } - @NotNull public static JsNameRef kotlin(@NotNull JsName name) { return pureFqn(name, kotlinObject()); @@ -326,11 +304,6 @@ public final class Namer { return result; } - @NotNull - static String generatePackageName(@NotNull FqName packageFqName) { - return packageFqName.isRoot() ? getRootPackageName() : packageFqName.shortName().asString(); - } - @NotNull public static JsExpression getUndefinedExpression() { return new JsPrefixOperation(JsUnaryOperator.VOID, new JsIntLiteral(0)); @@ -350,30 +323,9 @@ public final class Namer { return pureFqn("Long", kotlinObject()); } - @NotNull - private static JsNameRef createInlineFunction() { - return pureFqn(DEFINE_INLINE_FUNCTION, kotlinObject()); - } - - @NotNull - private static JsNameRef wrapFunction() { - return pureFqn(WRAP_FUNCTION, kotlinObject()); - } - @NotNull public static JsExpression createSpecialFunction(@NotNull SpecialFunction specialFunction) { - switch (specialFunction) { - case DEFINE_INLINE_FUNCTION: - return createInlineFunction(); - case WRAP_FUNCTION: - return wrapFunction(); - case TO_BOXED_CHAR: - return pureFqn("toBoxedChar", kotlinObject()); - case UNBOX_CHAR: - return pureFqn("unboxChar", kotlinObject()); - default: - throw new IllegalArgumentException("Unknown function: " + specialFunction); - } + return pureFqn(specialFunction.getSuggestedName(), kotlinObject()); } @NotNull diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/StaticContext.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/StaticContext.java index a1f7b629ae1..1071efb092c 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/StaticContext.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/StaticContext.java @@ -18,9 +18,7 @@ package org.jetbrains.kotlin.js.translate.context; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.intellij.openapi.util.Factory; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.hash.LinkedHashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -36,6 +34,7 @@ import org.jetbrains.kotlin.js.config.JsConfig; import org.jetbrains.kotlin.js.naming.NameSuggestion; import org.jetbrains.kotlin.js.naming.NameSuggestionKt; import org.jetbrains.kotlin.js.naming.SuggestedName; +import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver; import org.jetbrains.kotlin.js.translate.context.generator.Generator; import org.jetbrains.kotlin.js.translate.context.generator.Rule; import org.jetbrains.kotlin.js.translate.declaration.ClassModelGenerator; @@ -85,8 +84,6 @@ public final class StaticContext { @NotNull private final Generator innerNames = new InnerNameGenerator(); @NotNull - private final Map packageNames = Maps.newHashMap(); - @NotNull private final Generator scopes = new ScopeGenerator(); @NotNull private final Generator objectInstanceNames = new ObjectInstanceNameGenerator(); @@ -123,9 +120,6 @@ public final class StaticContext { @NotNull private final Map importedModules = new LinkedHashMap<>(); - @NotNull - private final JsScope rootPackageScope; - @NotNull private final DeclarationExporter exporter = new DeclarationExporter(this); @@ -142,10 +136,16 @@ public final class StaticContext { private final Map specialFunctions = new EnumMap<>(SpecialFunction.class); + private final Map intrinsicNames = new HashMap<>(); + + @NotNull + private final SourceFilePathResolver sourceFilePathResolver; + public StaticContext( @NotNull BindingTrace bindingTrace, @NotNull JsConfig config, - @NotNull ModuleDescriptor moduleDescriptor + @NotNull ModuleDescriptor moduleDescriptor, + @NotNull SourceFilePathResolver sourceFilePathResolver ) { program = new JsProgram(); JsFunction rootFunction = JsAstUtils.createFunctionWithEmptyBody(program.getScope()); @@ -153,16 +153,16 @@ public final class StaticContext { this.bindingTrace = bindingTrace; this.namer = Namer.newInstance(program.getRootScope()); - this.intrinsics = new Intrinsics(this); + this.intrinsics = new Intrinsics(); this.rootScope = fragment.getScope(); this.config = config; this.currentModule = moduleDescriptor; - rootPackageScope = new JsObjectScope(rootScope, ""); JsName kotlinName = rootScope.declareName(Namer.KOTLIN_NAME); createImportedModule(new JsImportedModuleKey(Namer.KOTLIN_LOWER_NAME, null), Namer.KOTLIN_LOWER_NAME, kotlinName, null); classModelGenerator = new ClassModelGenerator(TranslationContext.rootContext(this)); + this.sourceFilePathResolver = sourceFilePathResolver; } @NotNull @@ -195,6 +195,11 @@ public final class StaticContext { return namer; } + @NotNull + public SourceFilePathResolver getSourceFilePathResolver() { + return sourceFilePathResolver; + } + @NotNull public JsScope getScopeForDescriptor(@NotNull DeclarationDescriptor descriptor) { if (descriptor instanceof ModuleDescriptor) { @@ -329,12 +334,6 @@ public final class StaticContext { return expression; } - @NotNull - public JsNameRef getQualifiedReference(@NotNull FqName packageFqName) { - JsName packageName = getNameForPackage(packageFqName); - return pureFqn(packageName, packageFqName.isRoot() ? null : getQualifierForParentPackage(packageFqName.parent())); - } - @NotNull public JsName getNameForDescriptor(@NotNull DeclarationDescriptor descriptor) { if (descriptor instanceof ClassDescriptor && KotlinBuiltIns.isAny((ClassDescriptor) descriptor)) { @@ -438,47 +437,13 @@ public final class StaticContext { return names; } - @NotNull - private JsName getNameForPackage(@NotNull FqName packageFqName) { - return ContainerUtil.getOrCreate(packageNames, packageFqName, (Factory) () -> { - String name = Namer.generatePackageName(packageFqName); - return rootPackageScope.declareName(name); - }); - } - - @NotNull - private JsNameRef getQualifierForParentPackage(@NotNull FqName packageFqName) { - JsNameRef result = null; - JsNameRef qualifier = null; - - FqName fqName = packageFqName; - - while (true) { - JsNameRef ref = pureFqn(getNameForPackage(fqName), null); - - if (qualifier == null) { - result = ref; - } - else { - qualifier.setQualifier(ref); - } - - qualifier = ref; - - if (fqName.isRoot()) break; - fqName = fqName.parent(); - } - - return result; - } - @NotNull public JsConfig getConfig() { return config; } @NotNull - public JsName importDeclaration(@NotNull String suggestedName, @NotNull String tag, @NotNull JsExpression declaration) { + private JsName importDeclaration(@NotNull String suggestedName, @NotNull String tag, @NotNull JsExpression declaration) { JsName result = importDeclarationImpl(suggestedName, tag, declaration); fragment.getNameBindings().add(new JsNameBinding(tag, result)); return result; @@ -871,4 +836,13 @@ public final class StaticContext { return name; }); } + + + @NotNull + public JsExpression getReferenceToIntrinsic(@NotNull String name) { + JsName resultName = intrinsicNames.computeIfAbsent(name, k -> + importDeclaration(NameSuggestion.sanitizeName(name), "intrinsic:" + name, TranslationUtils.getIntrinsicFqn(name))); + + return pureFqn(resultName, null); + } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/TranslationContext.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/TranslationContext.java index e3e1a583fbf..791e6d7a7eb 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/TranslationContext.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/TranslationContext.java @@ -28,7 +28,9 @@ import org.jetbrains.kotlin.js.backend.ast.*; import org.jetbrains.kotlin.js.backend.ast.metadata.MetadataProperties; import org.jetbrains.kotlin.js.backend.ast.metadata.SpecialFunction; import org.jetbrains.kotlin.js.config.JsConfig; +import org.jetbrains.kotlin.js.naming.NameSuggestion; import org.jetbrains.kotlin.js.naming.SuggestedName; +import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver; import org.jetbrains.kotlin.js.translate.declaration.ClassModelGenerator; import org.jetbrains.kotlin.js.translate.intrinsic.Intrinsics; import org.jetbrains.kotlin.js.translate.reference.CallExpressionTranslator; @@ -317,6 +319,27 @@ public class TranslationContext { return name; } + @NotNull + public JsExpression getReferenceToIntrinsic(@NotNull String intrinsicName) { + JsExpression result; + if (inlineFunctionContext == null || !isPublicInlineFunction()) { + result = staticContext.getReferenceToIntrinsic(intrinsicName); + } + else { + String tag = "intrinsic:" + intrinsicName; + result = pureFqn(inlineFunctionContext.getImports().computeIfAbsent(tag, t -> { + JsExpression imported = TranslationUtils.getIntrinsicFqn(intrinsicName); + + JsName name = JsScope.declareTemporaryName(NameSuggestion.sanitizeName(intrinsicName)); + MetadataProperties.setImported(name, true); + inlineFunctionContext.getImportBlock().getStatements().add(JsAstUtils.newVar(name, imported)); + return name; + }), null); + } + + return result; + } + @NotNull public JsName getNameForObjectInstance(@NotNull ClassDescriptor descriptor) { return staticContext.getNameForObjectInstance(descriptor); @@ -874,4 +897,9 @@ public class TranslationContext { }); } } + + @NotNull + public SourceFilePathResolver getSourceFilePathResolver() { + return staticContext.getSourceFilePathResolver(); + } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/AbstractDeclarationVisitor.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/AbstractDeclarationVisitor.kt index 2b8ec1f5e3b..5c9a778fd8d 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/AbstractDeclarationVisitor.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/AbstractDeclarationVisitor.kt @@ -21,15 +21,17 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.isOverridable import org.jetbrains.kotlin.js.backend.ast.JsExpression +import org.jetbrains.kotlin.js.backend.ast.JsFunction import org.jetbrains.kotlin.js.backend.ast.JsName +import org.jetbrains.kotlin.js.backend.ast.metadata.coroutineMetadata +import org.jetbrains.kotlin.js.descriptorUtils.shouldBeExported import org.jetbrains.kotlin.js.translate.context.TranslationContext -import org.jetbrains.kotlin.js.translate.expression.translateAndAliasParameters -import org.jetbrains.kotlin.js.translate.expression.translateFunction -import org.jetbrains.kotlin.js.translate.expression.wrapWithInlineMetadata +import org.jetbrains.kotlin.js.translate.expression.* import org.jetbrains.kotlin.js.translate.general.TranslatorVisitor import org.jetbrains.kotlin.js.translate.utils.* import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.descriptorUtil.isExtensionProperty +import org.jetbrains.kotlin.resolve.source.getPsi abstract class AbstractDeclarationVisitor : TranslatorVisitor() { override fun emptyResult(context: TranslationContext) { } @@ -52,7 +54,7 @@ abstract class AbstractDeclarationVisitor : TranslatorVisitor() { val defaultTranslator = DefaultPropertyTranslator(descriptor, context, getBackingFieldReference(descriptor)) val getter = descriptor.getter!! val getterExpr = if (expression.hasCustomGetter()) { - translateFunction(getter, expression.getter!!, propertyContext) + translateFunction(getter, expression.getter!!, propertyContext).first } else { val function = context.getFunctionObject(getter) @@ -64,7 +66,7 @@ abstract class AbstractDeclarationVisitor : TranslatorVisitor() { val setterExpr = if (descriptor.isVar) { val setter = descriptor.setter!! if (expression.hasCustomSetter()) { - translateFunction(setter, expression.setter!!, propertyContext) + translateFunction(setter, expression.setter!!, propertyContext).first } else { val function = context.getFunctionObject(setter) @@ -88,8 +90,23 @@ abstract class AbstractDeclarationVisitor : TranslatorVisitor() { override fun visitNamedFunction(expression: KtNamedFunction, context: TranslationContext) { val descriptor = BindingUtils.getFunctionDescriptor(context.bindingContext(), expression) - val jsFunction = if (descriptor.modality != Modality.ABSTRACT) translateFunction(descriptor, expression, context) else null - addFunction(descriptor, jsFunction, expression) + val functionAndContext = if (descriptor.modality != Modality.ABSTRACT) { + translateFunction(descriptor, expression, context) + } + else { + null + } + addFunction(descriptor, functionAndContext?.first, expression) + + if (descriptor.isSuspend && descriptor.isInline && descriptor.shouldBeExported(context.config) && functionAndContext != null) { + val innerContext = functionAndContext.second + val inlineFunction = transformCoroutineMetadataToSpecialFunctions(context, functionAndContext.first.deepCopy() as JsFunction) + inlineFunction.name = null + inlineFunction.coroutineMetadata = null + val metadata = InlineMetadata.compose(inlineFunction, descriptor, innerContext) + val functionWithMetadata = metadata.functionWithMetadata(context, descriptor.source.getPsi()) + context.addDeclarationStatement(functionWithMetadata.makeStmt()) + } } override fun visitTypeAlias(typeAlias: KtTypeAlias, data: TranslationContext?) {} @@ -98,7 +115,7 @@ abstract class AbstractDeclarationVisitor : TranslatorVisitor() { descriptor: FunctionDescriptor, expression: KtDeclarationWithBody, context: TranslationContext - ): JsExpression { + ): Pair { val function = context.getFunctionObject(descriptor) function.source = expression.finalElement val innerContext = context.newDeclaration(descriptor).translateAndAliasParameters(descriptor, function.parameters) @@ -113,7 +130,14 @@ abstract class AbstractDeclarationVisitor : TranslatorVisitor() { function.body.statements += FunctionBodyTranslator.setDefaultValueForArguments(descriptor, innerContext) } innerContext.translateFunction(expression, function) - return innerContext.wrapWithInlineMetadata(context, function, descriptor) + val result = if (descriptor.isSuspend && descriptor.shouldBeExported(context.config)) { + function + } + else { + innerContext.wrapWithInlineMetadata(context, function, descriptor) + } + + return Pair(result, innerContext) } // used from kotlinx.serialization diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassModelGenerator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassModelGenerator.kt index 83b68ab0bc7..241ed123c7b 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassModelGenerator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassModelGenerator.kt @@ -54,7 +54,7 @@ class ClassModelGenerator(val context: TranslationContext) { // Traverse fake non-abstract member. Current class does not provide their implementation, // it can be inherited from interface. - for (member in members.filter { !it.kind.isReal && it.modality != Modality.ABSTRACT }) { + for (member in members.filter { !it.kind.isReal }) { if (member is FunctionDescriptor) { tryCopyWhenImplementingInterfaceWithDefaultArgs(member, model) } @@ -63,7 +63,7 @@ class ClassModelGenerator(val context: TranslationContext) { // Copy *implementation* functions (i.e. those ones which end with `$default` suffix) // of Kotlin functions with optional parameters. - if (member is FunctionDescriptor && !hasImplementationInPrototype(member)) { + if (member is FunctionDescriptor && !hasImplementationInPrototype(member) && member.modality != Modality.ABSTRACT) { copyMemberWithOptionalArgs(descriptor, member, model, Namer.DEFAULT_PARAMETER_IMPLEMENTOR_SUFFIX) } } @@ -155,7 +155,10 @@ class ClassModelGenerator(val context: TranslationContext) { // When none found, we have nothing to copy, ignore. // When multiple found, our current class should provide implementation, ignore. val memberToCopy = member.findNonRepeatingOverriddenDescriptors({ overriddenDescriptors }, { original }) - .singleOrNull { it.modality != Modality.ABSTRACT } ?: return null + .singleOrNull { + it.modality != Modality.ABSTRACT || + (it is FunctionDescriptor && it.hasOwnParametersWithDefaultValue()) + } ?: return null // If found member is not from interface, we don't need to copy it, it's already in prototype if ((memberToCopy.containingDeclaration as ClassDescriptor).kind != ClassKind.INTERFACE) return null diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt index 458f664f813..7a065d1156f 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.js.backend.ast.* +import org.jetbrains.kotlin.js.backend.ast.metadata.forcedReturnVariable import org.jetbrains.kotlin.js.descriptorUtils.hasPrimaryConstructor import org.jetbrains.kotlin.js.translate.callTranslator.CallTranslator import org.jetbrains.kotlin.js.translate.context.* @@ -208,13 +209,14 @@ class ClassTranslator private constructor( private fun createMetadataRef() = JsNameRef(Namer.METADATA, context().getInnerReference(descriptor)) private fun addMetadataType() { - val kotlinType = JsNameRef(Namer.CLASS_KIND_ENUM, Namer.KOTLIN_NAME) - val typeRef = when { - DescriptorUtils.isInterface(descriptor) -> JsNameRef(Namer.CLASS_KIND_INTERFACE, kotlinType) - DescriptorUtils.isObject(descriptor) -> JsNameRef(Namer.CLASS_KIND_OBJECT, kotlinType) - else -> JsNameRef(Namer.CLASS_KIND_CLASS, kotlinType) - } + val kindBuilder = StringBuilder(Namer.CLASS_KIND_ENUM + ".") + kindBuilder.append(when { + DescriptorUtils.isInterface(descriptor) -> Namer.CLASS_KIND_INTERFACE + DescriptorUtils.isObject(descriptor) -> Namer.CLASS_KIND_OBJECT + else -> Namer.CLASS_KIND_CLASS + }) + val typeRef = context().getReferenceToIntrinsic(kindBuilder.toString()) metadataLiteral.propertyInitializers += JsPropertyInitializer(JsNameRef(Namer.METADATA_CLASS_KIND), typeRef) val simpleName = descriptor.name @@ -280,6 +282,7 @@ class ClassTranslator private constructor( } constructorInitializer.parameters += JsParameter(thisName) + constructorInitializer.forcedReturnVariable = thisName // Generate super/this call to insert to beginning of the function val resolvedCall = BindingContextUtils.getDelegationConstructorCall(context.bindingContext(), constructorDescriptor) diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/EnumTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/EnumTranslator.kt index 43784f00225..c547f9bb68b 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/EnumTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/EnumTranslator.kt @@ -65,7 +65,8 @@ class EnumTranslator( val message = JsBinaryOperation(JsBinaryOperator.ADD, JsStringLiteral("No enum constant ${descriptor.fqNameSafe}."), nameParam.makeRef()) - val throwStatement = JsExpressionStatement(JsInvocation(Namer.throwIllegalStateExceptionFunRef(), message).source(psi)) + val throwFunction = context().getReferenceToIntrinsic(Namer.THROW_ILLEGAL_STATE_EXCEPTION_FUN_NAME) + val throwStatement = JsExpressionStatement(JsInvocation(throwFunction, message).source(psi)) if (clauses.isNotEmpty()) { val defaultCase = JsDefault().apply { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/PropertyTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/PropertyTranslator.kt index 2ffe76ee9c7..b2cfb84a5c9 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/PropertyTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/PropertyTranslator.kt @@ -29,7 +29,6 @@ import org.jetbrains.kotlin.js.translate.expression.translateFunction import org.jetbrains.kotlin.js.translate.general.AbstractTranslator import org.jetbrains.kotlin.js.translate.general.Translation import org.jetbrains.kotlin.js.translate.utils.BindingUtils -import org.jetbrains.kotlin.js.translate.utils.JsAstUtils.pureFqn import org.jetbrains.kotlin.js.translate.utils.JsDescriptorUtils import org.jetbrains.kotlin.js.translate.utils.TranslationUtils import org.jetbrains.kotlin.js.translate.utils.TranslationUtils.* @@ -95,8 +94,9 @@ class DefaultPropertyTranslator( assert(descriptor is PropertyDescriptor) { "Property descriptor expected: $descriptor" } val result = backingFieldReference(context(), descriptor as PropertyDescriptor) if (getterDescriptor is PropertyAccessorDescriptor && getterDescriptor.correspondingProperty.isLateInit) { + val throwFunction = context().getReferenceToIntrinsic(Namer.THROW_UNINITIALIZED_PROPERTY_ACCESS_EXCEPTION) function.body.statements += JsIf(JsBinaryOperation(JsBinaryOperator.EQ, result, JsNullLiteral()), - JsReturn(JsInvocation(Namer.throwUninitializedPropertyAccessExceptionFunRef(), + JsReturn(JsInvocation(throwFunction, JsStringLiteral(getterDescriptor.correspondingProperty.name.asString())))) } function.body.statements += JsReturn(result).apply { source = descriptor.source.getPsi() } @@ -195,7 +195,7 @@ fun TranslationContext.contextWithPropertyMetadataCreationIntrinsified( (delegatedCall.valueArgumentsByIndex!![1] as ExpressionValueArgument).valueArgument!!.getArgumentExpression() return innerContextWithAliasesForExpressions(mapOf( hostExpression to host, - fakeArgumentExpression to JsNew(pureFqn("PropertyMetadata", Namer.kotlinObject()), listOf(propertyNameLiteral)) + fakeArgumentExpression to JsNew(getReferenceToIntrinsic("PropertyMetadata"), listOf(propertyNameLiteral)) )) } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/inlineCoroutineUtil.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/inlineCoroutineUtil.kt new file mode 100644 index 00000000000..7c14f3749ff --- /dev/null +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/inlineCoroutineUtil.kt @@ -0,0 +1,101 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.js.translate.declaration + +import org.jetbrains.kotlin.js.backend.ast.* +import org.jetbrains.kotlin.js.backend.ast.metadata.* +import org.jetbrains.kotlin.js.translate.context.TranslationContext +import org.jetbrains.kotlin.js.translate.utils.TranslationUtils +import org.jetbrains.kotlin.js.translate.utils.name + +fun transformCoroutineMetadataToSpecialFunctions(context: TranslationContext, node: T): T { + val visitor = object : JsVisitorWithContextImpl() { + override fun endVisit(x: JsNameRef, ctx: JsContext) { + val specialFunction = when { + x.coroutineController -> SpecialFunction.COROUTINE_CONTROLLER + x.coroutineReceiver -> SpecialFunction.COROUTINE_RECEIVER + x.coroutineResult -> SpecialFunction.COROUTINE_RESULT + else -> null + } + if (specialFunction != null) { + val arguments = listOfNotNull(x.qualifier).toTypedArray() + ctx.replaceMe(TranslationUtils.invokeSpecialFunction(context, specialFunction, *arguments).source(x.source)) + } + else { + super.endVisit(x, ctx) + } + } + + override fun endVisit(x: JsExpression, ctx: JsContext) { + if (x.isSuspend) { + x.isSuspend = false + ctx.replaceMe(TranslationUtils.invokeSpecialFunction(context, SpecialFunction.SUSPEND_CALL, x).source(x.source)) + } + } + } + return visitor.accept(node) +} + +fun transformSpecialFunctionsToCoroutineMetadata(node: T): T { + val visitor = object : JsVisitorWithContextImpl() { + override fun endVisit(x: JsInvocation, ctx: JsContext) { + x.qualifier.name?.specialFunction?.let { specialFunction -> + val replacement = when (specialFunction) { + SpecialFunction.COROUTINE_CONTROLLER -> { + JsNameRef("\$\$controller\$\$", x.arguments.getOrNull(0)).apply { + coroutineController = true + } + } + SpecialFunction.COROUTINE_RECEIVER -> { + JsNameRef("\$this\$", x.arguments.getOrNull(0)).apply { + coroutineReceiver = true + } + } + SpecialFunction.COROUTINE_RESULT -> { + JsNameRef("\$result\$", x.arguments.getOrNull(0)).apply { + coroutineResult = true + } + } + SpecialFunction.SUSPEND_CALL -> { + x.arguments[0].apply { + isSuspend = true + } + } + else -> null + } + replacement?.let { ctx.replaceMe(it) } + } + } + } + return visitor.accept(node) +} \ No newline at end of file diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/ExpressionVisitor.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/ExpressionVisitor.java index 6b2f6fd7da5..9cc0169bad2 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/ExpressionVisitor.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/ExpressionVisitor.java @@ -263,7 +263,7 @@ public final class ExpressionVisitor extends TranslatorVisitor { return new JsInvocation(context.namer().kotlin(GET_KCLASS_FROM_EXPRESSION), receiver); } - return new JsInvocation(context.namer().kotlin(GET_KCLASS), UtilsKt.getReferenceToJsClass(lhs.getType(), context)); + return new JsInvocation(context.getReferenceToIntrinsic(GET_KCLASS), UtilsKt.getReferenceToJsClass(lhs.getType(), context)); } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/FunctionTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/FunctionTranslator.kt index 73f55169dc5..ae52db9da4a 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/FunctionTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/FunctionTranslator.kt @@ -112,7 +112,7 @@ fun TranslationContext.wrapWithInlineMetadata( if (descriptor.shouldBeExported(config)) { val metadata = InlineMetadata.compose(function, descriptor, this) val functionWithMetadata = metadata.functionWithMetadata(outerContext, sourceInfo) - config.configuration[JSConfigurationKeys.INCREMENTAL_RESULTS_CONSUMER]?.apply { + config.configuration[JSConfigurationKeys.INCREMENTAL_RESULTS_CONSUMER]?.apply { val psiFile = (descriptor.source.containingFile as? PsiSourceFile)?.psiFile ?: return@apply val file = VfsUtilCore.virtualToIoFile(psiFile.virtualFile) diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/PatternTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/PatternTranslator.java index 30c29147da2..08926c5b3c1 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/PatternTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/PatternTranslator.java @@ -94,7 +94,7 @@ public final class PatternTranslator extends AbstractTranslator { onFail = new JsNullLiteral(); } else { - JsExpression throwCCEFunRef = Namer.throwClassCastExceptionFunRef(); + JsExpression throwCCEFunRef = context().getReferenceToIntrinsic(Namer.THROW_CLASS_CAST_EXCEPTION_FUN_NAME); onFail = new JsInvocation(throwCCEFunRef); } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/StringTemplateTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/StringTemplateTranslator.java index b1666823145..91952d66708 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/StringTemplateTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/StringTemplateTranslator.java @@ -112,16 +112,11 @@ public final class StringTemplateTranslator extends AbstractTranslator { private boolean mustCallToString(@NotNull KotlinType type) { Name typeName = DescriptorUtilsKt.getNameIfStandardType(type); - if (typeName != null) { - //TODO: this is a hacky optimization, should use some generic approach - if (NamePredicate.STRING.test(typeName)) { - return false; - } - else if (NamePredicate.PRIMITIVE_NUMBERS.test(typeName)) { - return resultingExpression == null; - } + //TODO: this is a hacky optimization, should use some generic approach + if (typeName != null && NamePredicate.STRING.test(typeName)) { + return false; } - return expressionEntries.length == 1; + return resultingExpression == null; } @Override diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java index 9122698d1ec..e1f3cc9b7a0 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.js.facade.TranslationUnit; import org.jetbrains.kotlin.js.facade.exceptions.TranslationException; import org.jetbrains.kotlin.js.facade.exceptions.TranslationRuntimeException; import org.jetbrains.kotlin.js.facade.exceptions.UnsupportedFeatureException; +import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver; import org.jetbrains.kotlin.js.translate.callTranslator.CallTranslator; import org.jetbrains.kotlin.js.translate.context.Namer; import org.jetbrains.kotlin.js.translate.context.StaticContext; @@ -253,10 +254,11 @@ public final class Translation { @NotNull Collection units, @NotNull MainCallParameters mainCallParameters, @NotNull ModuleDescriptor moduleDescriptor, - @NotNull JsConfig config + @NotNull JsConfig config, + @NotNull SourceFilePathResolver sourceFilePathResolver ) throws TranslationException { try { - return doGenerateAst(bindingTrace, units, mainCallParameters, moduleDescriptor, config); + return doGenerateAst(bindingTrace, units, mainCallParameters, moduleDescriptor, config, sourceFilePathResolver); } catch (UnsupportedOperationException e) { throw new UnsupportedFeatureException("Unsupported feature used.", e); @@ -272,7 +274,8 @@ public final class Translation { @NotNull Collection units, @NotNull MainCallParameters mainCallParameters, @NotNull ModuleDescriptor moduleDescriptor, - @NotNull JsConfig config + @NotNull JsConfig config, + @NotNull SourceFilePathResolver sourceFilePathResolver ) { JsProgram program = new JsProgram(); JsFunction rootFunction = new JsFunction(program.getRootScope(), new JsBlock(), "root function"); @@ -290,7 +293,7 @@ public final class Translation { for (TranslationUnit unit : units) { if (unit instanceof TranslationUnit.SourceFile) { KtFile file = ((TranslationUnit.SourceFile) unit).getFile(); - StaticContext staticContext = new StaticContext(bindingTrace, config, moduleDescriptor); + StaticContext staticContext = new StaticContext(bindingTrace, config, moduleDescriptor, sourceFilePathResolver); TranslationContext context = TranslationContext.rootContext(staticContext); List fileMemberScope = new ArrayList<>(); translateFile(context, file, fileMemberScope); @@ -308,7 +311,7 @@ public final class Translation { } } - JsProgramFragment testFragment = mayBeGenerateTests(config, bindingTrace, moduleDescriptor); + JsProgramFragment testFragment = mayBeGenerateTests(config, bindingTrace, moduleDescriptor, sourceFilePathResolver); fragments.add(testFragment); newFragments.add(testFragment); merger.addFragment(testFragment); @@ -316,7 +319,7 @@ public final class Translation { if (mainCallParameters.shouldBeGenerated()) { JsProgramFragment mainCallFragment = generateCallToMain( - bindingTrace, config, moduleDescriptor, mainCallParameters.arguments()); + bindingTrace, config, moduleDescriptor, sourceFilePathResolver, mainCallParameters.arguments()); if (mainCallFragment != null) { fragments.add(mainCallFragment); newFragments.add(mainCallFragment); @@ -400,9 +403,9 @@ public final class Translation { @NotNull private static JsProgramFragment mayBeGenerateTests( @NotNull JsConfig config, @NotNull BindingTrace trace, - @NotNull ModuleDescriptor moduleDescriptor + @NotNull ModuleDescriptor moduleDescriptor, @NotNull SourceFilePathResolver sourceFilePathResolver ) { - StaticContext staticContext = new StaticContext(trace, config, moduleDescriptor); + StaticContext staticContext = new StaticContext(trace, config, moduleDescriptor, sourceFilePathResolver); TranslationContext context = TranslationContext.rootContext(staticContext); new JSTestGenerator(context).generateTestCalls(moduleDescriptor); @@ -414,9 +417,10 @@ public final class Translation { @Nullable private static JsProgramFragment generateCallToMain( @NotNull BindingTrace trace, @NotNull JsConfig config, @NotNull ModuleDescriptor moduleDescriptor, + @NotNull SourceFilePathResolver sourceFilePathResolver, @NotNull List arguments ) { - StaticContext staticContext = new StaticContext(trace, config, moduleDescriptor); + StaticContext staticContext = new StaticContext(trace, config, moduleDescriptor, sourceFilePathResolver); TranslationContext context = TranslationContext.rootContext(staticContext); MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(context.bindingContext()); FunctionDescriptor functionDescriptor = mainFunctionDetector.getMainFunction(moduleDescriptor); diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/Intrinsics.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/Intrinsics.java index a010936b3d2..6528ab3bf79 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/Intrinsics.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/Intrinsics.java @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.js.translate.intrinsic; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.descriptors.ClassDescriptor; import org.jetbrains.kotlin.descriptors.FunctionDescriptor; -import org.jetbrains.kotlin.js.translate.context.StaticContext; import org.jetbrains.kotlin.js.translate.context.TranslationContext; import org.jetbrains.kotlin.js.translate.intrinsic.functions.FunctionIntrinsics; import org.jetbrains.kotlin.js.translate.intrinsic.functions.basic.FunctionIntrinsic; @@ -37,8 +36,8 @@ public final class Intrinsics { private final BinaryOperationIntrinsics binaryOperationIntrinsics = new BinaryOperationIntrinsics(); private final ObjectIntrinsics objectIntrinsics; - public Intrinsics(@NotNull StaticContext staticContext) { - objectIntrinsics = new ObjectIntrinsics(staticContext); + public Intrinsics() { + objectIntrinsics = new ObjectIntrinsics(); } @NotNull diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/KotlinAliasedFunctionIntrinsic.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/KotlinAliasedFunctionIntrinsic.kt new file mode 100644 index 00000000000..eef982c3522 --- /dev/null +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/KotlinAliasedFunctionIntrinsic.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.js.translate.intrinsic.functions.factories + +import org.jetbrains.kotlin.js.backend.ast.JsExpression +import org.jetbrains.kotlin.js.backend.ast.JsInvocation +import org.jetbrains.kotlin.js.translate.context.TranslationContext +import org.jetbrains.kotlin.js.translate.intrinsic.functions.basic.FunctionIntrinsicWithReceiverComputed +import org.jetbrains.kotlin.js.translate.utils.TranslationUtils + +open class KotlinAliasedFunctionIntrinsic(private val functionName: String) : FunctionIntrinsicWithReceiverComputed() { + override fun apply( + receiver: JsExpression?, + arguments: List, + context: TranslationContext + ): JsExpression { + val function = context.getReferenceToIntrinsic(functionName) + return JsInvocation(function, if (receiver == null) arguments else TranslationUtils.generateInvocationArguments(receiver, arguments)) + } +} \ No newline at end of file diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/TopLevelFIF.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/TopLevelFIF.java index af13c6949ff..487763c4dd8 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/TopLevelFIF.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/TopLevelFIF.java @@ -47,7 +47,7 @@ import static org.jetbrains.kotlin.js.patterns.PatternBuilder.pattern; public final class TopLevelFIF extends CompositeFIF { public static final DescriptorPredicate EQUALS_IN_ANY = pattern("kotlin", "Any", "equals"); @NotNull - private static final KotlinFunctionIntrinsic KOTLIN_ANY_EQUALS = new KotlinFunctionIntrinsic("equals") { + private static final KotlinAliasedFunctionIntrinsic KOTLIN_ANY_EQUALS = new KotlinAliasedFunctionIntrinsic("equals") { @NotNull @Override public JsExpression apply( @@ -65,7 +65,7 @@ public final class TopLevelFIF extends CompositeFIF { }; @NotNull - public static final KotlinFunctionIntrinsic KOTLIN_EQUALS = new KotlinFunctionIntrinsic("equals"); + public static final KotlinAliasedFunctionIntrinsic KOTLIN_EQUALS = new KotlinAliasedFunctionIntrinsic("equals"); @NotNull private static final KotlinFunctionIntrinsic KOTLIN_SUBSEQUENCE = new KotlinFunctionIntrinsic("subSequence"); @@ -73,7 +73,7 @@ public final class TopLevelFIF extends CompositeFIF { @NotNull private static final DescriptorPredicate HASH_CODE_IN_ANY = pattern("kotlin", "Any", "hashCode"); @NotNull - private static final KotlinFunctionIntrinsic KOTLIN_HASH_CODE = new KotlinFunctionIntrinsic("hashCode"); + private static final KotlinAliasedFunctionIntrinsic KOTLIN_HASH_CODE = new KotlinAliasedFunctionIntrinsic("hashCode"); @NotNull private static final FunctionIntrinsic RETURN_RECEIVER_INTRINSIC = new FunctionIntrinsicWithReceiverComputed() { @@ -164,7 +164,7 @@ public final class TopLevelFIF extends CompositeFIF { @NotNull - public static final KotlinFunctionIntrinsic TO_STRING = new KotlinFunctionIntrinsic("toString"); + public static final KotlinAliasedFunctionIntrinsic TO_STRING = new KotlinAliasedFunctionIntrinsic("toString"); @NotNull private static final FunctionIntrinsic CHAR_TO_STRING = new FunctionIntrinsicWithReceiverComputed() { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/objects/objectsIntrinsics.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/objects/objectsIntrinsics.kt index 41910d9149c..877ccd61147 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/objects/objectsIntrinsics.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/objects/objectsIntrinsics.kt @@ -20,25 +20,16 @@ import org.jetbrains.kotlin.builtins.CompanionObjectMapping import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.js.backend.ast.JsExpression -import org.jetbrains.kotlin.js.backend.ast.JsName -import org.jetbrains.kotlin.js.translate.context.Namer -import org.jetbrains.kotlin.js.translate.context.StaticContext import org.jetbrains.kotlin.js.translate.context.TranslationContext -import org.jetbrains.kotlin.js.translate.utils.JsAstUtils import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe -class DefaultClassObjectIntrinsic(val staticContext: StaticContext, val tag: String, val fqName: FqName): ObjectIntrinsic { - private val innerName: JsName by lazy { - val declaration = JsAstUtils.replaceRootReference(staticContext.getQualifiedReference(fqName), Namer.kotlinObject()) - staticContext.importDeclaration(fqName.shortName().asString(), tag, declaration) - } - - override fun apply(context: TranslationContext) = JsAstUtils.pureFqn(innerName, null) +class DefaultClassObjectIntrinsic( val fqName: FqName): ObjectIntrinsic { + override fun apply(context: TranslationContext) = context.getReferenceToIntrinsic(fqName.asString()) } -class ObjectIntrinsics(private val staticContext: StaticContext) { +class ObjectIntrinsics { private val cache = mutableMapOf() fun getIntrinsic(classDescriptor: ClassDescriptor) = cache.getOrPut(classDescriptor) { createIntrinsic(classDescriptor) } @@ -53,8 +44,7 @@ class ObjectIntrinsics(private val staticContext: StaticContext) { val containingDeclaration = classDescriptor.containingDeclaration val name = Name.identifier(containingDeclaration.name.asString() + "CompanionObject") - return DefaultClassObjectIntrinsic( - staticContext, "intrinsic:kotlin.js.internal.${name.asString()}", FqName("kotlin.js.internal").child(name)) + return DefaultClassObjectIntrinsic(FqName("kotlin.js.internal").child(name)) } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallExpressionTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallExpressionTranslator.java index 13dbbd524cc..cd4e7cd5780 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallExpressionTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallExpressionTranslator.java @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.js.translate.reference; import com.google.gwt.dev.js.ThrowExceptionOnErrorReporter; +import com.google.gwt.dev.js.rhino.CodePosition; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.config.CommonConfigurationKeys; @@ -30,6 +31,7 @@ import org.jetbrains.kotlin.js.resolve.BindingContextSlicesJsKt; import org.jetbrains.kotlin.js.resolve.diagnostics.JsCallChecker; import org.jetbrains.kotlin.js.translate.callTranslator.CallTranslator; import org.jetbrains.kotlin.js.translate.context.TranslationContext; +import org.jetbrains.kotlin.js.translate.utils.PsiUtils; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.KtCallExpression; import org.jetbrains.kotlin.psi.KtExpression; @@ -40,6 +42,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.inline.InlineUtil; import org.jetbrains.kotlin.resolve.scopes.LexicalScope; +import java.io.IOException; import java.util.*; import static org.jetbrains.kotlin.js.resolve.diagnostics.JsCallChecker.isJsCall; @@ -175,6 +178,18 @@ public final class CallExpressionTranslator extends AbstractCallExpressionTransl assert currentScope instanceof JsFunctionScope : "Usage of js outside of function is unexpected"; JsScope temporaryRootScope = new JsRootScope(new JsProgram()); JsScope scope = new DelegatingJsFunctionScopeWithTemporaryParent((JsFunctionScope) currentScope, temporaryRootScope); - return ParserUtilsKt.parse(jsCode, ThrowExceptionOnErrorReporter.INSTANCE, scope, jsCodeExpression.getContainingKtFile().getName()); + + JsLocation location; + try { + location = PsiUtils.extractLocationFromPsi(jsCodeExpression, context().getSourceFilePathResolver()); + } + catch (IOException e) { + location = new JsLocation(jsCodeExpression.getContainingKtFile().getName(), 0, 0); + } + + List statements = ParserUtilsKt.parseExpressionOrStatement( + jsCode, ThrowExceptionOnErrorReporter.INSTANCE, scope, + new CodePosition(location.getStartLine(), location.getStartChar()), location.getFile()); + return statements != null ? statements : Collections.emptyList(); } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallableReferenceTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallableReferenceTranslator.kt index 82d2e1fd4d3..33477cdd581 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallableReferenceTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallableReferenceTranslator.kt @@ -135,7 +135,7 @@ object CallableReferenceTranslator { function.body.statements += JsReturn(TranslationUtils.coerce(context, invocation, context.currentModule.builtIns.anyType)) val rawCallableRef = bindIfNecessary(function, receiver) - return wrapFunctionCallableRef(expression.callableReference.getReferencedName(), rawCallableRef) + return context.wrapFunctionCallableRef(expression.callableReference.getReferencedName(), rawCallableRef) } private fun translateForProperty( @@ -168,7 +168,7 @@ object CallableReferenceTranslator { null } - return wrapPropertyCallableRef(receiver, descriptor, expression.callableReference.getReferencedName(), getter, setter) + return context.wrapPropertyCallableRef(receiver, descriptor, expression.callableReference.getReferencedName(), getter, setter) } private fun isSetterVisible(descriptor: PropertyDescriptor, context: TranslationContext): Boolean { @@ -225,7 +225,7 @@ object CallableReferenceTranslator { } } - private fun wrapPropertyCallableRef( + private fun TranslationContext.wrapPropertyCallableRef( receiver: JsExpression?, descriptor: PropertyDescriptor, name: String, @@ -238,7 +238,7 @@ object CallableReferenceTranslator { } val nameLiteral = JsStringLiteral(name) val argCountLiteral = JsIntLiteral(argCount) - val invokeFun = JsNameRef(Namer.PROPERTY_CALLABLE_REF, Namer.kotlinObject()) + val invokeFun = getReferenceToIntrinsic(Namer.PROPERTY_CALLABLE_REF) val invocation = JsInvocation(invokeFun, nameLiteral, argCountLiteral, getter) if (setter != null) { invocation.arguments += setter @@ -246,13 +246,12 @@ object CallableReferenceTranslator { return invocation } - private fun wrapFunctionCallableRef( + private fun TranslationContext.wrapFunctionCallableRef( name: String, function: JsExpression ): JsExpression { val nameLiteral = JsStringLiteral(name) - val invokeName = Namer.FUNCTION_CALLABLE_REF - val invokeFun = JsNameRef(invokeName, Namer.kotlinObject()) + val invokeFun = getReferenceToIntrinsic(Namer.FUNCTION_CALLABLE_REF) invokeFun.sideEffects = SideEffectKind.PURE val invocation = JsInvocation(invokeFun, nameLiteral, function) invocation.isCallableReference = true diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/VariableAccessTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/VariableAccessTranslator.java index eaba7744093..1511324bad2 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/VariableAccessTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/VariableAccessTranslator.java @@ -83,8 +83,8 @@ public class VariableAccessTranslator extends AbstractTranslator implements Acce else if (original instanceof LocalVariableDescriptor) { LocalVariableDescriptor originalLocal = (LocalVariableDescriptor) original; if (originalLocal.isLateInit()) { - JsInvocation throwInvocation = new JsInvocation(Namer.throwUninitializedPropertyAccessExceptionFunRef(), - new JsStringLiteral(originalLocal.getName().asString())); + JsExpression throwFunction = context().getReferenceToIntrinsic(Namer.THROW_UNINITIALIZED_PROPERTY_ACCESS_EXCEPTION); + JsInvocation throwInvocation = new JsInvocation(throwFunction, new JsStringLiteral(originalLocal.getName().asString())); return new JsConditional(new JsBinaryOperation(JsBinaryOperator.EQ, e, new JsNullLiteral()), throwInvocation, e); } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/PsiUtils.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/PsiUtils.java index 440f371c462..567e1632586 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/PsiUtils.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/PsiUtils.java @@ -16,18 +16,26 @@ package org.jetbrains.kotlin.js.translate.utils; +import com.intellij.openapi.editor.Document; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.CallableDescriptor; +import org.jetbrains.kotlin.js.backend.ast.JsLocation; +import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver; import org.jetbrains.kotlin.lexer.KtToken; import org.jetbrains.kotlin.lexer.KtTokens; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall; +import java.io.*; +import java.nio.charset.Charset; import java.util.Collections; import java.util.List; +import java.util.function.Supplier; public final class PsiUtils { @@ -120,4 +128,18 @@ public final class PsiUtils { return resolvedCall.getCandidateDescriptor(); } + + @NotNull + public static JsLocation extractLocationFromPsi(@NotNull PsiElement element, @NotNull SourceFilePathResolver pathResolver) + throws IOException { + PsiFile psiFile = element.getContainingFile(); + int offset = element.getNode().getStartOffset(); + Document document = psiFile.getViewProvider().getDocument(); + assert document != null; + int sourceLine = document.getLineNumber(offset); + int sourceColumn = offset - document.getLineStartOffset(sourceLine); + + File file = new File(psiFile.getViewProvider().getVirtualFile().getPath()); + return new JsLocation(pathResolver.getPathRelativeToSourceRoots(file), sourceLine, sourceColumn); + } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/TranslationUtils.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/TranslationUtils.java index 9aec9041bab..3cfa71d1a67 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/TranslationUtils.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/TranslationUtils.java @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.js.translate.utils; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -226,17 +227,6 @@ public final class TranslationUtils { return Translation.translateAsExpression(baseExpression, context); } - @NotNull - public static JsExpression translateLeftExpression( - @NotNull TranslationContext context, - @NotNull KtBinaryExpression expression, - @NotNull JsBlock block - ) { - KtExpression left = expression.getLeft(); - assert left != null : "Binary expression should have a left expression: " + expression.getText(); - return Translation.translateAsExpression(left, context, block); - } - @NotNull public static JsExpression translateRightExpression( @NotNull TranslationContext context, @@ -305,7 +295,7 @@ public final class TranslationUtils { @NotNull public static JsConditional sure(@NotNull JsExpression expression, @NotNull TranslationContext context) { - JsInvocation throwNPE = new JsInvocation(Namer.throwNPEFunctionRef()); + JsInvocation throwNPE = new JsInvocation(context.getReferenceToIntrinsic(Namer.THROW_NPE_FUN_NAME)); JsConditional ensureNotNull = notNullConditional(expression, throwNPE, context); JsExpression thenExpression = ensureNotNull.getThenExpression(); @@ -536,7 +526,7 @@ public final class TranslationUtils { } @NotNull - private static JsInvocation invokeSpecialFunction( + public static JsInvocation invokeSpecialFunction( @NotNull TranslationContext context, @NotNull SpecialFunction function, @NotNull JsExpression... arguments ) { @@ -548,4 +538,13 @@ public final class TranslationUtils { public static String getTagForSpecialFunction(@NotNull SpecialFunction specialFunction) { return "special:" + specialFunction.name(); } + + @NotNull + public static JsExpression getIntrinsicFqn(@NotNull String name) { + JsExpression fqn = pureFqn(Namer.KOTLIN_NAME, null); + for (String part : StringUtil.split(name, ".")) { + fqn = pureFqn(part, fqn); + } + return fqn; + } } diff --git a/js/js.translator/testData/box/coroutines/localVarOptimization.kt b/js/js.translator/testData/box/coroutines/localVarOptimization.kt new file mode 100644 index 00000000000..431365d4f21 --- /dev/null +++ b/js/js.translator/testData/box/coroutines/localVarOptimization.kt @@ -0,0 +1,49 @@ +// EXPECTED_REACHABLE_NODES: 1124 +// DECLARES_VARIABLE: function=doResume name=k +// PROPERTY_READ_COUNT: name=local$o count=1 +// PROPERTY_WRITE_COUNT: name=local$o count=2 +import kotlin.coroutines.experimental.* + +var next: () -> Unit = {} +var complete = false +var log = "" + +suspend fun foo(x: String): String = suspendCoroutine { continuation -> + log += "[$x]" + next = { continuation.resume(x) } +} + +fun build(x: suspend () -> Unit) { + next = { + x.startCoroutine(object : Continuation { + override val context = EmptyCoroutineContext + + override fun resume(x: Unit) { + complete = true + } + + override fun resumeWithException(x: Throwable) { + complete = true + } + }) + } +} + +fun box(): String { + build { + val o = foo("O") + log += "-" + val k = foo("K") + log += ":" + log += "{$o$k}" + } + + while (!complete) { + next() + log += "#" + } + + if (log != "[O]#-[K]#:{OK}#") return "fail: $log" + + return "OK" +} \ No newline at end of file diff --git a/js/js.translator/testData/box/coroutines/nativeExceptions.kt b/js/js.translator/testData/box/coroutines/nativeExceptions.kt new file mode 100644 index 00000000000..b610f0b5807 --- /dev/null +++ b/js/js.translator/testData/box/coroutines/nativeExceptions.kt @@ -0,0 +1,53 @@ +// EXPECTED_REACHABLE_NODES: 1123 +import kotlin.coroutines.experimental.* +import kotlin.coroutines.experimental.intrinsics.* + +private var next: () -> Unit = {} +private var stopped = false + +suspend fun delay(): Unit = suspendCoroutine { c -> + next = { c.resume(Unit) } +} + +fun build(c: suspend () -> Unit) { + c.startCoroutine(object : Continuation { + override fun resume(x: Unit) { + stopped = true + } + + override fun resumeWithException(x: Throwable) { + stopped = true + } + + override val context = EmptyCoroutineContext + }) +} + +fun box(): String { + var log = "" + + build { + try { + log += "before delay;" + delay() + log += "after delay;" + js("undefined").lalala + log += "ignore;" + } + catch (e: dynamic) { + log += "caught ${e.name};" + } + finally { + log += "finally;" + } + } + + while (!stopped) { + log += "@;" + next() + } + + if (log != "before delay;@;after delay;caught TypeError;finally;") return "fail: $log" + + return "OK" +} \ No newline at end of file diff --git a/js/js.translator/testData/box/expression/evaluationOrder/secondaryConstructorTemporaryVars.kt b/js/js.translator/testData/box/expression/evaluationOrder/secondaryConstructorTemporaryVars.kt index ab19a3ea3bb..c532bd5e70b 100644 --- a/js/js.translator/testData/box/expression/evaluationOrder/secondaryConstructorTemporaryVars.kt +++ b/js/js.translator/testData/box/expression/evaluationOrder/secondaryConstructorTemporaryVars.kt @@ -1,5 +1,5 @@ // EXPECTED_REACHABLE_NODES: 995 -// HAS_NO_CAPTURED_VARS: function=A_init except=Kotlin;A +// HAS_NO_CAPTURED_VARS: function=A_init except=Kotlin;A;equals class A() { var y: String? = null diff --git a/js/js.translator/testData/box/expression/stringTemplates/nonStrings.kt b/js/js.translator/testData/box/expression/stringTemplates/nonStrings.kt new file mode 100644 index 00000000000..f697630a933 --- /dev/null +++ b/js/js.translator/testData/box/expression/stringTemplates/nonStrings.kt @@ -0,0 +1,23 @@ +// EXPECTED_REACHABLE_NODES: 1024 +fun box(): String { + val x = foo() + val y = bar() + + var r = "$x$y" + if (r != "2342") return "fail: $r" + + r = "$y$x" + if (r != "4223") return "fail: $r" + + r = "$x$x" + if (r != "2323") return "fail: $r" + + r = "$y$y" + if (r != "4242") return "fail: $r" + + return "OK" +} + +fun foo(): Any = 23 + +fun bar() = 42 \ No newline at end of file diff --git a/js/js.translator/testData/box/incremental/jsModule.js b/js/js.translator/testData/box/incremental/jsModule.js new file mode 100644 index 00000000000..e23b8236e20 --- /dev/null +++ b/js/js.translator/testData/box/incremental/jsModule.js @@ -0,0 +1,14 @@ +define("foo", [], function() { + return { + "fooF": function() { + return "foo"; + } + }; +}); +define("bar", [], function() { + return { + "barF": function() { + return "bar"; + } + }; +}); \ No newline at end of file diff --git a/js/js.translator/testData/box/incremental/jsModule.kt b/js/js.translator/testData/box/incremental/jsModule.kt new file mode 100644 index 00000000000..7904eb29357 --- /dev/null +++ b/js/js.translator/testData/box/incremental/jsModule.kt @@ -0,0 +1,32 @@ +// EXPECTED_REACHABLE_NODES: 1018 + +// MODULE: lib +// FILE: a.kt +// MODULE_KIND: AMD +@file:JsModule("foo") + +external fun fooF(): String + +// FILE: b.kt +@file:JsModule("bar") + +external fun barF(): String + +// FILE: c.kt +// RECOMPILE +fun dummyF() = "dummy" + +// MODULE: main(lib) +// FILE: main.kt +// MODULE_KIND: AMD + +fun box(): String { + val foo = fooF() + if (foo != "foo") return "fail1: $foo" + + val bar = barF() + if (bar != "bar") return "fail2: $bar" + + return "OK" +} + diff --git a/js/js.translator/testData/box/inlineSizeReduction/multiModuleDefaultArgsCleanup.kt b/js/js.translator/testData/box/inlineSizeReduction/multiModuleDefaultArgsCleanup.kt new file mode 100644 index 00000000000..303d60680b7 --- /dev/null +++ b/js/js.translator/testData/box/inlineSizeReduction/multiModuleDefaultArgsCleanup.kt @@ -0,0 +1,17 @@ +// EXPECTED_REACHABLE_NODES: 1018 +// MODULE: lib +// FILE: lib.kt +inline fun foo(x: String = "x", y: String = "y") = x + y + +// MODULE: main(lib) +// FILE: main.kt +// CHECK_VARS_COUNT: function=test count=0 + +fun test() = foo() + ";" + foo(x = "X") + ";" + foo(y = "Y") + ";" + foo(x = "X", y = "Y") + +fun box(): String { + val r = test() + if (test() != "xy;Xy;xY;XY") return "fail: $r" + + return "OK" +} \ No newline at end of file diff --git a/js/js.translator/testData/box/jsCode/objectExpression.kt b/js/js.translator/testData/box/jsCode/objectExpression.kt new file mode 100644 index 00000000000..55710dbabdd --- /dev/null +++ b/js/js.translator/testData/box/jsCode/objectExpression.kt @@ -0,0 +1,26 @@ +// EXPECTED_REACHABLE_NODES: 1026 +import kotlin.js.* + +private fun isOrdinaryObject(o: Any?): Boolean = jsTypeOf(o) == "object" && Object.getPrototypeOf(o).`constructor` === Any::class.js + +external class Object { + companion object { + fun getPrototypeOf(x: Any?): dynamic + + fun keys(x: Any): Array + } +} + +fun box(): String { + val a = js("{}") + if (!isOrdinaryObject(a)) return "fail: a is not an object" + if (Object.keys(a).size != 0) return "fail: a should not have any properties" + + val b = js("{ foo: 23, bar: 42 }") + if (!isOrdinaryObject(b)) return "fail: b is not an object" + if (Object.keys(b).size != 2) return "fail: b should have two properties" + if (b.foo != 23) return "fail: b.foo == ${b.foo}" + if (b.bar != 42) return "fail: b.bar == ${b.bar}" + + return "OK" +} \ No newline at end of file diff --git a/js/js.translator/testData/lineNumbers/coroutine.kt b/js/js.translator/testData/lineNumbers/coroutine.kt index 9055877c714..92ece9624ea 100644 --- a/js/js.translator/testData/lineNumbers/coroutine.kt +++ b/js/js.translator/testData/lineNumbers/coroutine.kt @@ -14,4 +14,4 @@ suspend fun bar(): Unit { println(a + b) } -// LINES: 4 4 4 5 5 5 5 6 4 4 4 15 9 9 9 9 15 9 9 9 9 * 15 10 10 11 11 11 11 11 * 11 12 12 13 13 13 13 13 13 14 14 \ No newline at end of file +// LINES: 4 4 4 5 5 5 5 6 4 4 4 15 9 9 9 9 15 9 9 9 * 15 10 10 11 11 11 11 11 * 11 12 12 13 13 13 13 13 13 13 14 14 \ No newline at end of file diff --git a/js/js.translator/testData/lineNumbers/coroutineNullAssertion.kt b/js/js.translator/testData/lineNumbers/coroutineNullAssertion.kt new file mode 100644 index 00000000000..6bde8933151 --- /dev/null +++ b/js/js.translator/testData/lineNumbers/coroutineNullAssertion.kt @@ -0,0 +1,11 @@ +suspend fun foo() { + delay() + null!! + delay() + println("OK") +} + +suspend fun delay() { +} + +// LINES: 6 1 1 1 1 6 1 1 * 6 2 2 2 2 2 * 3 3 4 4 4 4 4 5 5 * 9 \ No newline at end of file diff --git a/js/js.translator/testData/lineNumbers/inlineReturn.kt b/js/js.translator/testData/lineNumbers/inlineReturn.kt index 46c862ad3b3..89b2acc48d4 100644 --- a/js/js.translator/testData/lineNumbers/inlineReturn.kt +++ b/js/js.translator/testData/lineNumbers/inlineReturn.kt @@ -21,4 +21,4 @@ fun bar(x: Int) { println("%") } -// LINES: 1 1 1 1 1 1 1 17 2 2 3 3 4 7 7 9 9 10 10 11 14 14 16 16 1 1 22 20 20 20 20 2 2 3 3 4 3 7 7 9 9 10 10 11 10 14 14 16 16 * 20 21 21 \ No newline at end of file +// LINES: 1 1 1 1 1 1 1 1 1 17 2 2 3 3 4 7 7 9 9 10 10 11 14 14 16 16 1 1 1 1 22 20 20 20 20 2 2 3 3 4 3 7 7 9 9 10 10 11 10 14 14 16 16 * 20 21 21 \ No newline at end of file diff --git a/js/js.translator/testData/lineNumbers/jsCode.kt b/js/js.translator/testData/lineNumbers/jsCode.kt new file mode 100644 index 00000000000..735dbaa1f69 --- /dev/null +++ b/js/js.translator/testData/lineNumbers/jsCode.kt @@ -0,0 +1,8 @@ +fun foo() { + var x = "foo" + println("before: $x") + js("console.log('js' + x);") + println("after: $x") +} + +// LINES: 6 2 2 3 3 4 4 5 5 \ No newline at end of file diff --git a/js/npm.templates/kotlin-compiler/package.json b/js/npm.templates/kotlin-compiler/package.json index ff1651e537c..04612fab7ab 100644 --- a/js/npm.templates/kotlin-compiler/package.json +++ b/js/npm.templates/kotlin-compiler/package.json @@ -21,8 +21,5 @@ "homepage": "kotlinlang.org", "bin": { "kotlinc-js": "bin/kotlinc-js-runner.js" - }, - "publishConfig" : { - "tag" : "dev" } } diff --git a/js/npm.templates/kotlin/package.json b/js/npm.templates/kotlin/package.json index aa42b62390f..2fac326ba12 100644 --- a/js/npm.templates/kotlin/package.json +++ b/js/npm.templates/kotlin/package.json @@ -19,8 +19,5 @@ "bugs": { "url": "kotl.in/issue" }, - "homepage": "kotlinlang.org", - "publishConfig" : { - "tag" : "dev" - } + "homepage": "kotlinlang.org" } diff --git a/libraries/commonConfiguration.gradle b/libraries/commonConfiguration.gradle index b4d53fd51e2..1d0291e35a1 100644 --- a/libraries/commonConfiguration.gradle +++ b/libraries/commonConfiguration.gradle @@ -216,7 +216,6 @@ ext.createScriptTask = { Project project, def name, Closure configureC return project.configure(task) { // dependsOn(rootProject.prepareBootstrap) classpath = rootProject.configurations.scriptCompile - println(rootProject.configurations.scriptCompile.files) main = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler" args = [ "-script", diff --git a/libraries/stdlib/src/kotlin/util/KotlinVersion.kt b/libraries/stdlib/src/kotlin/util/KotlinVersion.kt index 2c22882f7bc..a056e1f0a31 100644 --- a/libraries/stdlib/src/kotlin/util/KotlinVersion.kt +++ b/libraries/stdlib/src/kotlin/util/KotlinVersion.kt @@ -70,6 +70,6 @@ public class KotlinVersion(val major: Int, val minor: Int, val patch: Int) : Com */ // TODO: get from metadata or hardcode automatically during build @kotlin.jvm.JvmField - public val CURRENT: KotlinVersion = KotlinVersion(1, 1, 50) + public val CURRENT: KotlinVersion = KotlinVersion(1, 1, 60) } } diff --git a/libraries/stdlib/src/kotlin/util/Standard.kt b/libraries/stdlib/src/kotlin/util/Standard.kt index ab1835108af..e524197ebab 100644 --- a/libraries/stdlib/src/kotlin/util/Standard.kt +++ b/libraries/stdlib/src/kotlin/util/Standard.kt @@ -82,7 +82,7 @@ public inline fun T.takeUnless(predicate: (T) -> Boolean): T? = if (!predica */ @kotlin.internal.InlineOnly public inline fun repeat(times: Int, action: (Int) -> Unit) { - for (index in 0..times - 1) { + for (index in 0 until times) { action(index) } -} \ No newline at end of file +} diff --git a/libraries/tools/kotlin-annotation-processing/build.gradle.kts b/libraries/tools/kotlin-annotation-processing/build.gradle.kts index e4dfe9d8b49..121ac9025c9 100644 --- a/libraries/tools/kotlin-annotation-processing/build.gradle.kts +++ b/libraries/tools/kotlin-annotation-processing/build.gradle.kts @@ -17,10 +17,12 @@ apply { plugin("kotlin") } val packedJars by configurations.creating dependencies { - compileOnly(project(":kotlin-annotation-processing")) - compile("org.jetbrains.kotlin:gradle-api:1.6") - compile("com.android.tools.build:gradle:1.1.0") compile(projectDist(":kotlin-stdlib")) + compileOnly(project(":kotlin-annotation-processing")) + compileOnly("org.jetbrains.kotlin:gradle-api:1.6") + testCompile("org.jetbrains.kotlin:gradle-api:1.6") + compileOnly("com.android.tools.build:gradle:1.1.0") + testCompile("com.android.tools.build:gradle:1.1.0") testCompile(commonDep("junit:junit")) packedJars(project(":kotlin-annotation-processing")) { isTransitive = false } } diff --git a/libraries/tools/kotlin-annotations-jvm/build.gradle b/libraries/tools/kotlin-annotations-jvm/build.gradle new file mode 100644 index 00000000000..f9d929951bd --- /dev/null +++ b/libraries/tools/kotlin-annotations-jvm/build.gradle @@ -0,0 +1,36 @@ +description = 'Kotlin annotations for JVM' + +apply plugin: 'kotlin' + +configureJvm6Project(project) +configurePublishing(project) + +sourceSets { + main { + kotlin { + srcDir 'src' + } + } +} + +artifacts { + archives sourcesJar + archives javadocJar +} + +dist { + from (jar, sourcesJar) +} + +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + kotlinOptions.jdkHome = JDK_16 + kotlinOptions.jvmTarget = 1.6 +} + +compileKotlin { + kotlinOptions.freeCompilerArgs = [ + "-Xallow-kotlin-package", + "-module-name", project.name + ] +} + diff --git a/libraries/tools/kotlin-annotations-jvm/src/kotlin/annotations/jvm/Annotations.kt b/libraries/tools/kotlin-annotations-jvm/src/kotlin/annotations/jvm/Annotations.kt new file mode 100644 index 00000000000..00d67daae8d --- /dev/null +++ b/libraries/tools/kotlin-annotations-jvm/src/kotlin/annotations/jvm/Annotations.kt @@ -0,0 +1,34 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.annotations.jvm + +/** + * Contains the list of possible migration statuses. + */ +public enum class MigrationStatus { + IGNORE, + WARN, + @Deprecated("experimental feature") + STRICT +} + +/** + * This meta-annotation is intended for user nullability annotations with JSR-305 type qualifiers. Behaviour of meta-annotated + * nullability annotations can be controlled via compilation flag. + */ +@Target(AnnotationTarget.ANNOTATION_CLASS) +public annotation class UnderMigration(val status: MigrationStatus) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle index 245d391566e..e13e1efbcac 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle @@ -26,6 +26,37 @@ dependencies { testCompile 'org.jetbrains.kotlin:gradle-api:2.2' } +test.dependsOn(":kotlin-allopen:install", + ":kotlin-android-extensions:install", + ":kotlin-build-common:install", + ":kotlin-compiler-embeddable:install", + ":kotlin-gradle-plugin:install", + ":kotlin-reflect:install", + ":kotlin-test:kotlin-test-jvm:install", + ":kotlin-gradle-subplugin-example:install", + ":kotlin-stdlib-jre8:install") + +// Validate that all dependencies 'install' tasks are added to 'test' dependencies +// Test dependencies are specified as paths to avoid forcing dependency resolution +// and also to avoid specifying evaluationDependsOn for each testCompile dependency. +gradle.taskGraph.whenReady { + def notAddedTestTasks = [] + def testDependencies = test.dependsOn + + for (dependency in configurations.getByName("testCompile").allDependencies) { + if (!(dependency instanceof ProjectDependency)) continue + + def task = dependency.dependencyProject.tasks.findByName("install") + if (task != null && !testDependencies.contains(task.path)) { + notAddedTestTasks.add("\"${task.path}\"") + } + } + + if (!notAddedTestTasks.isEmpty()) { + throw new GradleException("Add the following tasks to ${test.path} dependencies:\n ${notAddedTestTasks.join(",\n ")}") + } +} + processResources { expand(project.properties) } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt index f124b53b380..9da522f7baa 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt @@ -145,7 +145,8 @@ abstract class BaseGradleIT { val forceOutputToStdout: Boolean = false, val debug: Boolean = false, val freeCommandLineArgs: List = emptyList(), - val kotlinVersion: String = KOTLIN_VERSION) + val kotlinVersion: String = KOTLIN_VERSION, + val kotlinDaemonDebugPort: Int? = null) open inner class Project( val projectName: String, @@ -438,6 +439,9 @@ abstract class BaseGradleIT { if (options.debug) { add("-Dorg.gradle.debug=true") } + options.kotlinDaemonDebugPort?.let { port -> + add("-Dkotlin.daemon.jvm.options=-agentlib:jdwp=transport=dt_socket\\,server=y\\,suspend=y\\,address=$port") + } addAll(options.freeCommandLineArgs) } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt index 602740837ac..7b1a8d5f7fb 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt @@ -20,10 +20,7 @@ import org.gradle.api.logging.LogLevel import com.intellij.openapi.util.io.FileUtil import org.jetbrains.kotlin.gradle.plugin.CopyClassesToJavaOutputStatus import org.jetbrains.kotlin.gradle.tasks.USING_INCREMENTAL_COMPILATION_MESSAGE -import org.jetbrains.kotlin.gradle.util.checkBytecodeContains -import org.jetbrains.kotlin.gradle.util.getFileByName -import org.jetbrains.kotlin.gradle.util.getFilesByNames -import org.jetbrains.kotlin.gradle.util.modify +import org.jetbrains.kotlin.gradle.util.* import org.junit.Test import java.io.File import java.util.zip.ZipFile @@ -503,6 +500,27 @@ class KotlinGradleIT: BaseGradleIT() { } } + @Test + fun testIncrementalTestCompile() { + val project = Project("kotlinProject", GRADLE_VERSION) + val options = defaultBuildOptions().copy(incremental = true) + + project.build("build", options = options) { + assertSuccessful() + } + + val joinerKt = project.projectDir.getFileByName("KotlinGreetingJoiner.kt") + joinerKt.modify { + it.replace("class KotlinGreetingJoiner", "internal class KotlinGreetingJoiner") + } + + project.build("build", options = options) { + assertSuccessful() + val testJoinerKt = project.projectDir.getFileByName("TestKotlinGreetingJoiner.kt") + assertCompiledKotlinSources(project.relativize(joinerKt, testJoinerKt)) + } + } + @Test fun testLanguageVersionApiVersionExplicit() { val project = Project("kotlinProject", "3.3") diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/TestRootAffectedIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/TestRootAffectedIT.kt index 04b9d34cfb9..0eab7d30ac5 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/TestRootAffectedIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/TestRootAffectedIT.kt @@ -1,15 +1,13 @@ package org.jetbrains.kotlin.gradle -import org.jetbrains.kotlin.gradle.util.allKotlinFiles import org.jetbrains.kotlin.gradle.util.getFileByName import org.jetbrains.kotlin.gradle.util.modify import org.junit.Test -import java.io.File class TestRootAffectedIT : BaseGradleIT() { @Test fun testSourceRootClassIsModifiedIC() { - val project = Project("kotlinProject", "2.10") + val project = Project("kotlinProject", "4.1") val buildOptions = defaultBuildOptions().copy(incremental = true) project.build("build", options = buildOptions) { @@ -26,8 +24,8 @@ class TestRootAffectedIT : BaseGradleIT() { project.build("build", options = buildOptions) { assertSuccessful() - val expectedToCompile = project.relativize(listOf(kotlinGreetingJoinerFile) + project.allTestKotlinFiles()) - assertCompiledKotlinSources(expectedToCompile) + val testKotlinGreetingJoinerFile = project.projectDir.getFileByName("TestKotlinGreetingJoiner.kt") + assertCompiledKotlinSources(project.relativize(kotlinGreetingJoinerFile, testKotlinGreetingJoinerFile)) } project.build("build", options = buildOptions) { @@ -38,7 +36,8 @@ class TestRootAffectedIT : BaseGradleIT() { @Test fun testSourceRootClassIsRemovedIC() { - val project = Project("kotlinProject", "2.10") + // todo: update Gradle after https://github.com/gradle/gradle/issues/3051 is resolved + val project = Project("kotlinProject", "3.0") val buildOptions = defaultBuildOptions().copy(incremental = true) project.build("build", options = buildOptions) { @@ -48,12 +47,6 @@ class TestRootAffectedIT : BaseGradleIT() { val dummyFile = project.projectDir.getFileByName("Dummy.kt") dummyFile.delete() - project.build("build", options = buildOptions) { - assertSuccessful() - val expectedToCompile = project.relativize(project.allTestKotlinFiles()) - assertCompiledKotlinSources(expectedToCompile) - } - project.build("build", options = buildOptions) { assertSuccessful() assertCompiledKotlinSources(emptyList()) @@ -62,7 +55,7 @@ class TestRootAffectedIT : BaseGradleIT() { @Test fun testTestRootClassIsRemovedIC() { - val project = Project("kotlinProject", "2.10") + val project = Project("kotlinProject", "4.1") val buildOptions = defaultBuildOptions().copy(incremental = true) project.build("build", options = buildOptions) { @@ -76,13 +69,5 @@ class TestRootAffectedIT : BaseGradleIT() { assertSuccessful() assertCompiledKotlinSources(emptyList()) } - - project.build("build", options = buildOptions) { - assertSuccessful() - assertCompiledKotlinSources(emptyList()) - } } - - private fun Project.allTestKotlinFiles(): Iterable = - File(projectDir, "src/test").allKotlinFiles() } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/build.gradle b/libraries/tools/kotlin-gradle-plugin/build.gradle index 3837a8f08be..72bf195c6fd 100644 --- a/libraries/tools/kotlin-gradle-plugin/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin/build.gradle @@ -80,7 +80,7 @@ jar.dependsOn agp25Classes jar { from compileGroovy.destinationDir - from sourceSets.agp25.output.classesDir + from sourceSets.agp25.output.classesDirs manifestAttributes(manifest, project) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleCompilerEnvironment.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleCompilerEnvironment.kt index b37381c5b28..640e6e799f3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleCompilerEnvironment.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleCompilerEnvironment.kt @@ -36,5 +36,7 @@ internal class GradleIncrementalCompilerEnvironment( compilerArgs: CommonCompilerArguments, val kaptAnnotationsFileUpdater: AnnotationFileUpdater? = null, val artifactDifferenceRegistryProvider: ArtifactDifferenceRegistryProvider? = null, - val artifactFile: File? = null + val artifactFile: File? = null, + val buildHistoryFile: File? = null, + val friendBuildHistoryFile: File? = null ) : GradleCompilerEnvironment(compilerClasspath, messageCollector, outputItemsCollector, compilerArgs) \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerRunner.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerRunner.kt index 52f0f88b03d..a117ea566c3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerRunner.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerRunner.kt @@ -255,7 +255,9 @@ internal class GradleCompilerRunner(private val project: Project) : KotlinCompil reportSeverity = reportSeverity(verbose), requestedCompilationResults = arrayOf(CompilationResultCategory.IC_COMPILE_ITERATION.code), compilerMode = CompilerMode.INCREMENTAL_COMPILER, - targetPlatform = targetPlatform + targetPlatform = targetPlatform, + resultDifferenceFile = environment.buildHistoryFile, + friendDifferenceFile = environment.friendBuildHistoryFile ) val servicesFacade = GradleIncrementalCompilerServicesFacadeImpl(project, environment) val argsArray = ArgumentUtils.convertArgumentsToStringList(environment.compilerArgs).toTypedArray() diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt index 140fec2ebc9..8d148fd34b3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt @@ -243,6 +243,7 @@ open class KotlinCompile : AbstractKotlinCompile(), Kotl internal open val sourceRootsContainer = FilteringSourceRootsContainer() private var kaptAnnotationsFileUpdater: AnnotationFileUpdater? = null + val buildHistoryFile: File = File(taskBuildDirectory, "build-history.bin") val kaptOptions = KaptOptions() @@ -316,10 +317,13 @@ open class KotlinCompile : AbstractKotlinCompile(), Kotl !incremental -> GradleCompilerEnvironment(computedCompilerClasspath, messageCollector, outputItemCollector, args) else -> { logger.info(USING_INCREMENTAL_COMPILATION_MESSAGE) + val friendTask = friendTaskName?.let { project.tasks.findByName(it) as? KotlinCompile } GradleIncrementalCompilerEnvironment(computedCompilerClasspath, changedFiles, reporter, taskBuildDirectory, messageCollector, outputItemCollector, args, kaptAnnotationsFileUpdater, artifactDifferenceRegistryProvider, - artifactFile) + artifactFile = artifactFile, + buildHistoryFile = buildHistoryFile, + friendBuildHistoryFile = friendTask?.buildHistoryFile) } } @@ -453,7 +457,7 @@ open class Kotlin2JsCompile() : AbstractKotlinCompile(), args.friendModules = friendDependency - args.sourceMapSourceRoots = source.orEmpty() + args.sourceMapBaseDirs = source.orEmpty() .asSequence() .filterIsInstance() .flatMap { it.srcDirs.asSequence() } diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-plugins/expected.log b/libraries/tools/kotlin-maven-plugin-test/src/it/test-plugins/expected.log index 83cdfeb956f..19e6a306de6 100644 --- a/libraries/tools/kotlin-maven-plugin-test/src/it/test-plugins/expected.log +++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-plugins/expected.log @@ -1,17 +1,9 @@ -[INFO] Kotlin version @snapshot@ (JRE ) -[INFO] Compiling Kotlin sources from [/test-extension/src/main/kotlin] -[INFO] Module name is test-extension [WARNING] Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath or use '-Xskip-runtime-version-check' to suppress this warning [WARNING] /local-repo/org/jetbrains/kotlin/kotlin-compiler/@snapshot@/kotlin-compiler-@snapshot@.jar: (-1, -1) Library has Kotlin runtime bundled into it -[INFO] Kotlin version @snapshot@ (JRE ) [WARNING] No sources found skipping Kotlin compile -[INFO] Kotlin version @snapshot@ (JRE ) -[INFO] Compiling Kotlin sources from [/use-test-extension/src/main/kotlin] -[INFO] Module name is use-test-extension [INFO] Applicability test for project use-test-extension [INFO] Applied plugin: 'test-me' [INFO] Configuring test plugin with arguments [INFO] Plugin applied [INFO] Option value: my-special-value -[INFO] Kotlin version @snapshot@ (JRE ) [WARNING] No sources found skipping Kotlin compile diff --git a/libraries/tools/kotlin-maven-plugin/src/it/simple/expected.log b/libraries/tools/kotlin-maven-plugin/src/it/simple/expected.log index 6d4adc457b4..e69de29bb2d 100644 --- a/libraries/tools/kotlin-maven-plugin/src/it/simple/expected.log +++ b/libraries/tools/kotlin-maven-plugin/src/it/simple/expected.log @@ -1,3 +0,0 @@ -[INFO] Kotlin version @snapshot@ (JRE ) -[INFO] Compiling Kotlin sources from [/src/main/kotlin] -[INFO] Module name is test-project diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java index 74377f8868b..cc4106e5ed7 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java @@ -131,7 +131,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase getClassPathElements() throws DependencyResolutionRequiredException { diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JVMCompileMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JVMCompileMojo.java index 92ca920600f..70c36bfe071 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JVMCompileMojo.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JVMCompileMojo.java @@ -168,7 +168,7 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase e @Override public void execute() throws MojoExecutionException, MojoFailureException { - getLog().info("Kotlin version " + KotlinCompilerVersion.VERSION + + getLog().debug("Kotlin version " + KotlinCompilerVersion.VERSION + " (JRE " + System.getProperty("java.runtime.version") + ")"); if (!hasKotlinFilesInSources()) { @@ -433,7 +433,7 @@ public abstract class KotlinCompileMojoBase e if (sourceRoots.isEmpty()) { throw new MojoExecutionException("No source roots to compile"); } - getLog().info("Compiling Kotlin sources from " + sourceRoots); + getLog().debug("Compiling Kotlin sources from " + sourceRoots); return sourceRoots; } diff --git a/plugins/android-extensions/android-extensions-idea/build.gradle.kts b/plugins/android-extensions/android-extensions-idea/build.gradle.kts index 11e7316c18c..6fe3c03f88a 100644 --- a/plugins/android-extensions/android-extensions-idea/build.gradle.kts +++ b/plugins/android-extensions/android-extensions-idea/build.gradle.kts @@ -50,6 +50,7 @@ sourceSets { testsJar {} projectTest { + dependsOn(":kotlin-android-extensions-runtime:dist") workingDir = rootDir } diff --git a/plugins/android-extensions/android-extensions-runtime/build.gradle.kts b/plugins/android-extensions/android-extensions-runtime/build.gradle.kts index 3748e356835..dec72c91f65 100644 --- a/plugins/android-extensions/android-extensions-runtime/build.gradle.kts +++ b/plugins/android-extensions/android-extensions-runtime/build.gradle.kts @@ -18,4 +18,6 @@ runtimeJar() sourcesJar() javadocJar() +dist(targetName = "android-extensions-runtime.jar") + publish() diff --git a/plugins/plugins-tests/build.gradle.kts b/plugins/plugins-tests/build.gradle.kts index c25f38d5bb0..b62938c7aa1 100644 --- a/plugins/plugins-tests/build.gradle.kts +++ b/plugins/plugins-tests/build.gradle.kts @@ -38,7 +38,10 @@ sourceSets { testsJar {} +evaluationDependsOn(":kotlin-android-extensions-runtime") + projectTest { + environment("ANDROID_EXTENSIONS_RUNTIME_CLASSES", getSourceSetsFrom(":kotlin-android-extensions-runtime")["main"].output.classesDirs.asPath) dependsOnTaskIfExistsRec("dist", project = rootProject) workingDir = rootDir } diff --git a/plugins/plugins-tests/tests/org/jetbrains/kotlin/android/parcel/AbstractParcelBoxTest.kt b/plugins/plugins-tests/tests/org/jetbrains/kotlin/android/parcel/AbstractParcelBoxTest.kt index 50b754fee4b..0b5b15e3cc3 100644 --- a/plugins/plugins-tests/tests/org/jetbrains/kotlin/android/parcel/AbstractParcelBoxTest.kt +++ b/plugins/plugins-tests/tests/org/jetbrains/kotlin/android/parcel/AbstractParcelBoxTest.kt @@ -117,9 +117,12 @@ abstract class AbstractParcelBoxTest : CodegenTestCase() { val junitCoreResourceName = JUnitCore::class.java.name.replace('.', '/') + ".class" val junitJar = File(JUnitCore::class.java.classLoader.getResource(junitCoreResourceName).file.substringBeforeLast('!')) - val androidExtensionsRuntime = File("out/production/android-extensions-runtime") + val androidExtensionsRuntimeCP = + (System.getenv("ANDROID_EXTENSIONS_RUNTIME_CLASSES")?.split(File.pathSeparator) + ?: listOf("out/production/android-extensions-runtime") + ).map { File(it) } - return listOf(kotlinRuntimeJar) + layoutLibJars + robolectricJars + junitJar + androidExtensionsRuntime + return listOf(kotlinRuntimeJar) + layoutLibJars + robolectricJars + junitJar + androidExtensionsRuntimeCP } override fun doMultiFileTest(wholeFile: File, files: List, javaFilesDir: File?) { diff --git a/prepare/compiler/build.gradle.kts b/prepare/compiler/build.gradle.kts index edc9081039a..0c2df80e723 100644 --- a/prepare/compiler/build.gradle.kts +++ b/prepare/compiler/build.gradle.kts @@ -21,8 +21,11 @@ plugins { `java` } -// Set to false to disable proguard run on kotlin-compiler.jar. Speeds up the build -val shrink = true +// You can run Gradle with "-Pkotlin.build.proguard=true" to enable ProGuard run on kotlin-compiler.jar (on TeamCity, ProGuard always runs) +val shrink = + findProperty("kotlin.build.proguard")?.toString()?.toBoolean() + ?: hasProperty("teamcity") + val compilerManifestClassPath = "kotlin-stdlib.jar kotlin-reflect.jar kotlin-script-runtime.jar" @@ -64,7 +67,6 @@ dependencies { fatJarContents(commonDep("org.jline", "jline")) fatJarContents(commonDep("org.fusesource.jansi", "jansi")) fatJarContents(protobufFull()) - fatJarContents(commonDep("com.github.spullara.cli-parser", "cli-parser")) fatJarContents(commonDep("com.google.code.findbugs", "jsr305")) fatJarContents(commonDep("io.javaslang", "javaslang")) fatJarContents(preloadedDeps("json-org")) @@ -121,11 +123,12 @@ noDefaultJar() cleanArtifacts() -dist(targetName = compilerBaseName + ".jar", - fromTask = if (shrink) proguard - else packCompiler) +val pack = if (shrink) proguard else packCompiler -runtimeJarArtifactBy(proguard, proguard.outputs.files.singleFile) { +dist(targetName = compilerBaseName + ".jar", + fromTask = pack) + +runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) { name = compilerBaseName classifier = "" } diff --git a/prepare/idea-plugin/build.gradle.kts b/prepare/idea-plugin/build.gradle.kts index f5353ba9adb..60c924fa85d 100644 --- a/prepare/idea-plugin/build.gradle.kts +++ b/prepare/idea-plugin/build.gradle.kts @@ -77,7 +77,6 @@ val packedJars by configurations.creating val sideJars by configurations.creating dependencies { - packedJars(commonDep("com.github.spullara.cli-parser", "cli-parser")) packedJars(preloadedDeps("protobuf-${rootProject.extra["versions.protobuf-java"]}")) packedJars(project(":kotlin-stdlib", configuration = "builtins")) sideJars(projectDist(":kotlin-script-runtime")) @@ -95,6 +94,7 @@ val jar = runtimeJar(task("shadowJar")) { dependsOn("$p:classes") from(getSourceSetsFrom(p)["main"].output) } + archiveName = "kotlin-plugin.jar" } ideaPlugin { diff --git a/settings.gradle b/settings.gradle index 492db255b21..f91b6cd22a5 100644 --- a/settings.gradle +++ b/settings.gradle @@ -131,6 +131,7 @@ include ":kotlin-build-common", ":examples:kotlin-jsr223-daemon-local-eval-example", ":ultimate", ":ultimate:ultimate-runner", + ":kotlin-annotations-jvm", // plugin markers: ':kotlin-gradle-plugin:plugin-marker', @@ -199,6 +200,7 @@ project(':kotlin-annotation-processing-gradle').projectDir = "$rootDir/libraries project(':kotlin-annotation-processing').projectDir = "$rootDir/plugins/kapt3" as File project(':examples:kotlin-jsr223-local-example').projectDir = "$rootDir/libraries/examples/kotlin-jsr223-local-example" as File project(':examples:kotlin-jsr223-daemon-local-eval-example').projectDir = "$rootDir/libraries/examples/kotlin-jsr223-daemon-local-eval-example" as File +project(':kotlin-annotations-jvm').projectDir = "$rootDir/libraries/tools/kotlin-annotations-jvm" as File // plugin markers: project(':kotlin-gradle-plugin:plugin-marker').projectDir = file("$rootDir/libraries/tools/kotlin-gradle-plugin/plugin-marker") diff --git a/ultimate/build.gradle.kts b/ultimate/build.gradle.kts index e3f9e5fa4a3..bcb5fc03e8c 100644 --- a/ultimate/build.gradle.kts +++ b/ultimate/build.gradle.kts @@ -16,8 +16,6 @@ buildscript { apply { plugin("kotlin") } -val ideaCommunityPlugin by configurations.creating - val ideaProjectResources = project(":idea").the().sourceSets["main"].output.resourcesDir evaluationDependsOn(":prepare:idea-plugin") @@ -40,7 +38,6 @@ dependencies { compile(ideaUltimatePreloadedDeps("*.jar", subdir = "nodejs_plugin/NodeJS/lib")) compile(ideaUltimateSdkCoreDeps("annotations", "trove4j", "intellij-core")) compile(ideaUltimateSdkDeps("openapi", "idea", "util")) -// compile(ideaUltimatePluginDeps("gradle-tooling-api", plugin = "gradle")) compile(ideaUltimatePluginDeps("*.jar", plugin = "CSS")) compile(ideaUltimatePluginDeps("*.jar", plugin = "DatabaseTools")) compile(ideaUltimatePluginDeps("*.jar", plugin = "JavaEE")) @@ -63,7 +60,6 @@ dependencies { testCompile(project(":idea:idea-jvm")) { isTransitive = false } testCompile(project(":generators")) { isTransitive = false } testCompile(projectTests(":idea")) -// testCompileOnly(projectTests(":idea:idea-gradle")) testCompile(commonDep("junit:junit")) testCompile(ideaUltimateSdkDeps("gson")) testCompile(preloadedDeps("kotlinx-coroutines-core")) @@ -94,8 +90,6 @@ dependencies { testRuntime(ideaUltimatePluginDeps("*.jar", plugin = "copyright")) testRuntime(ideaUltimatePluginDeps("*.jar", plugin = "java-decompiler")) testRuntime(files("${System.getProperty("java.home")}/../lib/tools.jar")) - - ideaCommunityPlugin(projectRuntimeJar(":prepare:idea-plugin")) } val preparedResources = File(buildDir, "prepResources") @@ -133,14 +127,14 @@ val preparePluginXml by task { } } +val communityPluginProject = ":prepare:idea-plugin" + val jar = runtimeJar(task("shadowJar")) { duplicatesStrategy = DuplicatesStrategy.EXCLUDE dependsOn(preparePluginXml) - project(":prepare:idea-plugin").afterEvaluate { - ideaCommunityPlugin.files.forEach { - from(zipTree(it), { exclude("META-INF/plugin.xml") }) - } - } + dependsOn("$communityPluginProject:shadowJar") + val communityPluginJar = project(communityPluginProject).configurations["runtimeJar"].artifacts.files.singleFile + from(zipTree(communityPluginJar), { exclude("META-INF/plugin.xml") }) from(preparedResources, { include("META-INF/plugin.xml") }) from(the().sourceSets.getByName("main").output) archiveName = "kotlin-plugin.jar" @@ -150,7 +144,8 @@ val ideaPluginDir: File by rootProject.extra val ideaUltimatePluginDir: File by rootProject.extra task("ideaUltimatePlugin") { - dependsOnTaskIfExistsRec("idea-plugin", rootProject) + dependsOn("$communityPluginProject:ideaPlugin") + dependsOnTaskIfExistsRec("ideaPlugin", rootProject) into(ideaUltimatePluginDir) from(ideaPluginDir) { exclude("lib/kotlin-plugin.jar") } from(jar, { into("lib") }) diff --git a/update_dependencies.xml b/update_dependencies.xml index 2320da3266f..5db4d4ea680 100644 --- a/update_dependencies.xml +++ b/update_dependencies.xml @@ -109,7 +109,7 @@ - +