diff --git a/compiler/testData/builtin-classes/newMethods/kotlin.txt b/compiler/testData/builtin-classes/newMethods/kotlin.txt index 2bb26a0b6aa..01b1737c826 100644 --- a/compiler/testData/builtin-classes/newMethods/kotlin.txt +++ b/compiler/testData/builtin-classes/newMethods/kotlin.txt @@ -744,6 +744,9 @@ public final class String : kotlin.Comparable, kotlin.CharSequenc public open override /*1*/ fun compareTo(/*0*/ other: kotlin.String): kotlin.Int public open override /*1*/ fun get(/*0*/ index: kotlin.Int): kotlin.Char public final operator fun plus(/*0*/ other: kotlin.Any?): kotlin.String + @kotlin.Deprecated(level = DeprecationLevel.WARNING, message = "This member is not fully supported by Kotlin compiler, so it may be absent or have different signature in next major version", replaceWith = kotlin.ReplaceWith(expression = "", imports = {})) public open fun strip(): kotlin.String! + @kotlin.Deprecated(level = DeprecationLevel.WARNING, message = "This member is not fully supported by Kotlin compiler, so it may be absent or have different signature in next major version", replaceWith = kotlin.ReplaceWith(expression = "", imports = {})) public open fun stripLeading(): kotlin.String! + @kotlin.Deprecated(level = DeprecationLevel.WARNING, message = "This member is not fully supported by Kotlin compiler, so it may be absent or have different signature in next major version", replaceWith = kotlin.ReplaceWith(expression = "", imports = {})) public open fun stripTrailing(): kotlin.String! public open override /*1*/ fun subSequence(/*0*/ startIndex: kotlin.Int, /*1*/ endIndex: kotlin.Int): kotlin.CharSequence public companion object Companion { diff --git a/compiler/testData/diagnostics/testWithModifiedMockJdk/newStringMethods.kt b/compiler/testData/diagnostics/testWithModifiedMockJdk/newStringMethods.kt new file mode 100644 index 00000000000..53a19e64041 --- /dev/null +++ b/compiler/testData/diagnostics/testWithModifiedMockJdk/newStringMethods.kt @@ -0,0 +1,11 @@ +// !CHECK_TYPE +// SKIP_TXT + +fun foo(s: String) { + s.isBlank() + s.lines().checkType { _>() } + s.repeat(1) + + // We don't have `strip` extension, so leave it for a while in gray list + s.strip() +} diff --git a/compiler/testData/mockJDKModified/rt.jar b/compiler/testData/mockJDKModified/rt.jar index 64d380ad782..1241c3339a6 100644 Binary files a/compiler/testData/mockJDKModified/rt.jar and b/compiler/testData/mockJDKModified/rt.jar differ diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/TestJdkKind.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/TestJdkKind.java index e29fcd46cc1..35d3e901642 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/TestJdkKind.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/TestJdkKind.java @@ -20,6 +20,7 @@ public enum TestJdkKind { MOCK_JDK, // Differs from common mock JDK only by one additional 'nonExistingMethod' in Collection and constructor from Double in Throwable // It's needed to test the way we load additional built-ins members that neither in black nor white lists + // Also, now it contains new methods in java.lang.String introduced in JDK 11 MODIFIED_MOCK_JDK, // JDK found at $JDK_16 FULL_JDK_6, diff --git a/compiler/tests-java8/tests/org/jetbrains/kotlin/serialization/builtins/AdditionalBuiltInsMembersSignatureListsTest.kt b/compiler/tests-java8/tests/org/jetbrains/kotlin/serialization/builtins/AdditionalBuiltInsMembersSignatureListsTest.kt index 718ff922fcf..63a566015c0 100644 --- a/compiler/tests-java8/tests/org/jetbrains/kotlin/serialization/builtins/AdditionalBuiltInsMembersSignatureListsTest.kt +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/serialization/builtins/AdditionalBuiltInsMembersSignatureListsTest.kt @@ -57,8 +57,13 @@ class AdditionalBuiltInsMembersSignatureListsTest : KotlinTestWithEnvironment() val scope = classDescriptor.unsubstitutedMemberScope + val lateJdkSignatures = LATE_JDK_SIGNATURES[internalName] ?: emptySet() + jvmDescriptors.forEach { jvmDescriptor -> + + if (jvmDescriptor in lateJdkSignatures) return@forEach + val stringName = jvmDescriptor.split("(")[0] val functions = if (stringName == "") @@ -72,4 +77,8 @@ class AdditionalBuiltInsMembersSignatureListsTest : KotlinTestWithEnvironment() } } } + + private val LATE_JDK_SIGNATURES = mapOf( + "java/lang/String" to setOf("isBlank()Z", "lines()Ljava/util/stream/Stream;", "repeat(I)Ljava/lang/String;") + ) } diff --git a/compiler/tests/org/jetbrains/kotlin/cfg/DiagnosticsWithModifiedMockJdkTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cfg/DiagnosticsWithModifiedMockJdkTestGenerated.java index 30d3f488b6a..37bb8ca0111 100644 --- a/compiler/tests/org/jetbrains/kotlin/cfg/DiagnosticsWithModifiedMockJdkTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cfg/DiagnosticsWithModifiedMockJdkTestGenerated.java @@ -29,6 +29,11 @@ public class DiagnosticsWithModifiedMockJdkTestGenerated extends AbstractDiagnos KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testWithModifiedMockJdk"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("newStringMethods.kt") + public void testNewStringMethods() throws Exception { + runTest("compiler/testData/diagnostics/testWithModifiedMockJdk/newStringMethods.kt"); + } + @TestMetadata("notConsideredMethod.kt") public void testNotConsideredMethod() throws Exception { runTest("compiler/testData/diagnostics/testWithModifiedMockJdk/notConsideredMethod.kt"); diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/builtins/jvm/JvmBuiltInsSettings.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/builtins/jvm/JvmBuiltInsSettings.kt index 7fb1f6537e0..4af1c60c296 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/builtins/jvm/JvmBuiltInsSettings.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/builtins/jvm/JvmBuiltInsSettings.kt @@ -371,7 +371,8 @@ open class JvmBuiltInsSettings( "startsWith(Ljava/lang/String;I)Z", "startsWith(Ljava/lang/String;)Z", "substring(II)Ljava/lang/String;", "substring(I)Ljava/lang/String;", "toCharArray()[C", "toLowerCase()Ljava/lang/String;", "toLowerCase(Ljava/util/Locale;)Ljava/lang/String;", "toUpperCase()Ljava/lang/String;", - "toUpperCase(Ljava/util/Locale;)Ljava/lang/String;", "trim()Ljava/lang/String;" + "toUpperCase(Ljava/util/Locale;)Ljava/lang/String;", "trim()Ljava/lang/String;", + "isBlank()Z", "lines()Ljava/util/stream/Stream;", "repeat(I)Ljava/lang/String;" ) + inJavaLang("Double", "isInfinite()Z", "isNaN()Z") +