[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
@@ -26,11 +26,11 @@ FILE fqName:<root> fileName:/kt37570.kt
$receiver: CALL 'public final fun a (): kotlin.String declared in <root>' type=kotlin.String origin=null
block: FUN_EXPR type=kotlin.Function1<kotlin.String, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.String) returnType:kotlin.Unit
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
$receiver: VALUE_PARAMETER name:$this$apply type:kotlin.String
BLOCK_BODY
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.String visibility:private [final]' type=kotlin.Unit origin=null
receiver: GET_VAR '<this>: <root>.A declared in <root>.A' type=<root>.A origin=null
value: GET_VAR '<this>: kotlin.String declared in <root>.A.<anonymous>' type=kotlin.String origin=null
value: GET_VAR '$this$apply: kotlin.String declared in <root>.A.<anonymous>' type=kotlin.String origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
+2 -1
View File
@@ -14,9 +14,10 @@ class A {
init {
a().apply<String>(block = local fun String.<anonymous>() {
<this>.#b = <this>
<this>.#b = $this$apply
}
) /*~> Unit */
}
}
+2 -2
View File
@@ -74,14 +74,14 @@ FILE fqName:<root> fileName:/kt47082.kt
<E>: R of <root>.foo
block: FUN_EXPR type=kotlin.Function1<<root>.Derived<IrErrorType(null)>, kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.Derived<IrErrorType(null)>) returnType:kotlin.Unit
$receiver: VALUE_PARAMETER name:<this> type:<root>.Derived<IrErrorType(null)>
$receiver: VALUE_PARAMETER name:$this$produce type:<root>.Derived<IrErrorType(null)>
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
CALL 'public final fun toChannel <E, C> (destination: C of <root>.toChannel): C of <root>.toChannel declared in <root>' type=<root>.Derived<IrErrorType(null)> origin=null
<E>: R of <root>.foo
<C>: <root>.Derived<IrErrorType(null)>
$receiver: GET_VAR 'r: <root>.Receiver<R of <root>.foo> declared in <root>.foo' type=<root>.Receiver<R of <root>.foo> origin=null
destination: GET_VAR '<this>: <root>.Derived<IrErrorType(null)> declared in <root>.foo.<anonymous>' type=<root>.Derived<IrErrorType(null)> origin=null
destination: GET_VAR '$this$produce: <root>.Derived<IrErrorType(null)> declared in <root>.foo.<anonymous>' type=<root>.Derived<IrErrorType(null)> origin=null
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
+2 -1
View File
@@ -20,7 +20,7 @@ fun <E : Any?, C : Base<E>> Receiver<E>.toChannel(destination: C): C {
fun <R : Any?> foo(r: Receiver<R>): R {
return produce<R>(block = local fun Derived<ErrorType>.<anonymous>() {
r.toChannel<R, Derived<ErrorType>>(destination = <this>) /*~> Unit */
r.toChannel<R, Derived<ErrorType>>(destination = $this$produce) /*~> Unit */
}
)
}
@@ -28,3 +28,4 @@ fun <R : Any?> foo(r: Receiver<R>): R {
fun box(): String {
return "OK"
}