Create ProhibitJvmOverloadsOnConstructorsOfAnnotationClassesMigrationInspection
#KT-36260 Fixed
This commit is contained in:
@@ -3129,6 +3129,16 @@
|
|||||||
language="kotlin"
|
language="kotlin"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.migration.ProhibitJvmOverloadsOnConstructorsOfAnnotationClassesMigrationInspection"
|
||||||
|
displayName="'@JvmOverloads' annotation cannot be used on constructors of annotation classes since 1.4"
|
||||||
|
groupPath="Kotlin"
|
||||||
|
groupName="Migration"
|
||||||
|
enabledByDefault="false"
|
||||||
|
cleanupTool="true"
|
||||||
|
level="ERROR"
|
||||||
|
language="kotlin"
|
||||||
|
/>
|
||||||
|
|
||||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.migration.ObsoleteExperimentalCoroutinesInspection"
|
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.migration.ObsoleteExperimentalCoroutinesInspection"
|
||||||
displayName="Experimental coroutines usages are deprecated since 1.3"
|
displayName="Experimental coroutines usages are deprecated since 1.3"
|
||||||
groupPath="Kotlin"
|
groupPath="Kotlin"
|
||||||
|
|||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
Since Kotlin 1.4, it's forbidden to use <code>@JvmOverloads</code> on constructors of annotation classes.
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* 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.idea.inspections.migration
|
||||||
|
|
||||||
|
import com.intellij.codeInspection.CleanupLocalInspectionTool
|
||||||
|
import org.jetbrains.kotlin.config.LanguageVersion
|
||||||
|
import org.jetbrains.kotlin.idea.configuration.MigrationInfo
|
||||||
|
import org.jetbrains.kotlin.idea.configuration.isLanguageVersionUpdate
|
||||||
|
import org.jetbrains.kotlin.idea.quickfix.migration.MigrationFix
|
||||||
|
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||||
|
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||||
|
|
||||||
|
|
||||||
|
class ProhibitJvmOverloadsOnConstructorsOfAnnotationClassesMigrationInspection :
|
||||||
|
AbstractDiagnosticBasedMigrationInspection<KtAnnotationEntry>(
|
||||||
|
ErrorsJvm.OVERLOADS_ANNOTATION_CLASS_CONSTRUCTOR,
|
||||||
|
KtAnnotationEntry::class.java,
|
||||||
|
),
|
||||||
|
MigrationFix,
|
||||||
|
CleanupLocalInspectionTool {
|
||||||
|
override fun isApplicable(migrationInfo: MigrationInfo): Boolean {
|
||||||
|
return migrationInfo.isLanguageVersionUpdate(LanguageVersion.KOTLIN_1_3, LanguageVersion.KOTLIN_1_4)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
org.jetbrains.kotlin.idea.inspections.migration.ProhibitJvmOverloadsOnConstructorsOfAnnotationClassesMigrationInspection
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
// LANGUAGE_VERSION: 1.4
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
annotation class A @JvmOverloads<caret> constructor(val x: Int = 1)
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
// LANGUAGE_VERSION: 1.4
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
annotation class A constructor(val x: Int = 1)
|
||||||
+18
@@ -6603,6 +6603,24 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/testData/inspectionsLocal/prohibitJvmOverloadsOnConstructorsOfAnnotationClassesMigration")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class ProhibitJvmOverloadsOnConstructorsOfAnnotationClassesMigration extends AbstractLocalInspectionTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInProhibitJvmOverloadsOnConstructorsOfAnnotationClassesMigration() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/inspectionsLocal/prohibitJvmOverloadsOnConstructorsOfAnnotationClassesMigration"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simple.kt")
|
||||||
|
public void testSimple() throws Exception {
|
||||||
|
runTest("idea/testData/inspectionsLocal/prohibitJvmOverloadsOnConstructorsOfAnnotationClassesMigration/simple.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/inspectionsLocal/prohibitTypeParametersForLocalVariablesMigration")
|
@TestMetadata("idea/testData/inspectionsLocal/prohibitTypeParametersForLocalVariablesMigration")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user