[FIR] Fix conversion of underscored value parameters in functions
Fix false REDECLARATION
This commit is contained in:
+8
-2
@@ -1436,7 +1436,8 @@ class DeclarationsConverter(
|
||||
val target: FirFunctionTarget
|
||||
val functionSource = functionDeclaration.toFirSourceElement()
|
||||
val functionSymbol: FirFunctionSymbol<*>
|
||||
val functionBuilder = if (identifier == null && isLocal) {
|
||||
val isAnonymousFunction = identifier == null && isLocal
|
||||
val functionBuilder = if (isAnonymousFunction) {
|
||||
val labelName = functionDeclaration.getLabelName() ?: context.calleeNamesForLambda.lastOrNull()?.identifier
|
||||
target = FirFunctionTarget(labelName = labelName, isLambda = false)
|
||||
functionSymbol = FirAnonymousFunctionSymbol()
|
||||
@@ -1494,7 +1495,12 @@ class DeclarationsConverter(
|
||||
}
|
||||
|
||||
withCapturedTypeParameters(true, actualTypeParameters) {
|
||||
valueParametersList?.let { list -> valueParameters += convertValueParameters(list).map { it.firValueParameter } }
|
||||
valueParametersList?.let { list ->
|
||||
valueParameters += convertValueParameters(
|
||||
list,
|
||||
if (isAnonymousFunction) ValueParameterDeclaration.LAMBDA else ValueParameterDeclaration.OTHER
|
||||
).map { it.firValueParameter }
|
||||
}
|
||||
|
||||
val hasContractEffectList = outerContractDescription != null
|
||||
val bodyWithContractDescription = convertFunctionBody(block, expression, hasContractEffectList)
|
||||
|
||||
@@ -1113,8 +1113,8 @@ open class RawFirBuilder(
|
||||
val receiverType = function.receiverTypeReference.convertSafe<FirTypeRef>()
|
||||
|
||||
val labelName: String?
|
||||
val functionIsAnonymousFunction = function.name == null && !function.parent.let { it is KtFile || it is KtClassBody }
|
||||
val functionBuilder = if (functionIsAnonymousFunction) {
|
||||
val isAnonymousFunction = function.name == null && !function.parent.let { it is KtFile || it is KtClassBody }
|
||||
val functionBuilder = if (isAnonymousFunction) {
|
||||
FirAnonymousFunctionBuilder().apply {
|
||||
receiverTypeRef = receiverType
|
||||
symbol = FirAnonymousFunctionSymbol()
|
||||
@@ -1159,7 +1159,11 @@ open class RawFirBuilder(
|
||||
function.extractTypeParametersTo(this, symbol)
|
||||
}
|
||||
for (valueParameter in function.valueParameters) {
|
||||
valueParameters += valueParameter.convert<FirValueParameter>()
|
||||
valueParameters += convertValueParameter(
|
||||
valueParameter,
|
||||
null,
|
||||
if (isAnonymousFunction) ValueParameterDeclaration.LAMBDA else ValueParameterDeclaration.OTHER
|
||||
)
|
||||
}
|
||||
val actualTypeParameters = if (this is FirSimpleFunctionBuilder)
|
||||
this.typeParameters
|
||||
|
||||
+2
@@ -4,4 +4,6 @@ fun test2(block: (Int, String) -> Unit) { }
|
||||
|
||||
fun main() {
|
||||
test2 { <!REDECLARATION!>b<!>, <!REDECLARATION!>b<!> -> ; }
|
||||
|
||||
val func: (Int, Int) -> Int = fun(_, _): Int { return 42 }
|
||||
}
|
||||
|
||||
+2
@@ -4,4 +4,6 @@ fun test2(block: (Int, String) -> Unit) { }
|
||||
|
||||
fun main() {
|
||||
test2 { <!REDECLARATION, REDECLARATION!>b<!>, <!REDECLARATION, REDECLARATION!>b<!> -> ; }
|
||||
|
||||
val func: (Int, Int) -> Int = fun(_, _): Int { return 42 }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user