diff --git a/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/newStringMethods.fir.kt b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/newStringMethods.fir.kt new file mode 100644 index 00000000000..b6e9ed6ce5a --- /dev/null +++ b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/newStringMethods.fir.kt @@ -0,0 +1,13 @@ +// !JDK_KIND: MODIFIED_MOCK_JDK +// !CHECK_TYPE +// SKIP_TXT +// WITH_RUNTIME + +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/diagnostics/testWithModifiedMockJdk/newStringMethods.kt b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/newStringMethods.kt similarity index 88% rename from compiler/testData/diagnostics/testWithModifiedMockJdk/newStringMethods.kt rename to compiler/testData/diagnostics/tests/testWithModifiedMockJdk/newStringMethods.kt index c6a87538327..746b0a46c5e 100644 --- a/compiler/testData/diagnostics/testWithModifiedMockJdk/newStringMethods.kt +++ b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/newStringMethods.kt @@ -1,3 +1,4 @@ +// !JDK_KIND: MODIFIED_MOCK_JDK // !CHECK_TYPE // SKIP_TXT // WITH_RUNTIME diff --git a/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.fir.kt b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.fir.kt new file mode 100644 index 00000000000..bba63299a6f --- /dev/null +++ b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.fir.kt @@ -0,0 +1,13 @@ +// !JDK_KIND: MODIFIED_MOCK_JDK +// !CHECK_TYPE + +interface A : MutableCollection { + // Override of deprecated function could be marked as deprecated too + override fun nonExistingMethod(x: String) = "" +} + +fun foo(x: MutableCollection, y: Collection, z: A) { + x.nonExistingMethod(1).checkType { _() } + y.nonExistingMethod("") + z.nonExistingMethod("") +} diff --git a/compiler/testData/diagnostics/testWithModifiedMockJdk/notConsideredMethod.kt b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.kt similarity index 92% rename from compiler/testData/diagnostics/testWithModifiedMockJdk/notConsideredMethod.kt rename to compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.kt index dc97dd21b52..a9b6f81495b 100644 --- a/compiler/testData/diagnostics/testWithModifiedMockJdk/notConsideredMethod.kt +++ b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.kt @@ -1,3 +1,4 @@ +// !JDK_KIND: MODIFIED_MOCK_JDK // !CHECK_TYPE interface A : MutableCollection { diff --git a/compiler/testData/diagnostics/testWithModifiedMockJdk/notConsideredMethod.txt b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.txt similarity index 100% rename from compiler/testData/diagnostics/testWithModifiedMockJdk/notConsideredMethod.txt rename to compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.txt diff --git a/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/throwableConstructor.fir.kt b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/throwableConstructor.fir.kt new file mode 100644 index 00000000000..918ba3b6380 --- /dev/null +++ b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/throwableConstructor.fir.kt @@ -0,0 +1,6 @@ +// !JDK_KIND: MODIFIED_MOCK_JDK +abstract class A : Throwable(1.0) {} + +fun foo() { + Throwable(1.5) +} diff --git a/compiler/testData/diagnostics/testWithModifiedMockJdk/throwableConstructor.kt b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/throwableConstructor.kt similarity index 76% rename from compiler/testData/diagnostics/testWithModifiedMockJdk/throwableConstructor.kt rename to compiler/testData/diagnostics/tests/testWithModifiedMockJdk/throwableConstructor.kt index fca9ba19075..61b73c357c8 100644 --- a/compiler/testData/diagnostics/testWithModifiedMockJdk/throwableConstructor.kt +++ b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/throwableConstructor.kt @@ -1,3 +1,4 @@ +// !JDK_KIND: MODIFIED_MOCK_JDK abstract class A : Throwable(1.0) {} fun foo() { diff --git a/compiler/testData/diagnostics/testWithModifiedMockJdk/throwableConstructor.txt b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/throwableConstructor.txt similarity index 100% rename from compiler/testData/diagnostics/testWithModifiedMockJdk/throwableConstructor.txt rename to compiler/testData/diagnostics/tests/testWithModifiedMockJdk/throwableConstructor.txt diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index d8d5700976e..f87c05e2621 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -28200,6 +28200,34 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/testWithModifiedMockJdk") + @TestDataPath("$PROJECT_ROOT") + public class TestWithModifiedMockJdk extends AbstractDiagnosticTest { + @Test + public void testAllFilesPresentInTestWithModifiedMockJdk() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testWithModifiedMockJdk"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("newStringMethods.kt") + public void testNewStringMethods() throws Exception { + runTest("compiler/testData/diagnostics/tests/testWithModifiedMockJdk/newStringMethods.kt"); + } + + @Test + @TestMetadata("notConsideredMethod.kt") + public void testNotConsideredMethod() throws Exception { + runTest("compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.kt"); + } + + @Test + @TestMetadata("throwableConstructor.kt") + public void testThrowableConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/testWithModifiedMockJdk/throwableConstructor.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/testsWithExplicitApi") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 110fe12682f..5fea12c2faf 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -28104,6 +28104,34 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/testWithModifiedMockJdk") + @TestDataPath("$PROJECT_ROOT") + public class TestWithModifiedMockJdk extends AbstractFirDiagnosticTest { + @Test + public void testAllFilesPresentInTestWithModifiedMockJdk() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/testWithModifiedMockJdk"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("newStringMethods.kt") + public void testNewStringMethods() throws Exception { + runTest("compiler/testData/diagnostics/tests/testWithModifiedMockJdk/newStringMethods.kt"); + } + + @Test + @TestMetadata("notConsideredMethod.kt") + public void testNotConsideredMethod() throws Exception { + runTest("compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.kt"); + } + + @Test + @TestMetadata("throwableConstructor.kt") + public void testThrowableConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/testWithModifiedMockJdk/throwableConstructor.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/testsWithExplicitApi") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/cfg/AbstractDiagnosticsWithModifiedMockJdkTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/cfg/AbstractDiagnosticsWithModifiedMockJdkTest.kt deleted file mode 100644 index c4d63444e7a..00000000000 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/cfg/AbstractDiagnosticsWithModifiedMockJdkTest.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2010-2016 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.cfg - -import org.jetbrains.kotlin.checkers.AbstractDiagnosticsTest -import org.jetbrains.kotlin.test.TestJdkKind - -abstract class AbstractDiagnosticsWithModifiedMockJdkTest : AbstractDiagnosticsTest() { - override fun getTestJdkKind(files: List): TestJdkKind { - return TestJdkKind.MODIFIED_MOCK_JDK - } -} \ No newline at end of file diff --git a/compiler/tests-gen/org/jetbrains/kotlin/cfg/DiagnosticsWithModifiedMockJdkTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/cfg/DiagnosticsWithModifiedMockJdkTestGenerated.java deleted file mode 100644 index 46aab6a1eb5..00000000000 --- a/compiler/tests-gen/org/jetbrains/kotlin/cfg/DiagnosticsWithModifiedMockJdkTestGenerated.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.cfg; - -import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; -import org.jetbrains.kotlin.test.KotlinTestUtils; -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/diagnostics/testWithModifiedMockJdk") -@TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) -public class DiagnosticsWithModifiedMockJdkTestGenerated extends AbstractDiagnosticsWithModifiedMockJdkTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInTestWithModifiedMockJdk() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testWithModifiedMockJdk"), Pattern.compile("^(.+)\\.kt$"), null, 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"); - } - - @TestMetadata("throwableConstructor.kt") - public void testThrowableConstructor() throws Exception { - runTest("compiler/testData/diagnostics/testWithModifiedMockJdk/throwableConstructor.kt"); - } -} diff --git a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt index 507974bb3f7..fa92b5f0fc4 100644 --- a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt +++ b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.generators.tests import org.jetbrains.kotlin.asJava.AbstractCompilerLightClassTest import org.jetbrains.kotlin.cfg.AbstractControlFlowTest import org.jetbrains.kotlin.cfg.AbstractDataFlowTest -import org.jetbrains.kotlin.cfg.AbstractDiagnosticsWithModifiedMockJdkTest import org.jetbrains.kotlin.cfg.AbstractPseudoValueTest import org.jetbrains.kotlin.checkers.* import org.jetbrains.kotlin.checkers.javac.* @@ -80,10 +79,6 @@ fun main(args: Array) { model("diagnostics/nativeTests") } - testClass { - model("diagnostics/testWithModifiedMockJdk") - } - testClass { model("diagnostics/testsWithJava15") }