[K2] Fix stable parameter name metadata.

This commit is contained in:
Mads Ager
2023-03-16 13:23:10 +01:00
committed by Mikhail Glukhikh
parent 3a8f1ca690
commit 3795fc1106
2 changed files with 5 additions and 7 deletions
@@ -451,7 +451,7 @@ class FirElementSerializer private constructor(
simpleFunction?.isExternal == true, simpleFunction?.isExternal == true,
simpleFunction?.isSuspend == true, simpleFunction?.isSuspend == true,
simpleFunction?.isExpect == true, simpleFunction?.isExpect == true,
shouldSetStableParameterNames(simpleFunction), shouldSetStableParameterNames(function),
) )
if (flags != builder.flags) { if (flags != builder.flags) {
@@ -530,11 +530,11 @@ class FirElementSerializer private constructor(
return builder return builder
} }
private fun shouldSetStableParameterNames(simpleFunction: FirSimpleFunction?): Boolean { private fun shouldSetStableParameterNames(function: FirFunction?): Boolean {
return when { return when {
simpleFunction?.hasStableParameterNames == true -> true function?.hasStableParameterNames == true -> true
// for backward compatibility with K1, remove this line to fix KT-4758 // for backward compatibility with K1, remove this line to fix KT-4758
simpleFunction?.origin == FirDeclarationOrigin.Delegated -> true function?.origin == FirDeclarationOrigin.Delegated -> true
else -> false else -> false
} }
} }
@@ -601,7 +601,7 @@ class FirElementSerializer private constructor(
constructor.nonSourceAnnotations(session).isNotEmpty(), constructor.nonSourceAnnotations(session).isNotEmpty(),
ProtoEnumFlags.visibility(normalizeVisibility(constructor)), ProtoEnumFlags.visibility(normalizeVisibility(constructor)),
!constructor.isPrimary, !constructor.isPrimary,
constructor.hasStableParameterNames, shouldSetStableParameterNames(constructor)
) )
if (flags != builder.flags) { if (flags != builder.flags) {
builder.flags = flags builder.flags = flags
-2
View File
@@ -1,5 +1,3 @@
// IGNORE K2
fun test() { fun test() {
val f = {} val f = {}
val g = fun Unit.(s: IntArray?, t: Set<Double>): String { return "" } val g = fun Unit.(s: IntArray?, t: Set<Double>): String { return "" }