Set type reference: destructuring support #KT-14994 Fixed

This commit is contained in:
Mikhail Glukhikh
2017-01-26 15:23:26 +03:00
parent f4513e9c70
commit c0f5cafbd8
4 changed files with 15 additions and 1 deletions
@@ -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