[kotlin] k2 inline: restore type parameter references

^KTIJ-29128 fixed

GitOrigin-RevId: fc11b378f45f5590f7fff83e9f3072a2aae26c97
This commit is contained in:
Anna Kozlova
2024-03-21 19:06:00 +00:00
committed by intellij-monorepo-bot
parent d1184b7970
commit 1d1bb026ea
3 changed files with 5 additions and 6 deletions
@@ -12,6 +12,4 @@ object Test {
private fun gazonk() {
val ss = bar(Test.foo<String>())
}
}
// IGNORE_K2
}
@@ -7,6 +7,4 @@ object Test {
private fun gazonk() {
val ss = bar(emptyList<String>())
}
}
// IGNORE_K2
}
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.psi.KtQualifiedExpression
import org.jetbrains.kotlin.psi.KtReferenceExpression
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
import org.jetbrains.kotlin.psi.KtTypeParameter
import org.jetbrains.kotlin.psi.KtUserType
import org.jetbrains.kotlin.psi.KtValueArgumentName
import org.jetbrains.kotlin.psi.createExpressionByPattern
@@ -212,6 +213,8 @@ internal fun encodeInternalReferences(codeToInline: MutableCodeToInline, origina
target.nameAsSafeName
}
expression.putCopyableUserData(CodeToInline.PARAMETER_USAGE_KEY, getParameterName())
} else if (target is KtTypeParameter) {
expression.putCopyableUserData(CodeToInline.TYPE_PARAMETER_USAGE_KEY, target.nameAsName)
} else if (resolve == (originalDeclaration as? KtNamedFunction)?.receiverTypeReference && isAnonymousFunctionWithReceiver && expression.getReceiverExpression() == null) {
expression.putCopyableUserData(CodeToInline.PARAMETER_USAGE_KEY, Name.identifier("p1"))
}