[FIR] Fix local variable tests.

- Mangle names for extension receivers in lambdas
 - Correctly mark anonymous variables and variables for arguments
   for destructuring declaration.

There is one failure remaining which is cause by lambda
type inference differences that leads to FIR having an explicit
return from the lambda whereas old frontend leads to an implicit
return. This difference is visible in debug stepping that the
local variables tests do because the implicit return has the line
number of the closing brace of the lambda. This change adds an
IrText test to make the difference clear.
This commit is contained in:
Mads Ager
2021-10-28 13:49:57 +02:00
committed by Mikhail Glukhikh
parent 99293de6e9
commit e1f6c19c83
31 changed files with 186 additions and 60 deletions
+2 -2
View File
@@ -24,11 +24,11 @@ FILE fqName:<root> fileName:/builtinMap.kt
p0: GET_VAR '<this>: kotlin.collections.Map<out K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.collections.Map<out K1 of <root>.plus, V1 of <root>.plus> origin=null
block: FUN_EXPR type=kotlin.Function1<java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?>, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?>) returnType:kotlin.Unit
$receiver: VALUE_PARAMETER name:<this> type:java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?>
$receiver: VALUE_PARAMETER name:$this$apply type:java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?>
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
CALL 'public open fun put (p0: @[FlexibleNullability] K of java.util.LinkedHashMap?, p1: @[FlexibleNullability] V of java.util.LinkedHashMap?): V of java.util.LinkedHashMap? [fake_override] declared in java.util.LinkedHashMap' type=V1 of <root>.plus? origin=null
$this: GET_VAR '<this>: java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?> declared in <root>.plus.<anonymous>' type=java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?> origin=null
$this: GET_VAR '$this$apply: java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?> declared in <root>.plus.<anonymous>' type=java.util.LinkedHashMap<@[FlexibleNullability] K1 of <root>.plus?, @[FlexibleNullability] V1 of <root>.plus?> origin=null
p0: CALL 'public final fun <get-first> (): A of kotlin.Pair declared in kotlin.Pair' type=K1 of <root>.plus origin=GET_PROPERTY
$this: GET_VAR 'pair: kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> origin=null
p1: CALL 'public final fun <get-second> (): B of kotlin.Pair declared in kotlin.Pair' type=V1 of <root>.plus origin=GET_PROPERTY
+2 -1
View File
@@ -2,8 +2,9 @@ fun <K1 : Any?, V1 : Any?> Map<out K1, V1>.plus(pair: Pair<K1, V1>): Map<K1, V1>
return when {
<this>.isEmpty() -> mapOf<K1, V1>(pair = pair)
else -> LinkedHashMap<@FlexibleNullability K1?, @FlexibleNullability V1?>(p0 = <this>).apply<LinkedHashMap<@FlexibleNullability K1?, @FlexibleNullability V1?>>(block = local fun LinkedHashMap<@FlexibleNullability K1?, @FlexibleNullability V1?>.<anonymous>() {
<this>.put(p0 = pair.<get-first>(), p1 = pair.<get-second>()) /*~> Unit */
$this$apply.put(p0 = pair.<get-first>(), p1 = pair.<get-second>()) /*~> Unit */
}
)
}
}