[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:
committed by
Mikhail Glukhikh
parent
99293de6e9
commit
e1f6c19c83
@@ -55,12 +55,15 @@ import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrErrorTypeImpl
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.functions
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.psi
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
import org.jetbrains.kotlin.psi.KtQualifiedExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffsetSkippingComments
|
||||
import org.jetbrains.kotlin.resolve.calls.util.isSingleUnderscore
|
||||
import org.jetbrains.kotlin.types.ConstantValueKind
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
@@ -488,16 +491,18 @@ internal fun IrDeclarationParent.declareThisReceiverParameter(
|
||||
thisType: IrType,
|
||||
thisOrigin: IrDeclarationOrigin,
|
||||
startOffset: Int = this.startOffset,
|
||||
endOffset: Int = this.endOffset
|
||||
): IrValueParameter =
|
||||
symbolTable.irFactory.createValueParameter(
|
||||
endOffset: Int = this.endOffset,
|
||||
name: Name = SpecialNames.THIS
|
||||
): IrValueParameter {
|
||||
return symbolTable.irFactory.createValueParameter(
|
||||
startOffset, endOffset, thisOrigin, IrValueParameterSymbolImpl(),
|
||||
SpecialNames.THIS, UNDEFINED_PARAMETER_INDEX, thisType,
|
||||
name, UNDEFINED_PARAMETER_INDEX, thisType,
|
||||
varargElementType = null, isCrossinline = false, isNoinline = false,
|
||||
isHidden = false, isAssignable = false
|
||||
).apply {
|
||||
this.parent = this@declareThisReceiverParameter
|
||||
}
|
||||
}
|
||||
|
||||
fun FirClass.irOrigin(firProvider: FirProvider): IrDeclarationOrigin = when {
|
||||
firProvider.getFirClassifierContainerFileIfAny(symbol) != null -> IrDeclarationOrigin.DEFINED
|
||||
@@ -615,6 +620,15 @@ fun FirSession.createFilesWithGeneratedDeclarations(): List<FirFile> {
|
||||
fun FirDeclaration?.computeIrOrigin(predefinedOrigin: IrDeclarationOrigin? = null): IrDeclarationOrigin {
|
||||
return predefinedOrigin
|
||||
?: (this?.origin as? FirDeclarationOrigin.Plugin)?.let { IrPluginDeclarationOrigin(it.key) }
|
||||
?: ((this as? FirValueParameter)?.source.psi as? KtParameter)?.let {
|
||||
if (it.isSingleUnderscore) {
|
||||
IrDeclarationOrigin.UNDERSCORE_PARAMETER
|
||||
} else if (it.destructuringDeclaration != null) {
|
||||
IrDeclarationOrigin.DESTRUCTURED_OBJECT_PARAMETER
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
?: IrDeclarationOrigin.DEFINED
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -338,12 +338,17 @@ class Fir2IrDeclarationStorage(
|
||||
else parentPropertyReceiverType
|
||||
if (receiverTypeRef != null) {
|
||||
extensionReceiverParameter = receiverTypeRef.convertWithOffsets { startOffset, endOffset ->
|
||||
val name = (function as? FirAnonymousFunction)?.label?.name?.let {
|
||||
val suffix = it.takeIf(Name::isValidIdentifier) ?: "\$receiver"
|
||||
Name.identifier("\$this\$$suffix")
|
||||
} ?: SpecialNames.THIS
|
||||
declareThisReceiverParameter(
|
||||
symbolTable,
|
||||
thisType = receiverTypeRef.toIrType(typeContext),
|
||||
thisOrigin = thisOrigin,
|
||||
startOffset = startOffset,
|
||||
endOffset = endOffset
|
||||
endOffset = endOffset,
|
||||
name = name
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+6
@@ -2462,6 +2462,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
runTest("compiler/testData/ir/irText/lambdas/justLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaReturningUnit.kt")
|
||||
public void testLambdaReturningUnit() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/lambdas/lambdaReturningUnit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFunction.kt")
|
||||
public void testLocalFunction() throws Exception {
|
||||
|
||||
@@ -69,7 +69,7 @@ FILE fqName:<root> fileName:/noSymbolForIntRangeIterator.kt
|
||||
CALL 'public final fun buildString (builderAction: @[ExtensionFunctionType] kotlin.Function1<java.lang.StringBuilder, kotlin.Unit>): kotlin.String [inline] declared in kotlin.text.StringsKt' type=kotlin.String origin=null
|
||||
builderAction: FUN_EXPR type=kotlin.Function1<java.lang.StringBuilder, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:java.lang.StringBuilder) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:<this> type:java.lang.StringBuilder
|
||||
$receiver: VALUE_PARAMETER name:$this$buildString type:java.lang.StringBuilder
|
||||
BLOCK_BODY
|
||||
BLOCK type=kotlin.Unit origin=FOR_LOOP
|
||||
VAR FOR_LOOP_ITERATOR name:tmp_2 type:kotlin.collections.IntIterator [val]
|
||||
@@ -85,7 +85,7 @@ FILE fqName:<root> fileName:/noSymbolForIntRangeIterator.kt
|
||||
CALL 'public final fun next (): kotlin.Int [operator] declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT
|
||||
$this: GET_VAR 'val tmp_2: kotlin.collections.IntIterator [val] declared in <root>.test.localFunc.<anonymous>' type=kotlin.collections.IntIterator origin=null
|
||||
CALL 'public final fun appendLine (value: kotlin.String?): java.lang.StringBuilder [inline] declared in kotlin.text.StringsKt' type=java.lang.StringBuilder origin=null
|
||||
$receiver: GET_VAR '<this>: java.lang.StringBuilder declared in <root>.test.localFunc.<anonymous>' type=java.lang.StringBuilder origin=null
|
||||
$receiver: GET_VAR '$this$buildString: java.lang.StringBuilder declared in <root>.test.localFunc.<anonymous>' type=java.lang.StringBuilder origin=null
|
||||
value: STRING_CONCATENATION type=kotlin.String
|
||||
CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL
|
||||
$this: GET_VAR 'val i: kotlin.Int [val] declared in <root>.test.localFunc' type=kotlin.Int origin=null
|
||||
|
||||
@@ -41,7 +41,9 @@ suspend fun box() {
|
||||
// test.kt:16 box: $continuation:kotlin.coroutines.Continuation=TestKt$box$1, $result:java.lang.Object=null, $i$f$suspendBar:int=0:int, $this$extensionFun$iv$iv:AtomicInt=AtomicInt, $i$f$extensionFun:int=0:int
|
||||
// test.kt:20 box: $continuation:kotlin.coroutines.Continuation=TestKt$box$1, $result:java.lang.Object=null, $i$f$suspendBar:int=0:int
|
||||
// test.kt:21 box: $continuation:kotlin.coroutines.Continuation=TestKt$box$1, $result:java.lang.Object=null, $i$f$suspendBar:int=0:int, $i$a$-suspendCoroutineUninterceptedOrReturn-TestKt$suspendBar$2$iv:int=0:int
|
||||
// EXPECTATIONS CLASSIC_FRONTEND
|
||||
// test.kt:22 box: $continuation:kotlin.coroutines.Continuation=TestKt$box$1, $result:java.lang.Object=null, $i$f$suspendBar:int=0:int, $i$a$-suspendCoroutineUninterceptedOrReturn-TestKt$suspendBar$2$iv:int=0:int
|
||||
// EXPECTATIONS
|
||||
// test.kt:20 box: $continuation:kotlin.coroutines.Continuation=TestKt$box$1, $result:java.lang.Object=null, $i$f$suspendBar:int=0:int
|
||||
// test.kt:23 box: $continuation:kotlin.coroutines.Continuation=TestKt$box$1, $result:java.lang.Object=null, $i$f$suspendBar:int=0:int
|
||||
// test.kt:26 box: $continuation:kotlin.coroutines.Continuation=TestKt$box$1, $result:java.lang.Object=null
|
||||
|
||||
@@ -22,7 +22,7 @@ FILE fqName:<root> fileName:/initValInLambda.kt
|
||||
$receiver: CONST Int type=kotlin.Int value=1
|
||||
block: FUN_EXPR type=kotlin.Function1<kotlin.Int, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:<this> type:kotlin.Int
|
||||
$receiver: VALUE_PARAMETER name:$this$run type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=null
|
||||
receiver: GET_VAR '<this>: <root>.TestInitValInLambdaCalledOnce declared in <root>.TestInitValInLambdaCalledOnce' type=<root>.TestInitValInLambdaCalledOnce origin=null
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -14,9 +14,10 @@ class A {
|
||||
|
||||
init {
|
||||
a().apply<String>(block = local fun String.<anonymous>() {
|
||||
<this>.#b = <this>
|
||||
<this>.#b = $this$apply
|
||||
}
|
||||
) /*~> Unit */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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>'
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
@@ -61,10 +61,10 @@ FILE fqName:<root> fileName:/AllCandidates.kt
|
||||
<R>: @[FlexibleNullability] A of <root>.allCandidatesResult?
|
||||
block: FUN_EXPR type=kotlin.Function1<@[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>?, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:@[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>?) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:<this> type:@[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>?
|
||||
$receiver: VALUE_PARAMETER name:$this$apply type:@[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>?
|
||||
BLOCK_BODY
|
||||
CALL 'public open fun setAllCandidates (allCandidates: @[FlexibleNullability] kotlin.collections.Collection<@[FlexibleNullability] <root>.ResolvedCall<@[FlexibleNullability] D of <root>.OverloadResolutionResultsImpl?>?>?): kotlin.Unit declared in <root>.OverloadResolutionResultsImpl' type=kotlin.Unit origin=EQ
|
||||
$this: GET_VAR '<this>: @[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>? declared in <root>.allCandidatesResult.<anonymous>' type=@[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>? origin=null
|
||||
$this: GET_VAR '$this$apply: @[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>? declared in <root>.allCandidatesResult.<anonymous>' type=@[FlexibleNullability] <root>.OverloadResolutionResultsImpl<@[FlexibleNullability] A of <root>.allCandidatesResult?>? origin=null
|
||||
allCandidates: CALL 'public final fun map <T, R> (transform: kotlin.Function1<T of kotlin.collections.CollectionsKt.map, R of kotlin.collections.CollectionsKt.map>): kotlin.collections.List<R of kotlin.collections.CollectionsKt.map> [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<<root>.ResolvedCall<A of <root>.allCandidatesResult>> origin=null
|
||||
<T>: <root>.MyCandidate
|
||||
<R>: <root>.ResolvedCall<A of <root>.allCandidatesResult>
|
||||
|
||||
@@ -22,10 +22,11 @@ class MyCandidate {
|
||||
|
||||
private fun <A : Any?> allCandidatesResult(allCandidates: Collection<MyCandidate>): @FlexibleNullability OverloadResolutionResultsImpl<@FlexibleNullability A?>? {
|
||||
return nameNotFound<@FlexibleNullability A?>().apply<@FlexibleNullability OverloadResolutionResultsImpl<@FlexibleNullability A?>?>(block = local fun @FlexibleNullability OverloadResolutionResultsImpl<@FlexibleNullability A?>?.<anonymous>() {
|
||||
<this>.setAllCandidates(allCandidates = allCandidates.map<MyCandidate, ResolvedCall<A>>(transform = local fun <anonymous>(it: MyCandidate): ResolvedCall<A> {
|
||||
$this$apply.setAllCandidates(allCandidates = allCandidates.map<MyCandidate, ResolvedCall<A>>(transform = local fun <anonymous>(it: MyCandidate): ResolvedCall<A> {
|
||||
return it.<get-resolvedCall>() as ResolvedCall<A>
|
||||
}
|
||||
))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -622,31 +622,31 @@ FILE fqName:<root> fileName:/typeVariableAfterBuildMap.kt
|
||||
<V>: kotlin.Int
|
||||
builderAction: FUN_EXPR type=kotlin.Function1<kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int>, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int>) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:<this> type:kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int>
|
||||
$receiver: VALUE_PARAMETER name:$this$buildMap type:kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int>
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public abstract fun put (key: K of kotlin.collections.MutableMap, value: V of kotlin.collections.MutableMap): V of kotlin.collections.MutableMap? declared in kotlin.collections.MutableMap' type=kotlin.Int? origin=null
|
||||
$this: GET_VAR '<this>: kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> declared in <root>.Visibilities.ORDERED_VISIBILITIES.<anonymous>' type=kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> origin=null
|
||||
$this: GET_VAR '$this$buildMap: kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> declared in <root>.Visibilities.ORDERED_VISIBILITIES.<anonymous>' type=kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> origin=null
|
||||
key: GET_OBJECT 'CLASS OBJECT name:PrivateToThis modality:FINAL visibility:public superTypes:[<root>.Visibility]' type=<root>.Visibilities.PrivateToThis
|
||||
value: CONST Int type=kotlin.Int value=0
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public abstract fun put (key: K of kotlin.collections.MutableMap, value: V of kotlin.collections.MutableMap): V of kotlin.collections.MutableMap? declared in kotlin.collections.MutableMap' type=kotlin.Int? origin=null
|
||||
$this: GET_VAR '<this>: kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> declared in <root>.Visibilities.ORDERED_VISIBILITIES.<anonymous>' type=kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> origin=null
|
||||
$this: GET_VAR '$this$buildMap: kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> declared in <root>.Visibilities.ORDERED_VISIBILITIES.<anonymous>' type=kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> origin=null
|
||||
key: GET_OBJECT 'CLASS OBJECT name:Private modality:FINAL visibility:public superTypes:[<root>.Visibility]' type=<root>.Visibilities.Private
|
||||
value: CONST Int type=kotlin.Int value=0
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public abstract fun put (key: K of kotlin.collections.MutableMap, value: V of kotlin.collections.MutableMap): V of kotlin.collections.MutableMap? declared in kotlin.collections.MutableMap' type=kotlin.Int? origin=null
|
||||
$this: GET_VAR '<this>: kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> declared in <root>.Visibilities.ORDERED_VISIBILITIES.<anonymous>' type=kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> origin=null
|
||||
$this: GET_VAR '$this$buildMap: kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> declared in <root>.Visibilities.ORDERED_VISIBILITIES.<anonymous>' type=kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> origin=null
|
||||
key: GET_OBJECT 'CLASS OBJECT name:Internal modality:FINAL visibility:public superTypes:[<root>.Visibility]' type=<root>.Visibilities.Internal
|
||||
value: CONST Int type=kotlin.Int value=1
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public abstract fun put (key: K of kotlin.collections.MutableMap, value: V of kotlin.collections.MutableMap): V of kotlin.collections.MutableMap? declared in kotlin.collections.MutableMap' type=kotlin.Int? origin=null
|
||||
$this: GET_VAR '<this>: kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> declared in <root>.Visibilities.ORDERED_VISIBILITIES.<anonymous>' type=kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> origin=null
|
||||
$this: GET_VAR '$this$buildMap: kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> declared in <root>.Visibilities.ORDERED_VISIBILITIES.<anonymous>' type=kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> origin=null
|
||||
key: GET_OBJECT 'CLASS OBJECT name:Protected modality:FINAL visibility:public superTypes:[<root>.Visibility]' type=<root>.Visibilities.Protected
|
||||
value: CONST Int type=kotlin.Int value=1
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public abstract fun put (key: K of kotlin.collections.MutableMap, value: V of kotlin.collections.MutableMap): V of kotlin.collections.MutableMap? declared in kotlin.collections.MutableMap' type=kotlin.Int? origin=null
|
||||
$this: GET_VAR '<this>: kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> declared in <root>.Visibilities.ORDERED_VISIBILITIES.<anonymous>' type=kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> origin=null
|
||||
$this: GET_VAR '$this$buildMap: kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> declared in <root>.Visibilities.ORDERED_VISIBILITIES.<anonymous>' type=kotlin.collections.MutableMap<<root>.Visibility, kotlin.Int> origin=null
|
||||
key: GET_OBJECT 'CLASS OBJECT name:Public modality:FINAL visibility:public superTypes:[<root>.Visibility]' type=<root>.Visibilities.Public
|
||||
value: CONST Int type=kotlin.Int value=2
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-ORDERED_VISIBILITIES> visibility:private modality:FINAL <> ($this:<root>.Visibilities) returnType:kotlin.collections.Map<<root>.Visibility, kotlin.Int>
|
||||
|
||||
+6
-5
@@ -163,13 +163,14 @@ object Visibilities {
|
||||
|
||||
private val ORDERED_VISIBILITIES: Map<Visibility, Int>
|
||||
field = buildMap<Visibility, Int>(builderAction = local fun MutableMap<Visibility, Int>.<anonymous>() {
|
||||
<this>.put(key = PrivateToThis, value = 0) /*~> Unit */
|
||||
<this>.put(key = Private, value = 0) /*~> Unit */
|
||||
<this>.put(key = Internal, value = 1) /*~> Unit */
|
||||
<this>.put(key = Protected, value = 1) /*~> Unit */
|
||||
<this>.put(key = Public, value = 2) /*~> Unit */
|
||||
$this$buildMap.put(key = PrivateToThis, value = 0) /*~> Unit */
|
||||
$this$buildMap.put(key = Private, value = 0) /*~> Unit */
|
||||
$this$buildMap.put(key = Internal, value = 1) /*~> Unit */
|
||||
$this$buildMap.put(key = Protected, value = 1) /*~> Unit */
|
||||
$this$buildMap.put(key = Public, value = 2) /*~> Unit */
|
||||
}
|
||||
)
|
||||
private get
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ FILE fqName:<root> fileName:/destructuringInLambda.kt
|
||||
EXPRESSION_BODY
|
||||
FUN_EXPR type=kotlin.Function1<<root>.A, kotlin.Int> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (<destruct>:<root>.A) returnType:kotlin.Int
|
||||
VALUE_PARAMETER name:<destruct> index:0 type:<root>.A
|
||||
VALUE_PARAMETER DESTRUCTURED_OBJECT_PARAMETER name:<destruct> index:0 type:<root>.A
|
||||
BLOCK_BODY
|
||||
VAR name:y type:kotlin.Int [val]
|
||||
CALL 'public final fun component2 (): kotlin.Int [operator] declared in <root>.A' type=kotlin.Int origin=COMPONENT_N(index=2)
|
||||
|
||||
@@ -8,8 +8,8 @@ FILE fqName:<root> fileName:/extensionLambda.kt
|
||||
$receiver: CONST String type=kotlin.String value="42"
|
||||
block: FUN_EXPR type=kotlin.Function1<kotlin.String, kotlin.Int> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.String) returnType:kotlin.Int
|
||||
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
|
||||
$receiver: VALUE_PARAMETER name:$this$run type:kotlin.String
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Int declared in <root>.test1'
|
||||
CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: kotlin.String declared in <root>.test1.<anonymous>' type=kotlin.String origin=null
|
||||
$this: GET_VAR '$this$run: kotlin.String declared in <root>.test1.<anonymous>' type=kotlin.String origin=null
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
fun test1(): Int {
|
||||
return "42".run<String, Int>(block = local fun String.<anonymous>(): Int {
|
||||
return <this>.<get-length>()
|
||||
return $this$run.<get-length>()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
FILE fqName:<root> fileName:/lambdaReturningUnit.kt
|
||||
FUN name:flaf visibility:public modality:FINAL <> (block:kotlin.Function0<kotlin.Any?>) returnType:kotlin.Unit [inline]
|
||||
VALUE_PARAMETER name:block index:0 type:kotlin.Function0<kotlin.Any?>
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=kotlin.Any? origin=INVOKE
|
||||
$this: GET_VAR 'block: kotlin.Function0<kotlin.Any?> declared in <root>.flaf' type=kotlin.Function0<kotlin.Any?> origin=VARIABLE_AS_FUNCTION
|
||||
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.Unit [suspend]
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun flaf (block: kotlin.Function0<kotlin.Any?>): kotlin.Unit [inline] declared in <root>' type=kotlin.Unit origin=null
|
||||
block: FUN_EXPR type=kotlin.Function0<kotlin.Any?> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Any? declared in <root>.box'
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
@@ -0,0 +1,10 @@
|
||||
inline fun flaf(block: Function0<Any?>) {
|
||||
block.invoke() /*~> Unit */
|
||||
}
|
||||
|
||||
suspend fun box() {
|
||||
flaf(block = local fun <anonymous>(): Any? {
|
||||
return Unit
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
FILE fqName:<root> fileName:/lambdaReturningUnit.kt
|
||||
FUN name:flaf visibility:public modality:FINAL <> (block:kotlin.Function0<kotlin.Any?>) returnType:kotlin.Unit [inline]
|
||||
VALUE_PARAMETER name:block index:0 type:kotlin.Function0<kotlin.Any?>
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=kotlin.Any? origin=INVOKE
|
||||
$this: GET_VAR 'block: kotlin.Function0<kotlin.Any?> declared in <root>.flaf' type=kotlin.Function0<kotlin.Any?> origin=VARIABLE_AS_FUNCTION
|
||||
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.Unit [suspend]
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun flaf (block: kotlin.Function0<kotlin.Any?>): kotlin.Unit [inline] declared in <root>' type=kotlin.Unit origin=null
|
||||
block: FUN_EXPR type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
@@ -0,0 +1,12 @@
|
||||
// With FIR the type of the lambda in box is () -> Any?
|
||||
// With old frontend the type of the lambda is () -> Unit
|
||||
|
||||
inline fun flaf(block: () -> Any?) {
|
||||
block()
|
||||
}
|
||||
|
||||
suspend fun box() {
|
||||
flaf {
|
||||
Unit
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
inline fun flaf(block: Function0<Any?>) {
|
||||
block.invoke() /*~> Unit */
|
||||
}
|
||||
|
||||
suspend fun box() {
|
||||
flaf(block = local fun <anonymous>() {
|
||||
Unit
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ FILE fqName:<root> fileName:/multipleImplicitReceivers.kt
|
||||
receiver: GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.A
|
||||
block: FUN_EXPR type=kotlin.Function1<<root>.A, kotlin.Int> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.A) returnType:kotlin.Int
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
$receiver: VALUE_PARAMETER name:$this$with type:<root>.A
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Int declared in <root>.test'
|
||||
CALL 'public final fun with <T, R> (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1<T of kotlin.StandardKt.with, R of kotlin.StandardKt.with>): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null
|
||||
@@ -101,7 +101,7 @@ FILE fqName:<root> fileName:/multipleImplicitReceivers.kt
|
||||
receiver: GET_VAR 'fooImpl: <root>.IFoo declared in <root>.test' type=<root>.IFoo origin=null
|
||||
block: FUN_EXPR type=kotlin.Function1<<root>.IFoo, kotlin.Int> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.IFoo) returnType:kotlin.Int
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.IFoo
|
||||
$receiver: VALUE_PARAMETER name:$this$with type:<root>.IFoo
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Int declared in <root>.test.<anonymous>'
|
||||
CALL 'public final fun with <T, R> (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1<T of kotlin.StandardKt.with, R of kotlin.StandardKt.with>): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null
|
||||
@@ -110,11 +110,11 @@ FILE fqName:<root> fileName:/multipleImplicitReceivers.kt
|
||||
receiver: GET_VAR 'invokeImpl: <root>.IInvoke declared in <root>.test' type=<root>.IInvoke origin=null
|
||||
block: FUN_EXPR type=kotlin.Function1<<root>.IInvoke, kotlin.Int> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.IInvoke) returnType:kotlin.Int
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.IInvoke
|
||||
$receiver: VALUE_PARAMETER name:$this$with type:<root>.IInvoke
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Int declared in <root>.test.<anonymous>.<anonymous>'
|
||||
CALL 'public open fun invoke (): kotlin.Int [operator] declared in <root>.IInvoke' type=kotlin.Int origin=null
|
||||
$this: GET_VAR '<this>: <root>.IInvoke declared in <root>.test.<anonymous>.<anonymous>.<anonymous>' type=<root>.IInvoke origin=null
|
||||
$this: GET_VAR '$this$with: <root>.IInvoke declared in <root>.test.<anonymous>.<anonymous>.<anonymous>' type=<root>.IInvoke origin=null
|
||||
$receiver: CALL 'public open fun <get-foo> (): <root>.B declared in <root>.IFoo' type=<root>.B origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.IFoo declared in <root>.test.<anonymous>.<anonymous>' type=<root>.IFoo origin=null
|
||||
$receiver: GET_VAR '<this>: <root>.A declared in <root>.test.<anonymous>' type=<root>.A origin=null
|
||||
$this: GET_VAR '$this$with: <root>.IFoo declared in <root>.test.<anonymous>.<anonymous>' type=<root>.IFoo origin=null
|
||||
$receiver: GET_VAR '$this$with: <root>.A declared in <root>.test.<anonymous>' type=<root>.A origin=null
|
||||
|
||||
@@ -35,7 +35,7 @@ fun test(fooImpl: IFoo, invokeImpl: IInvoke) {
|
||||
with<A, Int>(receiver = A, block = local fun A.<anonymous>(): Int {
|
||||
return with<IFoo, Int>(receiver = fooImpl, block = local fun IFoo.<anonymous>(): Int {
|
||||
return with<IInvoke, Int>(receiver = invokeImpl, block = local fun IInvoke.<anonymous>(): Int {
|
||||
return (<this>, (<this>, <this>).<get-foo>()).invoke()
|
||||
return ($this$with, ($this$with, $this$with).<get-foo>()).invoke()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -43,3 +43,4 @@ fun test(fooImpl: IFoo, invokeImpl: IInvoke) {
|
||||
}
|
||||
) /*~> Unit */
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -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
@@ -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 */
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -12,19 +12,19 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
|
||||
<T>: R of <root>.scopedFlow
|
||||
block: FUN_EXPR type=kotlin.coroutines.SuspendFunction1<<root>.FlowCollector<R of <root>.scopedFlow>, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.FlowCollector<R of <root>.scopedFlow>) returnType:kotlin.Unit [suspend]
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.FlowCollector<R of <root>.scopedFlow>
|
||||
$receiver: VALUE_PARAMETER name:$this$flow type:<root>.FlowCollector<R of <root>.scopedFlow>
|
||||
BLOCK_BODY
|
||||
VAR name:collector type:<root>.FlowCollector<R of <root>.scopedFlow> [val]
|
||||
GET_VAR '<this>: <root>.FlowCollector<R of <root>.scopedFlow> declared in <root>.scopedFlow.<anonymous>' type=<root>.FlowCollector<R of <root>.scopedFlow> origin=null
|
||||
GET_VAR '$this$flow: <root>.FlowCollector<R of <root>.scopedFlow> declared in <root>.scopedFlow.<anonymous>' type=<root>.FlowCollector<R of <root>.scopedFlow> origin=null
|
||||
CALL 'public final fun flowScope <R> (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<<root>.CoroutineScope, R of <root>.flowScope>): R of <root>.flowScope [suspend] declared in <root>' type=kotlin.Unit origin=null
|
||||
<R>: kotlin.Unit
|
||||
block: FUN_EXPR type=kotlin.coroutines.SuspendFunction1<<root>.CoroutineScope, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.CoroutineScope) returnType:kotlin.Unit [suspend]
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.CoroutineScope
|
||||
$receiver: VALUE_PARAMETER name:$this$flowScope type:<root>.CoroutineScope
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun invoke (p1: P1 of kotlin.coroutines.SuspendFunction2, p2: P2 of kotlin.coroutines.SuspendFunction2): R of kotlin.coroutines.SuspendFunction2 [suspend,operator] declared in kotlin.coroutines.SuspendFunction2' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR 'block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<<root>.CoroutineScope, <root>.FlowCollector<R of <root>.scopedFlow>, kotlin.Unit> declared in <root>.scopedFlow' type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<<root>.CoroutineScope, <root>.FlowCollector<R of <root>.scopedFlow>, kotlin.Unit> origin=VARIABLE_AS_FUNCTION
|
||||
p1: GET_VAR '<this>: <root>.CoroutineScope declared in <root>.scopedFlow.<anonymous>.<anonymous>' type=<root>.CoroutineScope origin=null
|
||||
p1: GET_VAR '$this$flowScope: <root>.CoroutineScope declared in <root>.scopedFlow.<anonymous>.<anonymous>' type=<root>.CoroutineScope origin=null
|
||||
p2: GET_VAR 'val collector: <root>.FlowCollector<R of <root>.scopedFlow> [val] declared in <root>.scopedFlow.<anonymous>' type=<root>.FlowCollector<R of <root>.scopedFlow> origin=null
|
||||
FUN name:onCompletion visibility:public modality:FINAL <T> ($receiver:<root>.Flow<T of <root>.onCompletion>, action:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<<root>.FlowCollector<T of <root>.onCompletion>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit>) returnType:<root>.Flow<T of <root>.onCompletion>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
@@ -36,12 +36,12 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
|
||||
<T>: T of <root>.onCompletion
|
||||
block: FUN_EXPR type=kotlin.coroutines.SuspendFunction1<<root>.FlowCollector<T of <root>.onCompletion>, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.FlowCollector<T of <root>.onCompletion>) returnType:kotlin.Unit [suspend]
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.FlowCollector<T of <root>.onCompletion>
|
||||
$receiver: VALUE_PARAMETER name:$this$unsafeFlow type:<root>.FlowCollector<T of <root>.onCompletion>
|
||||
BLOCK_BODY
|
||||
VAR name:safeCollector type:<root>.SafeCollector<T of <root>.onCompletion> [val]
|
||||
CONSTRUCTOR_CALL 'public constructor <init> (collector: <root>.FlowCollector<T of <root>.SafeCollector>) [primary] declared in <root>.SafeCollector' type=<root>.SafeCollector<T of <root>.onCompletion> origin=null
|
||||
<class: T>: T of <root>.onCompletion
|
||||
collector: GET_VAR '<this>: <root>.FlowCollector<T of <root>.onCompletion> declared in <root>.onCompletion.<anonymous>' type=<root>.FlowCollector<T of <root>.onCompletion> origin=null
|
||||
collector: GET_VAR '$this$unsafeFlow: <root>.FlowCollector<T of <root>.onCompletion> declared in <root>.onCompletion.<anonymous>' type=<root>.FlowCollector<T of <root>.onCompletion> origin=null
|
||||
CALL 'public final fun invokeSafely <T> (action: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<<root>.FlowCollector<T of <root>.invokeSafely>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit>): kotlin.Unit [suspend] declared in <root>' type=kotlin.Unit origin=null
|
||||
<T>: T of <root>.onCompletion
|
||||
$receiver: GET_VAR 'val safeCollector: <root>.SafeCollector<T of <root>.onCompletion> [val] declared in <root>.onCompletion.<anonymous>' type=<root>.SafeCollector<T of <root>.onCompletion> origin=null
|
||||
@@ -74,7 +74,7 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
|
||||
$receiver: GET_VAR '<this>: <root>.Flow<T of <root>.onCompletion> declared in <root>.onCompletion' type=<root>.Flow<T of <root>.onCompletion> origin=null
|
||||
action: FUN_EXPR type=kotlin.coroutines.SuspendFunction2<<root>.FlowCollector<T of <root>.onCompletion>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.FlowCollector<T of <root>.onCompletion>, it:@[ParameterName(name = 'cause')] kotlin.Throwable?) returnType:kotlin.Unit [suspend]
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.FlowCollector<T of <root>.onCompletion>
|
||||
$receiver: VALUE_PARAMETER name:$this$onCompletion type:<root>.FlowCollector<T of <root>.onCompletion>
|
||||
VALUE_PARAMETER name:it index:0 type:@[ParameterName(name = 'cause')] kotlin.Throwable?
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun invoke (p1: P1 of kotlin.coroutines.SuspendFunction1): R of kotlin.coroutines.SuspendFunction1 [suspend,operator] declared in kotlin.coroutines.SuspendFunction1' type=kotlin.Unit origin=null
|
||||
@@ -90,12 +90,12 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
|
||||
$receiver: GET_VAR '<this>: <root>.CoroutineScope declared in <root>.asFairChannel' type=<root>.CoroutineScope origin=null
|
||||
block: FUN_EXPR type=kotlin.coroutines.SuspendFunction1<<root>.ProducerScope<kotlin.Any>, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.ProducerScope<kotlin.Any>) returnType:kotlin.Unit [suspend]
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.ProducerScope<kotlin.Any>
|
||||
$receiver: VALUE_PARAMETER name:$this$produce type:<root>.ProducerScope<kotlin.Any>
|
||||
BLOCK_BODY
|
||||
VAR name:channel type:<root>.ChannelCoroutine<kotlin.Any> [val]
|
||||
TYPE_OP type=<root>.ChannelCoroutine<kotlin.Any> origin=CAST typeOperand=<root>.ChannelCoroutine<kotlin.Any>
|
||||
CALL 'public abstract fun <get-channel> (): <root>.SendChannel<E of <root>.ProducerScope> declared in <root>.ProducerScope' type=<root>.SendChannel<kotlin.Nothing> origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.ProducerScope<kotlin.Any> declared in <root>.asFairChannel.<anonymous>' type=<root>.ProducerScope<kotlin.Nothing> origin=null
|
||||
$this: GET_VAR '$this$produce: <root>.ProducerScope<kotlin.Any> declared in <root>.asFairChannel.<anonymous>' type=<root>.ProducerScope<kotlin.Nothing> origin=null
|
||||
CALL 'public final fun collect <T> (action: kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'value')] T of <root>.collect, kotlin.Unit>): kotlin.Unit [inline,suspend] declared in <root>' type=kotlin.Unit origin=null
|
||||
<T>: kotlin.Any?
|
||||
$receiver: GET_VAR 'flow: <root>.Flow<*> declared in <root>.asFairChannel' type=<root>.Flow<*> origin=null
|
||||
@@ -128,7 +128,7 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
|
||||
$receiver: GET_VAR '<this>: <root>.CoroutineScope declared in <root>.asChannel' type=<root>.CoroutineScope origin=null
|
||||
block: FUN_EXPR type=kotlin.coroutines.SuspendFunction1<<root>.ProducerScope<@[ParameterName(name = 'value')] kotlin.Any>, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.ProducerScope<@[ParameterName(name = 'value')] kotlin.Any>) returnType:kotlin.Unit [suspend]
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.ProducerScope<@[ParameterName(name = 'value')] kotlin.Any>
|
||||
$receiver: VALUE_PARAMETER name:$this$produce type:<root>.ProducerScope<@[ParameterName(name = 'value')] kotlin.Any>
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun collect <T> (action: kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'value')] T of <root>.collect, kotlin.Unit>): kotlin.Unit [inline,suspend] declared in <root>' type=kotlin.Unit origin=null
|
||||
<T>: kotlin.Any?
|
||||
@@ -140,7 +140,7 @@ FILE fqName:<root> fileName:/castsInsideCoroutineInference.kt
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (value: @[ParameterName(name = 'value')] kotlin.Any?): kotlin.Unit [suspend] declared in <root>.asChannel.<anonymous>'
|
||||
CALL 'public abstract fun send (e: E of <root>.SendChannel): kotlin.Unit [suspend] declared in <root>.SendChannel' type=kotlin.Unit origin=null
|
||||
$this: CALL 'public abstract fun <get-channel> (): <root>.SendChannel<E of <root>.ProducerScope> declared in <root>.ProducerScope' type=<root>.SendChannel<@[ParameterName(name = 'value')] kotlin.Any> origin=GET_PROPERTY
|
||||
$this: GET_VAR '<this>: <root>.ProducerScope<@[ParameterName(name = 'value')] kotlin.Any> declared in <root>.asChannel.<anonymous>' type=<root>.ProducerScope<@[ParameterName(name = 'value')] kotlin.Any> origin=null
|
||||
$this: GET_VAR '$this$produce: <root>.ProducerScope<@[ParameterName(name = 'value')] kotlin.Any> declared in <root>.asChannel.<anonymous>' type=<root>.ProducerScope<@[ParameterName(name = 'value')] kotlin.Any> origin=null
|
||||
e: BLOCK type=@[ParameterName(name = 'value')] kotlin.Any origin=ELVIS
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:@[ParameterName(name = 'value')] kotlin.Any? [val]
|
||||
GET_VAR 'value: @[ParameterName(name = 'value')] kotlin.Any? declared in <root>.asChannel.<anonymous>.<anonymous>' type=@[ParameterName(name = 'value')] kotlin.Any? origin=null
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
@OptIn(markerClass = [ExperimentalTypeInference::class])
|
||||
fun <R : Any?> scopedFlow(@BuilderInference block: @ExtensionFunctionType SuspendFunction2<CoroutineScope, FlowCollector<R>, Unit>): Flow<R> {
|
||||
return flow<R>(block = local suspend fun FlowCollector<R>.<anonymous>() {
|
||||
val collector: FlowCollector<R> = <this>
|
||||
val collector: FlowCollector<R> = $this$flow
|
||||
flowScope<Unit>(block = local suspend fun CoroutineScope.<anonymous>() {
|
||||
block.invoke(p1 = <this>, p2 = collector)
|
||||
block.invoke(p1 = $this$flowScope, p2 = collector)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -12,7 +12,7 @@ fun <R : Any?> scopedFlow(@BuilderInference block: @ExtensionFunctionType Suspen
|
||||
|
||||
fun <T : Any?> Flow<T>.onCompletion(action: @ExtensionFunctionType SuspendFunction2<FlowCollector<T>, @ParameterName(name = "cause") Throwable?, Unit>): Flow<T> {
|
||||
return unsafeFlow<T>(block = local suspend fun FlowCollector<T>.<anonymous>() {
|
||||
val safeCollector: SafeCollector<T> = SafeCollector<T>(collector = <this>)
|
||||
val safeCollector: SafeCollector<T> = SafeCollector<T>(collector = $this$unsafeFlow)
|
||||
safeCollector.invokeSafely<T>(action = action)
|
||||
}
|
||||
)
|
||||
@@ -36,7 +36,7 @@ fun <T : Any?> Flow<T>.onCompletion(action: SuspendFunction1<@ParameterName(name
|
||||
|
||||
private fun CoroutineScope.asFairChannel(flow: Flow<*>): ReceiveChannel<Any> {
|
||||
return <this>.produce<Any>(block = local suspend fun ProducerScope<Any>.<anonymous>() {
|
||||
val channel: ChannelCoroutine<Any> = <this>.<get-channel>() as ChannelCoroutine<Any>
|
||||
val channel: ChannelCoroutine<Any> = $this$produce.<get-channel>() as ChannelCoroutine<Any>
|
||||
flow.collect<Any?>(action = local suspend fun <anonymous>(value: @ParameterName(name = "value") Any?) {
|
||||
return channel.sendFair(element = { // BLOCK
|
||||
val <elvis>: @ParameterName(name = "value") Any? = value
|
||||
@@ -54,7 +54,7 @@ private fun CoroutineScope.asFairChannel(flow: Flow<*>): ReceiveChannel<Any> {
|
||||
private fun CoroutineScope.asChannel(flow: Flow<*>): ReceiveChannel<Any> {
|
||||
return <this>.produce<@ParameterName(name = "value") Any>(block = local suspend fun ProducerScope<@ParameterName(name = "value") Any>.<anonymous>() {
|
||||
flow.collect<Any?>(action = local suspend fun <anonymous>(value: @ParameterName(name = "value") Any?) {
|
||||
return <this>.<get-channel>().send(e = { // BLOCK
|
||||
return $this$produce.<get-channel>().send(e = { // BLOCK
|
||||
val <elvis>: @ParameterName(name = "value") Any? = value
|
||||
when {
|
||||
EQEQ(arg0 = <elvis>, arg1 = null) -> Any()
|
||||
@@ -141,3 +141,4 @@ interface SendChannel<in E : Any?> {
|
||||
abstract suspend fun send(e: E)
|
||||
|
||||
}
|
||||
|
||||
|
||||
Generated
+6
@@ -2462,6 +2462,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest {
|
||||
runTest("compiler/testData/ir/irText/lambdas/justLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaReturningUnit.kt")
|
||||
public void testLambdaReturningUnit() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/lambdas/lambdaReturningUnit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localFunction.kt")
|
||||
public void testLocalFunction() throws Exception {
|
||||
|
||||
+20
-2
@@ -11,6 +11,8 @@ import com.sun.jdi.request.EventRequest.SUSPEND_ALL
|
||||
import com.sun.jdi.request.StepRequest
|
||||
import com.sun.tools.jdi.SocketAttachingConnector
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.model.FrontendKind
|
||||
import org.jetbrains.kotlin.test.model.FrontendKinds
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertEqualsToFile
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
@@ -27,12 +29,15 @@ abstract class DebugRunner(testServices: TestServices) : JvmBoxRunner(testServic
|
||||
const val FORCE_STEP_INTO_MARKER = "// FORCE_STEP_INTO"
|
||||
const val JVM_EXPECTATIONS_MARKER = "$EXPECTATIONS_MARKER JVM"
|
||||
const val JVM_IR_EXPECTATIONS_MARKER = "$EXPECTATIONS_MARKER JVM_IR"
|
||||
const val CLASSIC_FRONTEND_EXPECTATIONS_MARKER = "$EXPECTATIONS_MARKER CLASSIC_FRONTEND"
|
||||
const val FIR_EXPECTATIONS_MARKER = "$EXPECTATIONS_MARKER FIR"
|
||||
|
||||
val BOX_MAIN_FILE_CLASS_NAME = BOX_MAIN_FILE_NAME.replace(".kt", "Kt")
|
||||
}
|
||||
|
||||
private var wholeFile = File("")
|
||||
private var backend = TargetBackend.JVM
|
||||
private var frontend: FrontendKind<*> = FrontendKinds.ClassicFrontend
|
||||
|
||||
abstract fun storeStep(loggedItems: ArrayList<LoggedData>, event: Event)
|
||||
|
||||
@@ -42,8 +47,9 @@ abstract class DebugRunner(testServices: TestServices) : JvmBoxRunner(testServic
|
||||
classPath: List<URL>,
|
||||
mainClassAndArguments: List<String>
|
||||
): Process {
|
||||
// Extract target backend and the full test file used to extract test expectations.
|
||||
// Extract target backend, frontend, and the full test file used to extract test expectations.
|
||||
backend = module.targetBackend ?: backend
|
||||
frontend = module.frontendKind
|
||||
wholeFile = module.files.single { it.name == "test.kt" }.originalFile
|
||||
|
||||
// Setup the java process to suspend waiting for debugging connection on a free port.
|
||||
@@ -187,6 +193,7 @@ abstract class DebugRunner(testServices: TestServices) : JvmBoxRunner(testServic
|
||||
}
|
||||
|
||||
var currentBackend = TargetBackend.ANY
|
||||
var currentFrontend = frontend
|
||||
for (line in lineIterator) {
|
||||
if (line.isEmpty()) {
|
||||
actual.add(line)
|
||||
@@ -198,11 +205,22 @@ abstract class DebugRunner(testServices: TestServices) : JvmBoxRunner(testServic
|
||||
EXPECTATIONS_MARKER -> TargetBackend.ANY
|
||||
JVM_EXPECTATIONS_MARKER -> TargetBackend.JVM
|
||||
JVM_IR_EXPECTATIONS_MARKER -> TargetBackend.JVM_IR
|
||||
CLASSIC_FRONTEND_EXPECTATIONS_MARKER -> currentBackend
|
||||
FIR_EXPECTATIONS_MARKER -> currentBackend
|
||||
else -> error("Expected JVM backend: $line")
|
||||
}
|
||||
currentFrontend = when (line) {
|
||||
EXPECTATIONS_MARKER -> frontend
|
||||
JVM_EXPECTATIONS_MARKER -> currentFrontend
|
||||
JVM_IR_EXPECTATIONS_MARKER -> currentFrontend
|
||||
CLASSIC_FRONTEND_EXPECTATIONS_MARKER -> FrontendKinds.ClassicFrontend
|
||||
FIR_EXPECTATIONS_MARKER -> FrontendKinds.FIR
|
||||
else -> error("Expected JVM backend: $line")
|
||||
}
|
||||
continue
|
||||
}
|
||||
if (currentBackend == TargetBackend.ANY || currentBackend == backend) {
|
||||
if ((currentBackend == TargetBackend.ANY || currentBackend == backend) &&
|
||||
currentFrontend == frontend) {
|
||||
if (actualLineNumbersIterator.hasNext()) {
|
||||
actual.add(actualLineNumbersIterator.next())
|
||||
}
|
||||
|
||||
@@ -1831,6 +1831,11 @@ public class KlibTextTestCaseGenerated extends AbstractKlibTextTestCase {
|
||||
runTest("compiler/testData/ir/irText/lambdas/justLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaReturningUnit.kt")
|
||||
public void testLambdaReturningUnit() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/lambdas/lambdaReturningUnit.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunction.kt")
|
||||
public void testLocalFunction() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/lambdas/localFunction.kt");
|
||||
|
||||
Reference in New Issue
Block a user