[kotlin] Fixed tests to work with Kotlin 2.1

KTIJ-32943

GitOrigin-RevId: 41af496b58fb5b77fe2cb301fc0a145557fba0f8
This commit is contained in:
Frederik Haselmeier
2025-02-21 13:41:41 +00:00
committed by intellij-monorepo-bot
parent 7ff7bebc44
commit d8336f6b22
86 changed files with 170 additions and 51 deletions
@@ -38,5 +38,6 @@
<orderEntry type="module" module-name="intellij.java.tests" scope="TEST" />
<orderEntry type="module" module-name="kotlin.idea" scope="TEST" />
<orderEntry type="module" module-name="kotlin.base.compiler-configuration" scope="TEST" />
<orderEntry type="module" module-name="kotlin.test-framework" scope="TEST" />
</component>
</module>
@@ -6,7 +6,10 @@ import com.intellij.java.compiler.CompilerReferencesTestBase
import com.intellij.psi.CommonClassNames
import com.intellij.psi.util.descendantsOfType
import com.intellij.testFramework.SkipSlowTestLocally
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder
import org.jetbrains.kotlin.idea.base.plugin.KotlinPluginMode
import org.jetbrains.kotlin.idea.base.plugin.artifacts.KotlinArtifactNames
import org.jetbrains.kotlin.idea.base.plugin.artifacts.TestKotlinArtifacts
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
import org.jetbrains.kotlin.psi.KtClass
@@ -26,6 +29,17 @@ open class KotlinCompilerRefHelperTest : CompilerReferencesTestBase(), ExpectedP
}
}
override fun tuneFixture(moduleBuilder: JavaModuleFixtureBuilder<*>) {
super.tuneFixture(moduleBuilder)
if (pluginMode == KotlinPluginMode.K2) {
moduleBuilder.addLibrary(KotlinArtifactNames.KOTLIN_STDLIB, TestKotlinArtifacts.kotlinStdlib.path)
} else {
// For the K1 tests we want to use a Kotlin 1.x library because Kotlin 2 libraries might not be able to
// be consumed by the K1 compiler.
moduleBuilder.addMavenLibrary(JavaModuleFixtureBuilder.MavenLib("org.jetbrains.kotlin:kotlin-stdlib:1.9.25"))
}
}
fun `test dirty scope`() {
installCompiler()
val javaFile = myFixture.addFileToProject(
@@ -3,6 +3,7 @@ package org.jetbrains.kotlin.idea.search.refIndex
import com.intellij.openapi.module.JavaModuleType
import com.intellij.openapi.module.Module
import com.intellij.openapi.roots.ModuleRootManager
import com.intellij.openapi.roots.ModuleRootModificationUtil
import com.intellij.pom.java.LanguageLevel
import com.intellij.psi.CommonClassNames
@@ -11,6 +12,7 @@ import com.intellij.testFramework.IdeaTestUtil
import com.intellij.testFramework.PsiTestUtil
import com.intellij.testFramework.SkipSlowTestLocally
import org.jetbrains.kotlin.idea.base.plugin.KotlinPluginMode
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil
@SkipSlowTestLocally
open class KotlinCompilerReferenceMultiModuleTest : KotlinCompilerReferenceTestBase() {
@@ -138,6 +140,11 @@ open class KotlinCompilerReferenceMultiModuleTest : KotlinCompilerReferenceTestB
private fun createModule(moduleName: String): Module {
val moduleDir = myFixture.tempDirFixture.findOrCreateDir(moduleName)
val module = PsiTestUtil.addModule(project, JavaModuleType.getModuleType(), moduleName, moduleDir)
ModuleRootManager.getInstance(module)!!.modifiableModel.apply {
if (withK2Compiler) {
ConfigLibraryUtil.configureKotlinRuntime(module)
}
}
IdeaTestUtil.setModuleLanguageLevel(module, LanguageLevel.JDK_11)
return module
}
@@ -0,0 +1,9 @@
{
"mainFile": "Foo.kt",
"usages": [
"Doo.kt",
"Foo.kt",
"JavaClass.java",
"Main.kt"
]
}
@@ -32,10 +32,10 @@ abstract class X : java.util.ArrayList<String>(), Runnable {
// MEMBER_K1: "add(index: Int, element: String): Unit"
// MEMBER_K1: "addAll(elements: Collection<String>): Boolean"
// MEMBER_K1: "addAll(index: Int, elements: Collection<String>): Boolean"
// MEMBER_K1: "remove(element: String): Boolean"
// MEMBER_K1: "removeAll(elements: Collection<String>): Boolean"
// MEMBER_K1: "retainAll(elements: Collection<String>): Boolean"
// MEMBER_K1: "contains(element: String): Boolean"
// MEMBER_K1: "remove(element: String!): Boolean"
// MEMBER_K1: "removeAll(elements: Collection<String!>): Boolean"
// MEMBER_K1: "retainAll(elements: Collection<String!>): Boolean"
// MEMBER_K1: "contains(element: String!): Boolean"
// MEMBER_K1: "containsAll(elements: Collection<String!>): Boolean"
// MEMBER_K1: "forEach(p0: Consumer<in String!>!): Unit"
// MEMBER_K1: "spliterator(): Spliterator<String!>"
@@ -49,8 +49,8 @@ abstract class X : java.util.ArrayList<String>(), Runnable {
// MEMBER_K1: "set(index: Int, element: String): String"
// MEMBER_K1: "subList(fromIndex: Int, toIndex: Int): MutableList<String>"
// MEMBER_K1: "get(index: Int): String"
// MEMBER_K1: "indexOf(element: String): Int"
// MEMBER_K1: "lastIndexOf(element: String): Int"
// MEMBER_K1: "indexOf(element: String!): Int"
// MEMBER_K1: "lastIndexOf(element: String!): Int"
// MEMBER_K1: "sort(p0: Comparator<in String!>!): Unit"
// MEMBER: "clear(): Unit"
@@ -34,10 +34,10 @@ abstract class X : java.util.ArrayList<String>(), Runnable {
// MEMBER_K1: "add(index: Int, element: String): Unit"
// MEMBER_K1: "addAll(elements: Collection<String>): Boolean"
// MEMBER_K1: "addAll(index: Int, elements: Collection<String>): Boolean"
// MEMBER_K1: "remove(element: String): Boolean"
// MEMBER_K1: "removeAll(elements: Collection<String>): Boolean"
// MEMBER_K1: "retainAll(elements: Collection<String>): Boolean"
// MEMBER_K1: "contains(element: String): Boolean"
// MEMBER_K1: "remove(element: String!): Boolean"
// MEMBER_K1: "removeAll(elements: Collection<String!>): Boolean"
// MEMBER_K1: "retainAll(elements: Collection<String!>): Boolean"
// MEMBER_K1: "contains(element: String!): Boolean"
// MEMBER_K1: "containsAll(elements: Collection<String!>): Boolean"
// MEMBER_K1: "forEach(p0: Consumer<in String!>!): Unit"
// MEMBER_K1: "spliterator(): Spliterator<String!>"
@@ -51,8 +51,8 @@ abstract class X : java.util.ArrayList<String>(), Runnable {
// MEMBER_K1: "set(index: Int, element: String): String"
// MEMBER_K1: "subList(fromIndex: Int, toIndex: Int): MutableList<String>"
// MEMBER_K1: "get(index: Int): String"
// MEMBER_K1: "indexOf(element: String): Int"
// MEMBER_K1: "lastIndexOf(element: String): Int"
// MEMBER_K1: "indexOf(element: String!): Int"
// MEMBER_K1: "lastIndexOf(element: String!): Int"
// MEMBER_K1: "sort(p0: Comparator<in String!>!): Unit"
// MEMBER: "clear(): Unit"
@@ -3,7 +3,7 @@
val nullableString: String? = "abc"
val foo = if (<caret>nullableString != null) {
nullableString.toUpperCase()
nullableString.uppercase()
} else {
""
}
@@ -2,4 +2,4 @@
val nullableString: String? = "abc"
val foo = nullableString?.toUpperCase() ?: ""
val foo = nullableString?.uppercase() ?: ""
@@ -3,7 +3,7 @@
val nullableString: String? = "abc"
val foo = if (<caret>nullableString != null) {
nullableString.toUpperCase().toLowerCase()
nullableString.uppercase().lowercase()
} else {
""
}
@@ -2,4 +2,4 @@
val nullableString: String? = "abc"
val foo = nullableString?.toUpperCase()?.toLowerCase() ?: ""
val foo = nullableString?.uppercase()?.lowercase() ?: ""
@@ -3,7 +3,7 @@
val nullableString: String? = "abc"
val foo = <caret>if (nullableString != null) {
nullableString.toUpperCase().toLowerCase()
nullableString.uppercase().lowercase()
} else {
null
}
@@ -2,4 +2,4 @@
val nullableString: String? = "abc"
val foo = nullableString?.toUpperCase()?.toLowerCase()
val foo = nullableString?.uppercase()?.lowercase()
@@ -8,4 +8,3 @@ enum class EnumClass {
}
}
// IGNORE_K2
@@ -7,5 +7,3 @@ enum class EnumClass {
val v = entries.toTypedArray()
}
}
// IGNORE_K2
@@ -8,4 +8,3 @@ enum class EnumClass {
}
}
// IGNORE_K2
@@ -7,5 +7,3 @@ enum class EnumClass {
for (e in entries) {}
}
}
// IGNORE_K2
@@ -9,4 +9,3 @@ enum class EnumClass {
}
}
// IGNORE_K2
@@ -8,5 +8,3 @@ enum class EnumClass {
entries.forEach {}
}
}
// IGNORE_K2
@@ -19,4 +19,6 @@ fun main() {
implicitOut { AImpl() }
use { it.foo }
}
}
}
// IGNORE_K2
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun String.test(s: String): Boolean {
return <caret>toLowerCase() == s.toLowerCase()
}
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun String.test(s: String): Boolean {
return equals(s, ignoreCase = true)
}
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun String.test(s: String): Boolean {
return <caret>s.toLowerCase() == toLowerCase()
}
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun String.test(s: String): Boolean {
return s.equals(this, ignoreCase = true)
}
@@ -1,5 +1,7 @@
// PROBLEM: none
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun test(a: String, b: String): Boolean {
return <caret>a.toLowerCase() != b.toLowerCase()
}
@@ -1,5 +1,6 @@
// PROBLEM: none
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun test(a: String, b: String): Boolean {
return <caret>a == b.toLowerCase()
}
@@ -1,5 +1,6 @@
// PROBLEM: none
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun test(a: String, b: String): Boolean {
return <caret>a.toLowerCase() == b
}
@@ -1,5 +1,7 @@
// PROBLEM: none
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toUpperCase(): String' is an error. Use uppercase() instead.
fun test(a: String, b: String): Boolean {
return <caret>a.toLowerCase() == b.toUpperCase()
}
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun test(a: String?, b: String): Boolean {
return <caret>a?.toLowerCase() == b.toLowerCase()
}
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun test(a: String?, b: String): Boolean {
return a.equals(b, ignoreCase = true)
}
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun test(a: String, b: String?): Boolean {
return <caret>a.toLowerCase() == b?.toLowerCase()
}
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun test(a: String, b: String?): Boolean {
return a.equals(b, ignoreCase = true)
}
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun test(a: String?, b: String?): Boolean {
return <caret>a?.toLowerCase() == b?.toLowerCase()
}
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun test(a: String?, b: String?): Boolean {
return a.equals(b, ignoreCase = true)
}
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun test(a: String, b: String): Boolean {
return <caret>a.toLowerCase() == b.toLowerCase()
}
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
// ERROR: Using 'toLowerCase(): String' is an error. Use lowercase() instead.
fun test(a: String, b: String): Boolean {
return a.equals(b, ignoreCase = true)
}
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toUpperCase(): String' is an error. Use uppercase() instead.
// ERROR: Using 'toUpperCase(): String' is an error. Use uppercase() instead.
fun test(a: String, b: String): Boolean {
return <caret>a.toUpperCase() == b.toUpperCase()
}
@@ -1,4 +1,6 @@
// WITH_STDLIB
// ERROR: Using 'toUpperCase(): String' is an error. Use uppercase() instead.
// ERROR: Using 'toUpperCase(): String' is an error. Use uppercase() instead.
fun test(a: String, b: String): Boolean {
return a.equals(b, ignoreCase = true)
}
@@ -1,6 +1,5 @@
// PROBLEM: none
// WITH_STDLIB
// ERROR: Unresolved reference: SubclassOptInRequired
@file:OptIn(UnstableApiA::class, UnstableApiB::class, ExperimentalSubclassOptIn::class)
@@ -6,7 +6,6 @@
// ERROR: This annotation is not repeatable
// ERROR: This annotation is not repeatable
// ERROR: This annotation is not repeatable
// ERROR: Unresolved reference: SubclassOptInRequired
@file:OptIn(ExperimentalSubclassOptIn::class)
@@ -1,4 +1,5 @@
// PROBLEM: none
// K2_ERROR: Cannot use typealias 'Other' as a callable qualifier in import. Use original class 'MyEnum' instead or rewrite calls with 'Other' as a qualifier. See https://youtrack.jetbrains.com/issue/KT-64431.
import Other.HELLO
@@ -1,7 +1,7 @@
// "Add non-null asserted (toLowerCase()!!) call" "true"
// "Add non-null asserted (lowercase()!!) call" "true"
// WITH_STDLIB
fun String?.foo() {
<caret>toLowerCase()
<caret>lowercase()
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix
@@ -1,7 +1,7 @@
// "Add non-null asserted (toLowerCase()!!) call" "true"
// "Add non-null asserted (lowercase()!!) call" "true"
// WITH_STDLIB
fun String?.foo() {
this!!.toLowerCase()
this!!.lowercase()
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Add non-null asserted (this!!) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
// WITH_STDLIB
package p;
@@ -40,6 +41,7 @@ public class Foo {
// FILE: test.after.kt
// "Add non-null asserted (this!!) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
// WITH_STDLIB
package p;
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Add non-null asserted (x.foo()!!) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?
package p;
fun test(x: Foo) {
@@ -30,6 +31,7 @@ public class Foo {
// FILE: test.after.kt
// "Add non-null asserted (x.foo()!!) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?
package p;
fun test(x: Foo) {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Add non-null asserted (y!!) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
package p;
fun test(x: Foo) {
@@ -38,6 +39,7 @@ public class Foo {
// FILE: test.after.kt
// "Add non-null asserted (y!!) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
package p;
fun test(x: Foo) {
@@ -1,5 +1,7 @@
// FILE: test.before.kt
// "Add non-null asserted (y!!) call" "true"
// ERROR: Reference has a nullable type 'A?', use explicit '?.invoke()' to make a function-like call instead
// IGNORE_K1
package p;
fun test(x: Foo) {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Add non-null asserted (x.value!!) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?
package p;
fun test(x: Foo) {
@@ -42,6 +43,7 @@ public class Foo {
// FILE: test.after.kt
// "Add non-null asserted (x.value!!) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?
package p;
fun test(x: Foo) {
@@ -1,6 +1,7 @@
// FILE: test.before.kt
// "Add non-null asserted (bar()!!) call" "true"
// WITH_STDLIB
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
package p;
fun test(x: Foo) {
@@ -41,6 +42,7 @@ public class Foo {
// FILE: test.after.kt
// "Add non-null asserted (bar()!!) call" "true"
// WITH_STDLIB
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
package p;
fun test(x: Foo) {
@@ -2,7 +2,7 @@
// WITH_STDLIB
fun foo(a: String?) {
a<caret>.toLowerCase()
a<caret>.lowercase()
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix
@@ -2,7 +2,7 @@
// WITH_STDLIB
fun foo(a: String?) {
a!!.toLowerCase()
a!!.lowercase()
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Add 'Any' as upper bound for T" "true"
// ERROR: Type argument is not within its bounds: should be subtype of 'Any'
package p;
class Derived<T> : Base<<caret>T>() {}
@@ -30,6 +31,7 @@ public class Base<T> {}
// FILE: test.after.kt
// "Add 'Any' as upper bound for T" "true"
// ERROR: Type argument is not within its bounds: should be subtype of 'Any'
package p;
class Derived<T : Any> : Base<<caret>T>() {}
@@ -1,5 +1,8 @@
// "Fix 'kotlin.browser' package usage" "true"
// JS_WITH_DOM_API_COMPAT
// This test broke with the Update to Kotlin 2.1.10
// We do not update these tests because they are only for K1 and for a legacy inspection
// IGNORE_K1
package test
@@ -1,5 +1,8 @@
// "Fix 'kotlin.browser' package usage" "true"
// JS_WITH_DOM_API_COMPAT
// This test broke with the Update to Kotlin 2.1.10
// We do not update these tests because they are only for K1 and for a legacy inspection
// IGNORE_K1
package test
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Change function signature to 'fun foo(x: String): String'" "true"
// ERROR: 'foo' overrides nothing
package p;
class Bar : Foo() {
@@ -50,6 +51,7 @@ public class Foo {
// FILE: test.after.kt
// "Change function signature to 'fun foo(x: String): String'" "true"
// ERROR: 'foo' overrides nothing
package p;
class Bar : Foo() {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Change function signature to 'fun foo(x: String?): String'" "true"
// ERROR: 'foo' overrides nothing
package p;
class Bar : Foo() {
@@ -50,6 +51,7 @@ public class Foo {
// FILE: test.after.kt
// "Change function signature to 'fun foo(x: String?): String'" "true"
// ERROR: 'foo' overrides nothing
package p;
class Bar : Foo() {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Change function signature to 'fun foo(x: String): String'" "true"
// "Change return type to 'String'" "true"
// ERROR: Return type of 'foo' is not a subtype of the return type of the overridden member 'public open fun foo(x: String): String defined in p.Foo'
package p;
class Bar : Foo() {
@@ -49,7 +50,8 @@ public class Foo {
}
// FILE: test.after.kt
// "Change function signature to 'fun foo(x: String): String'" "true"
// "Change return type to 'String'" "true"
// ERROR: Return type of 'foo' is not a subtype of the return type of the overridden member 'public open fun foo(x: String): String defined in p.Foo'
package p;
class Bar : Foo() {
@@ -1,7 +1,7 @@
// "Replace with dot call" "true"
// WITH_STDLIB
fun foo(a: String) {
a<caret>?.toLowerCase()
a<caret>?.lowercase()
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ReplaceWithDotCallFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ReplaceWithDotCallFix
@@ -1,7 +1,7 @@
// "Replace with dot call" "true"
// WITH_STDLIB
fun foo(a: String) {
a.toLowerCase()
a.lowercase()
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ReplaceWithDotCallFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ReplaceWithDotCallFix
@@ -2,7 +2,7 @@
// WITH_STDLIB
fun foo(a: String?) {
a.apply {
<caret>toLowerCase()
<caret>lowercase()
}
}
// IGNORE_K2
@@ -2,7 +2,7 @@
// WITH_STDLIB
fun foo(a: String?) {
a.apply {
this?.toLowerCase()
this?.lowercase()
}
}
// IGNORE_K2
@@ -1,7 +1,7 @@
// "Replace with safe (this?.) call" "true"
// WITH_STDLIB
fun String?.foo() {
<caret>toLowerCase()
<caret>lowercase()
}
// IGNORE_K2
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ReplaceImplicitReceiverCallFix
@@ -1,7 +1,7 @@
// "Replace with safe (this?.) call" "true"
// WITH_STDLIB
fun String?.foo() {
this?.toLowerCase()
this?.lowercase()
}
// IGNORE_K2
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ReplaceImplicitReceiverCallFix
@@ -1,7 +1,7 @@
// "Replace with safe (?.) call" "true"
// WITH_STDLIB
fun foo(a: String?) {
a<caret>.toLowerCase()
a<caret>.lowercase()
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ReplaceWithSafeCallFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ReplaceWithSafeCallFix
@@ -1,7 +1,7 @@
// "Replace with safe (?.) call" "true"
// WITH_STDLIB
fun foo(a: String?) {
a?.toLowerCase()
a?.lowercase()
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ReplaceWithSafeCallFix
// FUS_K2_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ReplaceWithSafeCallFix
@@ -1,6 +1,7 @@
// FILE: test.before.kt
// "Replace with safe (this?.) call" "true"
// WITH_STDLIB
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
package p;
fun test(x: Foo) {
@@ -41,6 +42,7 @@ public class Foo {
// FILE: test.after.kt
// "Replace with safe (this?.) call" "true"
// WITH_STDLIB
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
package p;
fun test(x: Foo) {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Replace with safe (?.) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?
package p;
fun test(x: Foo) {
@@ -30,6 +31,7 @@ public class Foo {
// FILE: test.after.kt
// "Replace with safe (?.) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?
package p;
fun test(x: Foo) {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Replace with safe (?.) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
package p;
fun test(x: Foo) {
@@ -38,6 +39,7 @@ public class Foo {
// FILE: test.after.kt
// "Replace with safe (?.) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
package p;
fun test(x: Foo) {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Replace with safe (?.) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Foo?
package p;
fun test(x: Foo) {
@@ -31,6 +32,7 @@ public class Foo {
// FILE: test.after.kt
// "Replace with safe (?.) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Foo?
package p;
fun test(x: Foo) {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Replace with safe (?.) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Foo?
package p;
fun test(x: Foo) {
@@ -32,6 +33,7 @@ public class Foo {
// FILE: test.after.kt
// "Replace with safe (?.) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Foo?
package p;
fun test(x: Foo) {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Replace with safe (?.) call" "true"
// ERROR: Operator call corresponds to a dot-qualified call 'y.plus(y)' which is not allowed on a nullable receiver 'y'.
package p;
fun test(x: Foo) {
@@ -32,6 +33,7 @@ public class Foo {
// FILE: test.after.kt
// "Replace with safe (?.) call" "true"
// ERROR: Operator call corresponds to a dot-qualified call 'y.plus(y)' which is not allowed on a nullable receiver 'y'.
package p;
fun test(x: Foo) {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Replace with safe (?.) call" "true"
// ERROR: Reference has a nullable type 'Foo?', use explicit '?.invoke()' to make a function-like call instead
package p;
fun test(x: Foo) {
@@ -32,6 +33,7 @@ public class Foo {
// FILE: test.after.kt
// "Replace with safe (?.) call" "true"
// ERROR: Reference has a nullable type 'Foo?', use explicit '?.invoke()' to make a function-like call instead
package p;
fun test(x: Foo) {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Replace with safe (?.) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?
package p;
fun test(x: Foo) {
@@ -42,6 +43,7 @@ public class Foo {
// FILE: test.after.kt
// "Replace with safe (?.) call" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?
package p;
fun test(x: Foo) {
@@ -1,6 +1,7 @@
// FILE: test.before.kt
// "Replace with safe (?.) call" "true"
// WITH_STDLIB
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
package p;
fun test(x: Foo) {
@@ -41,6 +42,7 @@ public class Foo {
// FILE: test.after.kt
// "Replace with safe (?.) call" "true"
// WITH_STDLIB
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
package p;
fun test(x: Foo) {
@@ -2,7 +2,7 @@
// WITH_STDLIB
fun foo(a: String?) {
a.apply {
<caret>toLowerCase()
<caret>lowercase()
}
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ReplaceWithSafeCallForScopeFunctionFix
@@ -2,7 +2,7 @@
// WITH_STDLIB
fun foo(a: String?) {
a?.apply {
toLowerCase()
lowercase()
}
}
// FUS_QUICKFIX_NAME: org.jetbrains.kotlin.idea.quickfix.ReplaceWithSafeCallForScopeFunctionFix
@@ -1,6 +1,7 @@
// FILE: test.before.kt
// "Replace scope function with safe (?.) call" "true"
// WITH_STDLIB
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Foo?
package p;
fun test(x: Foo) {
@@ -35,6 +36,7 @@ public class Foo {
// FILE: test.after.kt
// "Replace scope function with safe (?.) call" "true"
// WITH_STDLIB
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Foo?
package p;
fun test(x: Foo) {
@@ -1,6 +1,7 @@
// FILE: test.before.kt
// "Replace scope function with safe (?.) call" "true"
// WITH_STDLIB
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Foo?
package p;
fun test(x: Foo) {
@@ -35,6 +36,7 @@ public class Foo {
// FILE: test.after.kt
// "Replace scope function with safe (?.) call" "true"
// WITH_STDLIB
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Foo?
package p;
fun test(x: Foo) {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Surround with null check" "true"
// ERROR: Type mismatch: inferred type is A? but A was expected
package p;
fun f(x: A) {}
@@ -40,6 +41,7 @@ public class Foo {
// FILE: test.after.kt
// "Surround with null check" "true"
// ERROR: Type mismatch: inferred type is A? but A was expected
package p;
fun f(x: A) {}
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Surround with null check" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
package p;
fun test(x: Foo) {
@@ -38,6 +39,7 @@ public class Foo {
// FILE: test.after.kt
// "Surround with null check" "true"
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type A?
package p;
fun test(x: Foo) {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Surround with null check" "true"
// ERROR: Reference has a nullable type 'A?', use explicit '?.invoke()' to make a function-like call instead
package p;
fun test(x: Foo) {
@@ -38,6 +39,7 @@ public class Foo {
// FILE: test.after.kt
// "Surround with null check" "true"
// ERROR: Reference has a nullable type 'A?', use explicit '?.invoke()' to make a function-like call instead
package p;
fun test(x: Foo) {
@@ -1,7 +1,6 @@
// "Wrap with '?.let { ... }' call" "false"
// WITH_STDLIB
// ACTION: Add non-null asserted (toLowerCase()!!) call
// ACTION: Compiler warning 'DEPRECATION' options
// ACTION: Add non-null asserted (lowercase()!!) call
// ACTION: Introduce import alias
// ACTION: Introduce local variable
// ACTION: Replace with safe (this?.) call
@@ -9,5 +8,5 @@
// K2_AFTER_ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'String?'.
fun String?.foo() {
toLowerCase<caret>()
lowercase<caret>()
}
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Wrap with '?.let { ... }' call" "true"
// ERROR: Type mismatch: inferred type is A? but A was expected
package p;
fun f(x: A) {}
@@ -39,6 +40,7 @@ public class Foo {
// FILE: test.after.kt
// "Wrap with '?.let { ... }' call" "true"
// ERROR: Type mismatch: inferred type is A? but A was expected
package p;
fun f(x: A) {}
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Wrap with '?.let { ... }' call" "true"
// ERROR: Type mismatch: inferred type is A? but A was expected
package p;
fun f(x: A) {}
@@ -40,6 +41,7 @@ public class Foo {
// FILE: test.after.kt
// "Wrap with '?.let { ... }' call" "true"
// ERROR: Type mismatch: inferred type is A? but A was expected
package p;
fun f(x: A) {}
@@ -5,6 +5,7 @@
// ACTION: Convert to run
// ACTION: Convert to with
// ACTION: Do not show hints for current method
// ERROR: Null can not be a value of a non-null type String
package p;
fun test(x: Foo) {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Wrap with '?.let { ... }' call" "true"
// ERROR: Reference has a nullable type 'A?', use explicit '?.invoke()' to make a function-like call instead
package p;
fun test(x: Foo) {
@@ -38,6 +39,7 @@ public class Foo {
// FILE: test.after.kt
// "Wrap with '?.let { ... }' call" "true"
// ERROR: Reference has a nullable type 'A?', use explicit '?.invoke()' to make a function-like call instead
package p;
fun test(x: Foo) {
@@ -1,5 +1,6 @@
// FILE: test.before.kt
// "Wrap with '?.let { ... }' call" "true"
// ERROR: Reference has a nullable type 'A?', use explicit '?.invoke()' to make a function-like call instead
package p;
fun test(x: Foo) {
@@ -37,6 +38,7 @@ public class Foo {
// FILE: test.after.kt
// "Wrap with '?.let { ... }' call" "true"
// ERROR: Reference has a nullable type 'A?', use explicit '?.invoke()' to make a function-like call instead
package p;
fun test(x: Foo) {