CreateTypeParameterFromUsageFix: fix KNPE for type alias

#KT-33302 Fixed
#EA-120181 Fixed
This commit is contained in:
Dmitry Gridin
2019-08-13 16:54:45 +07:00
parent 932765744a
commit cf3b92d80e
5 changed files with 21 additions and 2 deletions
@@ -489,9 +489,10 @@ fun KtTypeParameterListOwner.addTypeParameter(typeParameter: KtTypeParameter): K
val list = KtPsiFactory(this).createTypeParameterList("<X>")
list.parameters[0].replace(typeParameter)
val leftAnchor = when (this) {
is KtClass -> nameIdentifier ?: getClassOrInterfaceKeyword()
is KtClass -> nameIdentifier
is KtNamedFunction -> funKeyword
is KtProperty -> valOrVarKeyword
is KtTypeAlias -> nameIdentifier
else -> null
} ?: return null
return (addAfter(list, leftAnchor) as KtTypeParameterList).parameters.first()