Handle context receiver in KtModifierListOwner.addModifierList()

The existing `KtModifierListOwner.addModifierList(newModifierList)`
function adds a visibility keyword (e.g., `private`) in front of the
`context(..)` modifier, which generates wrong code. This commit fixes
it.

^KTIJ-23728 fixed
This commit is contained in:
Jaebaek Seo
2022-11-22 14:55:07 -08:00
committed by Ilya Kirillov
parent 9856204925
commit a637626601
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings
private fun KtModifierListOwner.addModifierList(newModifierList: KtModifierList): KtModifierList {
val anchor = firstChild!!
.siblings(forward = true)
.dropWhile { it is PsiComment || it is PsiWhiteSpace }
.dropWhile { it is PsiComment || it is PsiWhiteSpace || it is KtContextReceiverList }
.first()
return addBefore(newModifierList, anchor) as KtModifierList
}