AbstractDiagnosticBasedMigrationInspection: fix case with nullable custom factory

#KT-36479 Fixed
This commit is contained in:
Dmitry Gridin
2020-02-11 09:58:59 +07:00
parent b9911d0e0c
commit bcfd089473
3 changed files with 14 additions and 4 deletions
@@ -48,11 +48,10 @@ abstract class AbstractDiagnosticBasedMigrationInspection<T : KtElement>(
.singleOrNull()
?: error("Must have one diagnostic")
val intentionAction = (if (customIntentionFactory != null)
customIntentionFactory.invoke(diagnostic)
val intentionAction = if (customIntentionFactory != null)
customIntentionFactory.invoke(diagnostic) ?: return
else
actionsFactory.createActions(diagnostic).singleOrNull())
?: error("Must have one fix")
actionsFactory.createActions(diagnostic).ifEmpty { return }.singleOrNull() ?: error("Must have one fix")
val text = descriptionMessage() ?: DefaultErrorMessages.render(diagnostic)
problemDescriptors.add(
@@ -0,0 +1,6 @@
// LANGUAGE_VERSION: 1.4
// PROBLEM: none
var vgs: Int
get() = 0
set(value<caret>) {}
@@ -13337,6 +13337,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/inspectionsLocal/warningOnMainUnusedParameterMigration"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), null, true);
}
@TestMetadata("notApplicable.kt")
public void testNotApplicable() throws Exception {
runTest("idea/testData/inspectionsLocal/warningOnMainUnusedParameterMigration/notApplicable.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("idea/testData/inspectionsLocal/warningOnMainUnusedParameterMigration/simple.kt");