diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index 0785679a3c6..e9b4b0cbeb5 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -1827,6 +1827,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/types/asOnPlatformType.kt"); } + @TestMetadata("castsInsideCoroutineInference.kt") + public void testCastsInsideCoroutineInference() throws Exception { + runTest("compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt"); + } + @TestMetadata("coercionToUnitInLambdaReturnValue.kt") public void testCoercionToUnitInLambdaReturnValue() throws Exception { runTest("compiler/testData/ir/irText/types/coercionToUnitInLambdaReturnValue.kt"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt index 255e712916c..d484f2dcde2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt @@ -773,13 +773,14 @@ class NewResolvedCallImpl( } is FunctionDescriptor -> candidateDescriptor.substituteInferredVariablesAndApproximate(substitutor) is PropertyDescriptor -> { - val shouldRunApproximation = candidateDescriptor.returnType?.let { type -> + val shouldForceApproximationAndSubstitution = candidateDescriptor.returnType?.let { type -> type.contains { it is NewCapturedType } || type.contains { it.constructor is IntegerLiteralTypeConstructor } || - type.contains { it is DefinitelyNotNullType } + type.contains { it is DefinitelyNotNullType } || + type.contains { it is StubType } } ?: false - if (candidateDescriptor.typeParameters.isNotEmpty() || shouldRunApproximation) + if (candidateDescriptor.typeParameters.isNotEmpty() || shouldForceApproximationAndSubstitution) candidateDescriptor.substituteInferredVariablesAndApproximate(substitutor) else candidateDescriptor diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt new file mode 100644 index 00000000000..812f8130137 --- /dev/null +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt @@ -0,0 +1,180 @@ +FILE fqName: fileName:/castsInsideCoroutineInference.kt + FUN name:asFairChannel visibility:private modality:FINAL <> ($receiver:.CoroutineScope, flow:.Flow<*>) returnType:.ReceiveChannel + $receiver: VALUE_PARAMETER name: type:.CoroutineScope + VALUE_PARAMETER name:flow index:0 type:.Flow<*> + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun asFairChannel (flow: .Flow<*>): .ReceiveChannel declared in ' + CALL 'public final fun produce (block: kotlin.Function1<.ProducerScope.produce>, kotlin.Unit>): .ReceiveChannel.produce> declared in ' type=.ReceiveChannel origin=null + : kotlin.Any + $receiver: GET_VAR ': .CoroutineScope declared in .asFairChannel' type=.CoroutineScope origin=null + block: FUN_EXPR type=kotlin.Function1<.ProducerScope, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.ProducerScope) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name: type:.ProducerScope + BLOCK_BODY + VAR name:channel type:.ChannelCoroutine [val] + TYPE_OP type=.ChannelCoroutine origin=CAST typeOperand=.ChannelCoroutine + CALL 'public abstract fun (): .SendChannel declared in .ProducerScope' type=.SendChannel origin=null + $this: GET_VAR ': .ProducerScope declared in special.' type=.ProducerScope origin=null + CALL 'public abstract fun collect (collector: .FlowCollector): kotlin.Unit [suspend] declared in .Flow' type=kotlin.Unit origin=null + $this: GET_VAR 'flow: .Flow<*> declared in .asFairChannel' type=.Flow<*> origin=null + collector: FUN_EXPR type=kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (value:kotlin.Any?) returnType:kotlin.Unit + VALUE_PARAMETER name:value index:0 type:kotlin.Any? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (value: kotlin.Any?): kotlin.Unit declared in .asFairChannel.' + CALL 'public final fun sendFair (element: kotlin.Any): kotlin.Unit [suspend] declared in .ChannelCoroutine' type=kotlin.Unit origin=null + $this: GET_VAR 'val channel: .ChannelCoroutine [val] declared in .asFairChannel.' type=.ChannelCoroutine origin=null + element: BLOCK type=kotlin.Any origin=ELVIS + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any? [val] + GET_VAR 'value: kotlin.Any? declared in .asFairChannel..' type=kotlin.Any? origin=null + WHEN type=kotlin.Any origin=ELVIS + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in .asFairChannel..' type=kotlin.Any? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any + GET_VAR 'val tmp_0: kotlin.Any? [val] declared in .asFairChannel..' type=kotlin.Any? origin=null + FUN name:collect visibility:public modality:FINAL ($receiver:.Flow.collect>, action:kotlin.Function1.collect, kotlin.Unit>) returnType:kotlin.Unit [inline,suspend] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.Flow.collect> + VALUE_PARAMETER name:action index:0 type:kotlin.Function1.collect, kotlin.Unit> [crossinline] + BLOCK_BODY + CLASS CLASS name:ChannelCoroutine modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ChannelCoroutine.ChannelCoroutine> + TYPE_PARAMETER name:E index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> () returnType:.ChannelCoroutine.ChannelCoroutine> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ChannelCoroutine modality:OPEN visibility:public superTypes:[kotlin.Any]' + FUN name:sendFair visibility:public modality:FINAL <> ($this:.ChannelCoroutine.ChannelCoroutine>, element:E of .ChannelCoroutine) returnType:kotlin.Unit [suspend] + $this: VALUE_PARAMETER name: type:.ChannelCoroutine.ChannelCoroutine> + VALUE_PARAMETER name:element index:0 type:E of .ChannelCoroutine + BLOCK_BODY + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:CoroutineScope modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.CoroutineScope + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:Flow modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Flow.Flow> + TYPE_PARAMETER name:T index:0 variance:out superTypes:[kotlin.Any?] + FUN name:collect visibility:public modality:ABSTRACT <> ($this:.Flow.Flow>, collector:.FlowCollector.Flow>) returnType:kotlin.Unit [suspend] + $this: VALUE_PARAMETER name: type:.Flow.Flow> + VALUE_PARAMETER name:collector index:0 type:.FlowCollector.Flow> + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:FlowCollector modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FlowCollector.FlowCollector> + TYPE_PARAMETER name:T index:0 variance:in superTypes:[kotlin.Any?] + FUN name:emit visibility:public modality:ABSTRACT <> ($this:.FlowCollector.FlowCollector>, value:T of .FlowCollector) returnType:kotlin.Unit [suspend] + $this: VALUE_PARAMETER name: type:.FlowCollector.FlowCollector> + VALUE_PARAMETER name:value index:0 type:T of .FlowCollector + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:ReceiveChannel modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ReceiveChannel.ReceiveChannel> + TYPE_PARAMETER name:E index:0 variance:out superTypes:[kotlin.Any?] + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:produce visibility:public modality:FINAL ($receiver:.CoroutineScope, block:kotlin.Function1<.ProducerScope.produce>, kotlin.Unit>) returnType:.ReceiveChannel.produce> + TYPE_PARAMETER name:E index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.CoroutineScope + VALUE_PARAMETER name:block index:0 type:kotlin.Function1<.ProducerScope.produce>, kotlin.Unit> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun produce (block: kotlin.Function1<.ProducerScope.produce>, kotlin.Unit>): .ReceiveChannel.produce> declared in ' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CLASS INTERFACE name:ProducerScope modality:ABSTRACT visibility:public superTypes:[.CoroutineScope; .SendChannel.ProducerScope>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ProducerScope.ProducerScope> + TYPE_PARAMETER name:E index:0 variance:in superTypes:[kotlin.Any?] + PROPERTY name:channel visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.ProducerScope.ProducerScope>) returnType:.SendChannel.ProducerScope> + correspondingProperty: PROPERTY name:channel visibility:public modality:ABSTRACT [val] + $this: VALUE_PARAMETER name: type:.ProducerScope.ProducerScope> + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:SendChannel modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.SendChannel.SendChannel> + TYPE_PARAMETER name:E index:0 variance:in superTypes:[kotlin.Any?] + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt new file mode 100644 index 00000000000..3f42b3acdb2 --- /dev/null +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt @@ -0,0 +1,38 @@ +// WITH_RUNTIME + +import kotlin.experimental.ExperimentalTypeInference + +private fun CoroutineScope.asFairChannel(flow: Flow<*>): ReceiveChannel = produce { + val channel = channel as ChannelCoroutine + flow.collect { value -> + return@collect channel.sendFair(value ?: Any()) + } +} + +suspend inline fun Flow.collect(crossinline action: suspend (value: T) -> Unit) {} + +open class ChannelCoroutine { + suspend fun sendFair(element: E) {} +} + +interface CoroutineScope +interface Flow { + suspend fun collect(collector: FlowCollector) +} + +interface FlowCollector { + suspend fun emit(value: T) +} + +interface ReceiveChannel + +@OptIn(ExperimentalTypeInference::class) +fun CoroutineScope.produce( + @BuilderInference block: suspend ProducerScope.() -> Unit +): ReceiveChannel = TODO() + +interface ProducerScope : CoroutineScope, SendChannel { + val channel: SendChannel +} + +interface SendChannel \ No newline at end of file diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.txt new file mode 100644 index 00000000000..4c136265bec --- /dev/null +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.txt @@ -0,0 +1,186 @@ +FILE fqName: fileName:/castsInsideCoroutineInference.kt + FUN name:asFairChannel visibility:private modality:FINAL <> ($receiver:.CoroutineScope, flow:.Flow<*>) returnType:.ReceiveChannel + $receiver: VALUE_PARAMETER name: type:.CoroutineScope + VALUE_PARAMETER name:flow index:0 type:.Flow<*> + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun asFairChannel (flow: .Flow<*>): .ReceiveChannel declared in ' + CALL 'public final fun produce (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.ProducerScope.produce>, kotlin.Unit>): .ReceiveChannel.produce> declared in ' type=.ReceiveChannel origin=null + : kotlin.Any + $receiver: GET_VAR ': .CoroutineScope declared in .asFairChannel' type=.CoroutineScope origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.ProducerScope, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.ProducerScope) returnType:kotlin.Unit [suspend] + $receiver: VALUE_PARAMETER name: type:.ProducerScope + BLOCK_BODY + VAR name:channel type:.ChannelCoroutine [val] + TYPE_OP type=.ChannelCoroutine origin=CAST typeOperand=.ChannelCoroutine + CALL 'public abstract fun (): .SendChannel.ProducerScope> declared in .ProducerScope' type=.SendChannel origin=GET_PROPERTY + $this: GET_VAR ': .ProducerScope declared in .asFairChannel.' type=.ProducerScope origin=null + CALL 'public final fun collect (action: kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'value')] T of .collect, kotlin.Unit>): kotlin.Unit [inline,suspend] declared in ' type=kotlin.Unit origin=null + : kotlin.Any? + $receiver: GET_VAR 'flow: .Flow<*> declared in .asFairChannel' type=.Flow<*> origin=null + action: FUN_EXPR type=kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'value')] kotlin.Any?, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (value:kotlin.Any?) returnType:kotlin.Unit [suspend] + VALUE_PARAMETER name:value index:0 type:kotlin.Any? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (value: kotlin.Any?): kotlin.Unit [suspend] declared in .asFairChannel.' + CALL 'public final fun sendFair (element: E of .ChannelCoroutine): kotlin.Unit [suspend] declared in .ChannelCoroutine' type=kotlin.Unit origin=null + $this: GET_VAR 'val channel: .ChannelCoroutine [val] declared in .asFairChannel.' type=.ChannelCoroutine origin=null + element: BLOCK type=kotlin.Any origin=ELVIS + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any? [val] + GET_VAR 'value: kotlin.Any? declared in .asFairChannel..' type=kotlin.Any? origin=null + WHEN type=kotlin.Any origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in .asFairChannel..' type=kotlin.Any? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in .asFairChannel..' type=kotlin.Any? origin=null + FUN name:collect visibility:public modality:FINAL ($receiver:.Flow.collect>, action:kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'value')] T of .collect, kotlin.Unit>) returnType:kotlin.Unit [inline,suspend] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.Flow.collect> + VALUE_PARAMETER name:action index:0 type:kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'value')] T of .collect, kotlin.Unit> [crossinline] + BLOCK_BODY + CLASS CLASS name:ChannelCoroutine modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ChannelCoroutine.ChannelCoroutine> + TYPE_PARAMETER name:E index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> () returnType:.ChannelCoroutine.ChannelCoroutine> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ChannelCoroutine modality:OPEN visibility:public superTypes:[kotlin.Any]' + FUN name:sendFair visibility:public modality:FINAL <> ($this:.ChannelCoroutine.ChannelCoroutine>, element:E of .ChannelCoroutine) returnType:kotlin.Unit [suspend] + $this: VALUE_PARAMETER name: type:.ChannelCoroutine.ChannelCoroutine> + VALUE_PARAMETER name:element index:0 type:E of .ChannelCoroutine + BLOCK_BODY + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:CoroutineScope modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.CoroutineScope + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:Flow modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Flow.Flow> + TYPE_PARAMETER name:T index:0 variance:out superTypes:[kotlin.Any?] + FUN name:collect visibility:public modality:ABSTRACT <> ($this:.Flow.Flow>, collector:.FlowCollector.Flow>) returnType:kotlin.Unit [suspend] + $this: VALUE_PARAMETER name: type:.Flow.Flow> + VALUE_PARAMETER name:collector index:0 type:.FlowCollector.Flow> + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:FlowCollector modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FlowCollector.FlowCollector> + TYPE_PARAMETER name:T index:0 variance:in superTypes:[kotlin.Any?] + FUN name:emit visibility:public modality:ABSTRACT <> ($this:.FlowCollector.FlowCollector>, value:T of .FlowCollector) returnType:kotlin.Unit [suspend] + $this: VALUE_PARAMETER name: type:.FlowCollector.FlowCollector> + VALUE_PARAMETER name:value index:0 type:T of .FlowCollector + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:ReceiveChannel modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ReceiveChannel.ReceiveChannel> + TYPE_PARAMETER name:E index:0 variance:out superTypes:[kotlin.Any?] + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:produce visibility:public modality:FINAL ($receiver:.CoroutineScope, block:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.ProducerScope.produce>, kotlin.Unit>) returnType:.ReceiveChannel.produce> + annotations: + OptIn(markerClass = [CLASS_REFERENCE 'CLASS IR_EXTERNAL_DECLARATION_STUB ANNOTATION_CLASS name:ExperimentalTypeInference modality:FINAL visibility:public superTypes:[kotlin.Annotation]' type=kotlin.reflect.KClass]) + TYPE_PARAMETER name:E index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.CoroutineScope + VALUE_PARAMETER name:block index:0 type:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.ProducerScope.produce>, kotlin.Unit> + annotations: + BuilderInference + BLOCK_BODY + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CLASS INTERFACE name:ProducerScope modality:ABSTRACT visibility:public superTypes:[.CoroutineScope; .SendChannel.ProducerScope>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ProducerScope.ProducerScope> + TYPE_PARAMETER name:E index:0 variance:in superTypes:[kotlin.Any?] + PROPERTY name:channel visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.ProducerScope.ProducerScope>) returnType:.SendChannel.ProducerScope> + correspondingProperty: PROPERTY name:channel visibility:public modality:ABSTRACT [val] + $this: VALUE_PARAMETER name: type:.ProducerScope.ProducerScope> + 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 [fake_override,operator] declared in .CoroutineScope + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .SendChannel + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .CoroutineScope + public open fun hashCode (): kotlin.Int [fake_override] declared in .SendChannel + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .CoroutineScope + public open fun toString (): kotlin.String [fake_override] declared in .SendChannel + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:SendChannel modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.SendChannel.SendChannel> + TYPE_PARAMETER name:E index:0 variance:in superTypes:[kotlin.Any?] + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 2bce2ea3043..c8b6ad6e7ae 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -1826,6 +1826,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/types/asOnPlatformType.kt"); } + @TestMetadata("castsInsideCoroutineInference.kt") + public void testCastsInsideCoroutineInference() throws Exception { + runTest("compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt"); + } + @TestMetadata("coercionToUnitInLambdaReturnValue.kt") public void testCoercionToUnitInLambdaReturnValue() throws Exception { runTest("compiler/testData/ir/irText/types/coercionToUnitInLambdaReturnValue.kt");