Convert property to function: fix incorrectly conversion when property has explicit generic type
#KT-29192 Fixed
This commit is contained in:
committed by
Dmitry Gridin
parent
354f8f0bf1
commit
6ff776ba65
@@ -75,6 +75,11 @@ class ConvertPropertyToFunctionIntention : SelfTargetingIntention<KtProperty>(Kt
|
|||||||
.first { it !is PsiWhiteSpace }
|
.first { it !is PsiWhiteSpace }
|
||||||
.nextSibling
|
.nextSibling
|
||||||
property.deleteChildRange(dropPropertyFrom, getter.prevSibling)
|
property.deleteChildRange(dropPropertyFrom, getter.prevSibling)
|
||||||
|
|
||||||
|
val typeReference = property.typeReference
|
||||||
|
if (typeReference != null) {
|
||||||
|
property.addAfter(psiFactory.createWhiteSpace(), typeReference)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
property.setName(newName)
|
property.setName(newName)
|
||||||
|
|||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
class Test {
|
||||||
|
val <caret>foo: Foo<String>
|
||||||
|
get() = Foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
class Foo<T>
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
class Test {
|
||||||
|
fun getFoo(): Foo<String> = Foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
class Foo<T>
|
||||||
@@ -6614,6 +6614,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
runTest("idea/testData/intentions/convertPropertyToFunction/expressionBody.kt");
|
runTest("idea/testData/intentions/convertPropertyToFunction/expressionBody.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("expressionBodyWithGenericType.kt")
|
||||||
|
public void testExpressionBodyWithGenericType() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/convertPropertyToFunction/expressionBodyWithGenericType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("initializer.kt")
|
@TestMetadata("initializer.kt")
|
||||||
public void testInitializer() throws Exception {
|
public void testInitializer() throws Exception {
|
||||||
runTest("idea/testData/intentions/convertPropertyToFunction/initializer.kt");
|
runTest("idea/testData/intentions/convertPropertyToFunction/initializer.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user