Remove explicit type arguments: don't report when type argument has annotations
#KT-40985 Fixed
This commit is contained in:
committed by
Dmitry Gridin
parent
e1a380ec95
commit
5e9333773c
+2
-1
@@ -44,7 +44,8 @@ class RemoveExplicitTypeArgumentsIntention : SelfTargetingOffsetIndependentInten
|
||||
companion object {
|
||||
fun isApplicableTo(element: KtTypeArgumentList, approximateFlexible: Boolean): Boolean {
|
||||
val callExpression = element.parent as? KtCallExpression ?: return false
|
||||
if (callExpression.typeArguments.isEmpty()) return false
|
||||
val typeArguments = callExpression.typeArguments
|
||||
if (typeArguments.isEmpty() || typeArguments.any { it.typeReference?.annotationEntries?.isNotEmpty() == true }) return false
|
||||
|
||||
val resolutionFacade = callExpression.getResolutionFacade()
|
||||
val bindingContext = resolutionFacade.analyze(callExpression, BodyResolveMode.PARTIAL_WITH_CFA)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WITH_RUNTIME
|
||||
annotation class Foo(val value: String)
|
||||
|
||||
fun main() {
|
||||
val l = listOf<@Foo("bar") <caret>String>("")
|
||||
}
|
||||
@@ -14466,6 +14466,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
runTest("idea/testData/intentions/removeExplicitTypeArguments/getterBody.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("hasAnnotation.kt")
|
||||
public void testHasAnnotation() throws Exception {
|
||||
runTest("idea/testData/intentions/removeExplicitTypeArguments/hasAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inapplicableTypeThatIsAFunItCannotBeInferred.kt")
|
||||
public void testInapplicableTypeThatIsAFunItCannotBeInferred() throws Exception {
|
||||
runTest("idea/testData/intentions/removeExplicitTypeArguments/inapplicableTypeThatIsAFunItCannotBeInferred.kt");
|
||||
|
||||
Reference in New Issue
Block a user