Change Signature: Do not use local declaration as a context for a type code fragment

This commit is contained in:
Alexey Sedunov
2016-04-27 15:44:33 +03:00
parent c6cb5175a4
commit e6ab2f1c2d
@@ -408,12 +408,13 @@ class KotlinChangeSignatureDialog(
private fun getTypeCodeFragmentContext(startFrom: PsiElement): KtElement { private fun getTypeCodeFragmentContext(startFrom: PsiElement): KtElement {
return startFrom.parents.mapNotNull { return startFrom.parents.mapNotNull {
when (it) { when {
is KtNamedFunction -> it.bodyExpression it is KtNamedFunction -> it.bodyExpression
is KtPropertyAccessor -> it.bodyExpression it is KtPropertyAccessor -> it.bodyExpression
is KtConstructor<*> -> it it is KtDeclaration && KtPsiUtil.isLocal(it) -> null
is KtClassOrObject -> it it is KtConstructor<*> -> it
is KtFile -> it it is KtClassOrObject -> it
it is KtFile -> it
else -> null else -> null
} }
}.first() }.first()