FIR IDE: Enable AddExclExclCallFix for ASSIGNMENT_TYPE_MISMATCH and
INITIALIZER_TYPE_MISMATCH.
This commit is contained in:
committed by
teamcityserver
parent
eddc590aaf
commit
c6427d57f1
@@ -118,6 +118,8 @@ class MainKtQuickFixRegistrar : KtQuickFixRegistrar() {
|
||||
registerApplicator(AddExclExclCallFixFactories.iteratorOnNullableFactory)
|
||||
registerApplicator(TypeMismatchFactories.argumentTypeMismatchFactory)
|
||||
registerApplicator(TypeMismatchFactories.returnTypeMismatchFactory)
|
||||
registerApplicator(TypeMismatchFactories.assignmentTypeMismatch)
|
||||
registerApplicator(TypeMismatchFactories.initializerTypeMismatch)
|
||||
|
||||
// TODO: NON_EXHAUSTIVE_WHEN[_ON_SEALED_CLASS] will be replaced in future. We need to register the fix for those diagnostics as well
|
||||
registerPsiQuickFixes(KtFirDiagnostic.NoElseInWhen::class, AddWhenElseBranchFix)
|
||||
|
||||
@@ -22,6 +22,14 @@ object TypeMismatchFactories {
|
||||
getFixesForTypeMismatch(diagnostic.psi, diagnostic.expectedType, diagnostic.actualType)
|
||||
}
|
||||
|
||||
val assignmentTypeMismatch = diagnosticFixFactory<KtFirDiagnostic.AssignmentTypeMismatch> { diagnostic ->
|
||||
getFixesForTypeMismatch(diagnostic.psi, diagnostic.expectedType, diagnostic.actualType)
|
||||
}
|
||||
|
||||
val initializerTypeMismatch = diagnosticFixFactory<KtFirDiagnostic.InitializerTypeMismatch> { diagnostic ->
|
||||
diagnostic.psi.initializer?.let { getFixesForTypeMismatch(it, diagnostic.expectedType, diagnostic.actualType) } ?: emptyList()
|
||||
}
|
||||
|
||||
private fun KtAnalysisSession.getFixesForTypeMismatch(
|
||||
psi: PsiElement,
|
||||
expectedType: KtType,
|
||||
|
||||
Generated
+10
@@ -361,6 +361,11 @@ public class HighLevelQuickFixTestGenerated extends AbstractHighLevelQuickFixTes
|
||||
runTest("idea/testData/quickfix/addExclExclCall/typeMismatch/assignmentRValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initializer.kt")
|
||||
public void testInitializer() throws Exception {
|
||||
runTest("idea/testData/quickfix/addExclExclCall/typeMismatch/initializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("memberAccessInExtension.kt")
|
||||
public void testMemberAccessInExtension() throws Exception {
|
||||
runTest("idea/testData/quickfix/addExclExclCall/typeMismatch/memberAccessInExtension.kt");
|
||||
@@ -371,6 +376,11 @@ public class HighLevelQuickFixTestGenerated extends AbstractHighLevelQuickFixTes
|
||||
runTest("idea/testData/quickfix/addExclExclCall/typeMismatch/memberAccessInExtensionAsAssignmentRValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("memberAccessInExtensionAsInitializer.kt")
|
||||
public void testMemberAccessInExtensionAsInitializer() throws Exception {
|
||||
runTest("idea/testData/quickfix/addExclExclCall/typeMismatch/memberAccessInExtensionAsInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullArgument.kt")
|
||||
public void testNullArgument() throws Exception {
|
||||
runTest("idea/testData/quickfix/addExclExclCall/typeMismatch/nullArgument.kt");
|
||||
|
||||
@@ -8,4 +8,7 @@ fun foo(arg: String?) {
|
||||
if (arg == null) {
|
||||
val x: String = arg<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Need data flow info from null check
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
fun test() {
|
||||
val s: String? = null
|
||||
val z: String = <caret>s
|
||||
}
|
||||
// TODO: Enable when FIR reports TYPE_MISMATCH for assignments
|
||||
/* IGNORE_FIR */
|
||||
fun test(s: String?) {
|
||||
var z: String = ""
|
||||
z = <caret>s
|
||||
}
|
||||
+4
-6
@@ -1,7 +1,5 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
fun test() {
|
||||
val s: String? = null
|
||||
val z: String = s!!
|
||||
}
|
||||
// TODO: Enable when FIR reports TYPE_MISMATCH for assignments
|
||||
/* IGNORE_FIR */
|
||||
fun test(s: String?) {
|
||||
var z: String = ""
|
||||
z = s!!
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
fun test(s: String?) {
|
||||
val z: String = <caret>s
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
fun test(s: String?) {
|
||||
val z: String = s!!
|
||||
}
|
||||
Vendored
+3
-4
@@ -5,7 +5,6 @@ class C {
|
||||
|
||||
// Test for KTIJ-10052
|
||||
fun C.test() {
|
||||
val z: String = <caret>s
|
||||
}
|
||||
// TODO: Enable when FIR reports TYPE_MISMATCH for assignments
|
||||
/* IGNORE_FIR */
|
||||
var z: String = ""
|
||||
z = <caret>s
|
||||
}
|
||||
+3
-4
@@ -5,7 +5,6 @@ class C {
|
||||
|
||||
// Test for KTIJ-10052
|
||||
fun C.test() {
|
||||
val z: String = s!!
|
||||
}
|
||||
// TODO: Enable when FIR reports TYPE_MISMATCH for assignments
|
||||
/* IGNORE_FIR */
|
||||
var z: String = ""
|
||||
z = s!!
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
class C {
|
||||
val s: String? = null
|
||||
}
|
||||
|
||||
// Test for KTIJ-10052
|
||||
fun C.test() {
|
||||
var z: String = <caret>s
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// "Add non-null asserted (!!) call" "true"
|
||||
class C {
|
||||
val s: String? = null
|
||||
}
|
||||
|
||||
// Test for KTIJ-10052
|
||||
fun C.test() {
|
||||
var z: String = s!!
|
||||
}
|
||||
@@ -774,6 +774,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
runTest("idea/testData/quickfix/addExclExclCall/typeMismatch/assignmentRValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initializer.kt")
|
||||
public void testInitializer() throws Exception {
|
||||
runTest("idea/testData/quickfix/addExclExclCall/typeMismatch/initializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("memberAccessInExtension.kt")
|
||||
public void testMemberAccessInExtension() throws Exception {
|
||||
runTest("idea/testData/quickfix/addExclExclCall/typeMismatch/memberAccessInExtension.kt");
|
||||
@@ -784,6 +789,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
runTest("idea/testData/quickfix/addExclExclCall/typeMismatch/memberAccessInExtensionAsAssignmentRValue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("memberAccessInExtensionAsInitializer.kt")
|
||||
public void testMemberAccessInExtensionAsInitializer() throws Exception {
|
||||
runTest("idea/testData/quickfix/addExclExclCall/typeMismatch/memberAccessInExtensionAsInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullArgument.kt")
|
||||
public void testNullArgument() throws Exception {
|
||||
runTest("idea/testData/quickfix/addExclExclCall/typeMismatch/nullArgument.kt");
|
||||
|
||||
Reference in New Issue
Block a user