Set type reference: destructuring support #KT-14994 Fixed
This commit is contained in:
@@ -38,7 +38,9 @@ fun setTypeReference(declaration: KtCallableDeclaration, addAfter: PsiElement?,
|
||||
return oldTypeRef.replace(typeRef) as KtTypeReference
|
||||
}
|
||||
else {
|
||||
val anchor = addAfter ?: declaration.nameIdentifier?.siblings(forward = true)?.firstOrNull { it is PsiErrorElement }
|
||||
val anchor = addAfter
|
||||
?: declaration.nameIdentifier?.siblings(forward = true)?.firstOrNull { it is PsiErrorElement }
|
||||
?: (declaration as? KtParameter)?.destructuringDeclaration
|
||||
val newTypeRef = declaration.addAfter(typeRef, anchor) as KtTypeReference
|
||||
declaration.addAfter(KtPsiFactory(declaration.project).createColon(), anchor)
|
||||
return newTypeRef
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
data class A(val x: String, val y: String)
|
||||
fun foo(a: A, block: (Int, A, String) -> String): String = block(1, a, "#")
|
||||
fun bb() = foo(A("O", "K")) { i: Int, (x, y)<caret>, v: String -> i.toString() + x + y + v }
|
||||
@@ -0,0 +1,3 @@
|
||||
data class A(val x: String, val y: String)
|
||||
fun foo(a: A, block: (Int, A, String) -> String): String = block(1, a, "#")
|
||||
fun bb() = foo(A("O", "K")) { i: Int, (x, y): A, v: String -> i.toString() + x + y + v }
|
||||
@@ -13867,6 +13867,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("destructuringInLambda.kt")
|
||||
public void testDestructuringInLambda() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/specifyTypeExplicitly/destructuringInLambda.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("enumType.kt")
|
||||
public void testEnumType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/specifyTypeExplicitly/enumType.kt");
|
||||
|
||||
Reference in New Issue
Block a user