Fix false positive "Insert explicit type arguments" intention
#KT-16139 Fixed
This commit is contained in:
+2
-1
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
import org.jetbrains.kotlin.psi.KtTypeArgumentList
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.CapturedType
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
|
||||
@@ -46,7 +47,7 @@ class InsertExplicitTypeArgumentsIntention :
|
||||
|
||||
val resolvedCall = element.getResolvedCall(bindingContext) ?: return false
|
||||
val typeArgs = resolvedCall.typeArguments
|
||||
return typeArgs.isNotEmpty() && typeArgs.values.none { ErrorUtils.containsErrorType(it) }
|
||||
return typeArgs.isNotEmpty() && typeArgs.values.none { ErrorUtils.containsErrorType(it) || it is CapturedType }
|
||||
}
|
||||
|
||||
fun applyTo(element: KtCallElement, shortenReferences: Boolean = true) {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: false
|
||||
class X<T>(val t: T)
|
||||
|
||||
fun <T> X<T>.getT(): T = t
|
||||
|
||||
fun <T> useX(x: X<out T>) {
|
||||
x.getT<caret>()
|
||||
}
|
||||
@@ -9879,6 +9879,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
runTest("idea/testData/intentions/insertExplicitTypeArguments/insertTypeWithVarargs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableGenericType.kt")
|
||||
public void testNotApplicableGenericType() throws Exception {
|
||||
runTest("idea/testData/intentions/insertExplicitTypeArguments/notApplicableGenericType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleInsertTypeClass.kt")
|
||||
public void testSimpleInsertTypeClass() throws Exception {
|
||||
runTest("idea/testData/intentions/insertExplicitTypeArguments/simpleInsertTypeClass.kt");
|
||||
|
||||
Reference in New Issue
Block a user