Remove explicit type specification: don't propose for ext function type
#KT-8875 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
c8cbe05722
commit
8b2fef3812
@@ -77,6 +77,7 @@ class RemoveExplicitTypeIntention : SelfTargetingRangeIntention<KtCallableDeclar
|
|||||||
if (initializer == null) return true
|
if (initializer == null) return true
|
||||||
if (initializer !is KtLambdaExpression && initializer !is KtNamedFunction) return true
|
if (initializer !is KtLambdaExpression && initializer !is KtNamedFunction) return true
|
||||||
val functionType = element.typeReference?.typeElement as? KtFunctionType ?: return true
|
val functionType = element.typeReference?.typeElement as? KtFunctionType ?: return true
|
||||||
|
if (functionType.receiver != null) return false
|
||||||
if (functionType.parameters.isEmpty()) return true
|
if (functionType.parameters.isEmpty()) return true
|
||||||
val valueParameters = when (initializer) {
|
val valueParameters = when (initializer) {
|
||||||
is KtLambdaExpression -> initializer.valueParameters
|
is KtLambdaExpression -> initializer.valueParameters
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
val foo: <caret>Int.() -> String = {
|
||||||
|
toString() + hashCode()
|
||||||
|
}
|
||||||
@@ -13316,6 +13316,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
runTest("idea/testData/intentions/removeExplicitType/anonymousFunctionInitializer3.kt");
|
runTest("idea/testData/intentions/removeExplicitType/anonymousFunctionInitializer3.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("extensionFunction.kt")
|
||||||
|
public void testExtensionFunction() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/removeExplicitType/extensionFunction.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("funNoBody.kt")
|
@TestMetadata("funNoBody.kt")
|
||||||
public void testFunNoBody() throws Exception {
|
public void testFunNoBody() throws Exception {
|
||||||
runTest("idea/testData/intentions/removeExplicitType/funNoBody.kt");
|
runTest("idea/testData/intentions/removeExplicitType/funNoBody.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user