diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/CoroutineInferenceSession.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/CoroutineInferenceSession.kt index 1157555d31b..ab14a9c5522 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/CoroutineInferenceSession.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/CoroutineInferenceSession.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices +import org.jetbrains.kotlin.types.typeUtil.contains import org.jetbrains.kotlin.utils.addToStdlib.cast class CoroutineInferenceSession( @@ -52,6 +53,7 @@ class CoroutineInferenceSession( ) { private val commonCalls = arrayListOf() private val diagnostics = arrayListOf() + private var hasInapplicableCall = false override fun shouldRunCompletion(candidate: KotlinResolutionCandidate): Boolean { val system = candidate.getSystem() as NewConstraintSystemImpl @@ -78,26 +80,40 @@ class CoroutineInferenceSession( commonCalls.add(callInfo) + val resultingDescriptor = callInfo.resolvedCall.resultingDescriptor + + // This check is similar to one for old inference, see getCoroutineInferenceData() function + val checkCall = resultingDescriptor is LocalVariableDescriptor || anyReceiverContainStubType(resultingDescriptor) + + if (!checkCall) return + val isApplicableCall = callComponents.statelessCallbacks.isApplicableCallForBuilderInference( - callInfo.resolvedCall.resultingDescriptor, + resultingDescriptor, callComponents.languageVersionSettings ) if (!isApplicableCall) { - diagnostics.add(NonApplicableCallForBuilderInferenceDiagnostic(callInfo.callResolutionResult.resultCallAtom.atom)) + hasInapplicableCall = true } } + private fun anyReceiverContainStubType(descriptor: CallableDescriptor): Boolean { + return descriptor.dispatchReceiverParameter?.type?.contains { it is StubType } == true || + descriptor.extensionReceiverParameter?.type?.contains { it is StubType } == true + } + + fun hasInapplicableCall(): Boolean = hasInapplicableCall + override fun writeOnlyStubs(callInfo: SingleCallResolutionResult): Boolean { return !skipCall(callInfo) } private fun skipCall(callInfo: SingleCallResolutionResult): Boolean { - // FakeCallableDescriptorForObject and LocalVariableDescriptor can't introduce new information for inference, + // FakeCallableDescriptorForObject can't introduce new information for inference, // so it's safe to complete it fully val descriptor = callInfo.resultCallAtom.candidateDescriptor - return descriptor is FakeCallableDescriptorForObject || descriptor is LocalVariableDescriptor + return descriptor is FakeCallableDescriptorForObject } override fun currentConstraintSystem(): ConstraintStorage { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt index 576485155a2..157e76235f9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt @@ -139,8 +139,6 @@ class KotlinResolutionCallbacksImpl( if (expectedReturnType == null) ContextDependency.DEPENDENT else ContextDependency.INDEPENDENT ) - trace.record(BindingContext.NEW_INFERENCE_LAMBDA_INFO, psiCallArgument.ktFunction, lambdaInfo) - val builtIns = outerCallContext.scope.ownerDescriptor.builtIns // We have to refine receiverType because resolve inside lambda needs proper scope from receiver, @@ -179,8 +177,16 @@ class KotlinResolutionCallbacksImpl( null } + + val temporaryTrace = if (coroutineSession != null) + TemporaryBindingTrace.create(trace, "Trace to resolve coroutine $lambdaArgument") + else + null + + (temporaryTrace ?: trace).record(BindingContext.NEW_INFERENCE_LAMBDA_INFO, psiCallArgument.ktFunction, lambdaInfo) + val actualContext = outerCallContext - .replaceBindingTrace(trace) + .replaceBindingTrace(temporaryTrace ?: trace) .replaceContextDependency(lambdaInfo.contextDependency) .replaceExpectedType(approximatesExpectedType) .replaceDataFlowInfo(psiCallArgument.dataFlowInfoBeforeThisArgument).let { @@ -188,7 +194,13 @@ class KotlinResolutionCallbacksImpl( } val functionTypeInfo = expressionTypingServices.getTypeInfo(psiCallArgument.expression, actualContext) - trace.record(BindingContext.NEW_INFERENCE_LAMBDA_INFO, psiCallArgument.ktFunction, LambdaInfo.STUB_EMPTY) + (temporaryTrace ?: trace).record(BindingContext.NEW_INFERENCE_LAMBDA_INFO, psiCallArgument.ktFunction, LambdaInfo.STUB_EMPTY) + + if (coroutineSession?.hasInapplicableCall() == true) { + return ReturnArgumentsAnalysisResult(ReturnArgumentsInfo.empty, coroutineSession, hasInapplicableCallForBuilderInference = true) + } else { + temporaryTrace?.commit() + } var hasReturnWithoutExpression = false var returnArgumentFound = false diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ExternalComponents.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ExternalComponents.kt index 0bad519357c..3a14b07539f 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ExternalComponents.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ExternalComponents.kt @@ -50,11 +50,16 @@ data class ReturnArgumentsInfo( val lastExpression: KotlinCallArgument?, val lastExpressionCoercedToUnit: Boolean, val returnArgumentsExist: Boolean -) +) { + companion object { + val empty = ReturnArgumentsInfo(emptyList(), null, lastExpressionCoercedToUnit = false, returnArgumentsExist = false) + } +} data class ReturnArgumentsAnalysisResult( val returnArgumentsInfo: ReturnArgumentsInfo, - val inferenceSession: InferenceSession? + val inferenceSession: InferenceSession?, + val hasInapplicableCallForBuilderInference: Boolean = false ) // This components hold state (trace). Work with this carefully. diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/PostponedArgumentsAnalyzer.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/PostponedArgumentsAnalyzer.kt index 4f6bb58d0bd..17d8ebde48f 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/PostponedArgumentsAnalyzer.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/PostponedArgumentsAnalyzer.kt @@ -120,15 +120,21 @@ class PostponedArgumentsAnalyzer( else FilteredAnnotations(annotations, true) { it != KotlinBuiltIns.FQ_NAMES.extensionFunctionType } } - val (returnArgumentsInfo, inferenceSession) = resolutionCallbacks.analyzeAndGetLambdaReturnArguments( - lambda.atom, - lambda.isSuspend, - receiver, - parameters, - expectedTypeForReturnArguments, - convertedAnnotations ?: Annotations.EMPTY, - stubsForPostponedVariables.cast() - ) + val (returnArgumentsInfo, inferenceSession, hasInapplicableCallForBuilderInference) = + resolutionCallbacks.analyzeAndGetLambdaReturnArguments( + lambda.atom, + lambda.isSuspend, + receiver, + parameters, + expectedTypeForReturnArguments, + convertedAnnotations ?: Annotations.EMPTY, + stubsForPostponedVariables.cast() + ) + + if (hasInapplicableCallForBuilderInference) { + c.getBuilder().removePostponedVariables() + return + } val returnArguments = returnArgumentsInfo.nonErrorArguments returnArguments.forEach { c.addSubsystemFromArgument(it) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.kt index 215138feb4e..867437b8ba7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.kt @@ -1,7 +1,6 @@ // !USE_EXPERIMENTAL: kotlin.RequiresOptIn // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE // !WITH_NEW_INFERENCE -// NI_EXPECTED_FILE @file:OptIn(ExperimentalTypeInference::class) @@ -26,12 +25,12 @@ val test2 = generate { notYield(3) } -val test3 = generate { +val test3 = generate { yield(3) - yieldBarReturnType(3) + yieldBarReturnType(3) } -val test4 = generate { +val test4 = generate { yield(3) - barReturnType() + barReturnType() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.ni.txt deleted file mode 100644 index aa1fb869364..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/incorrectCalls.ni.txt +++ /dev/null @@ -1,18 +0,0 @@ -package - -public val test1: kotlin.collections.List -public val test2: kotlin.collections.List -public val test3: kotlin.collections.List -public val test4: kotlin.collections.List -public fun generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List - -public final class GenericController { - public constructor GenericController() - public final fun barReturnType(): T - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public final fun notYield(/*0*/ t: T): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - public final suspend fun yield(/*0*/ t: T): kotlin.Unit - public final suspend fun yieldBarReturnType(/*0*/ t: T): T -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.kt index dfffb034b7a..6b0fbee7b15 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.kt @@ -1,7 +1,6 @@ // !LANGUAGE: -ExperimentalBuilderInference // !DIAGNOSTICS: -UNUSED_PARAMETER // !WITH_NEW_INFERENCE -// NI_EXPECTED_FILE class Builder { suspend fun add(t: T) {} @@ -22,8 +21,8 @@ val memberWithoutAnn = add(42) } -val extension = build { - extensionAdd("foo") +val extension = build { + extensionAdd("foo") } val safeExtension = build { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.ni.txt deleted file mode 100644 index efde51d672d..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.ni.txt +++ /dev/null @@ -1,20 +0,0 @@ -package - -public val extension: kotlin.collections.List -public val member: kotlin.collections.List -public val memberWithoutAnn: [ERROR : Type for wrongBuild { - add(42) -}] -public val safeExtension: kotlin.collections.List -public fun build(/*0*/ g: suspend Builder.() -> kotlin.Unit): kotlin.collections.List -public fun wrongBuild(/*0*/ g: Builder.() -> kotlin.Unit): kotlin.collections.List -public fun Builder.extensionAdd(/*0*/ s: S): kotlin.Unit -public suspend fun Builder.safeExtensionAdd(/*0*/ s: S): kotlin.Unit - -public final class Builder { - public constructor Builder() - public final suspend fun add(/*0*/ t: T): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32097.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32097.kt new file mode 100644 index 00000000000..201207fc09b --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32097.kt @@ -0,0 +1,24 @@ +// !USE_EXPERIMENTAL: kotlin.RequiresOptIn +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import kotlin.experimental.ExperimentalTypeInference + +fun aFlow(): Flow = channelFlow { + awaitClose { + } +} + +interface Flow { + suspend fun collect(collector: FlowCollector) +} + +@OptIn(ExperimentalTypeInference::class) +fun channelFlow(@BuilderInference block: suspend ProducerScope.() -> Unit): Flow = TODO() + +interface ProducerScope + +interface FlowCollector { + suspend fun emit(value: T) +} + +suspend fun ProducerScope<*>.awaitClose(block: () -> Unit = {}) {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32097.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32097.txt new file mode 100644 index 00000000000..3d9f20a5432 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32097.txt @@ -0,0 +1,25 @@ +package + +public fun aFlow(): Flow +@kotlin.OptIn(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun channelFlow(/*0*/ @kotlin.BuilderInference block: suspend ProducerScope.() -> kotlin.Unit): Flow +public suspend fun ProducerScope<*>.awaitClose(/*0*/ block: () -> kotlin.Unit = ...): kotlin.Unit + +public interface Flow { + public abstract suspend fun collect(/*0*/ collector: FlowCollector): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface FlowCollector { + public abstract suspend fun emit(/*0*/ value: T): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface ProducerScope { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32203.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32203.kt new file mode 100644 index 00000000000..c1a19aed201 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32203.kt @@ -0,0 +1,16 @@ +// !USE_EXPERIMENTAL: kotlin.RequiresOptIn +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import kotlin.experimental.ExperimentalTypeInference + +class Buildee +class Builder + +@OptIn(ExperimentalTypeInference::class) +inline fun builder(@BuilderInference block: Builder.() -> Unit): Buildee = TODO() + +private fun Builder.consumer(builder: Builder): Unit = TODO() + +fun Builder.foo(): Buildee = builder { + consumer(this) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32203.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32203.txt new file mode 100644 index 00000000000..a7e96363433 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32203.txt @@ -0,0 +1,19 @@ +package + +@kotlin.OptIn(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public inline fun builder(/*0*/ @kotlin.BuilderInference block: Builder.() -> kotlin.Unit): Buildee +private fun Builder.consumer(/*0*/ builder: Builder): kotlin.Unit +public fun Builder.foo(): Buildee + +public final class Buildee { + public constructor Buildee() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class Builder { + public constructor Builder() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35306.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35306.kt new file mode 100644 index 00000000000..3e09c421f91 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35306.kt @@ -0,0 +1,43 @@ +// !LANGUAGE: +NewInference +// !USE_EXPERIMENTAL: kotlin.RequiresOptIn +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import kotlin.experimental.ExperimentalTypeInference + +interface Build + +@OptIn(ExperimentalTypeInference::class) +fun build(@BuilderInference fn: Builder.() -> Unit): Build = TODO() + +// Works completely +val build = build { + value(1) +} + +// Works completely +val buildWithWrappedValue = build { + wrappedValue(Wrapped(1)) +} + +// Works completely +val buildWithFn = build { + valueFn { + 1 + } +} + +// Works, but the ide complains with "Non-applicable call for builder inference" +val buildWithFnWrapped = build { + wrappedValueFn { + Wrapped(1) + } +} + +interface Builder { + fun value(value: T) + fun wrappedValue(value: Wrapped) + fun wrappedValueFn(fn: () -> Wrapped) + fun valueFn(fn: () -> T) +} + +data class Wrapped(val value: T) \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35306.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35306.txt new file mode 100644 index 00000000000..d0469da501f --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35306.txt @@ -0,0 +1,33 @@ +package + +public val build: Build +public val buildWithFn: Build +public val buildWithFnWrapped: Build +public val buildWithWrappedValue: Build +@kotlin.OptIn(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun build(/*0*/ @kotlin.BuilderInference fn: Builder.() -> kotlin.Unit): Build + +public interface Build { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Builder { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public abstract fun value(/*0*/ value: T): kotlin.Unit + public abstract fun valueFn(/*0*/ fn: () -> T): kotlin.Unit + public abstract fun wrappedValue(/*0*/ value: Wrapped): kotlin.Unit + public abstract fun wrappedValueFn(/*0*/ fn: () -> Wrapped): kotlin.Unit +} + +public final data class Wrapped { + public constructor Wrapped(/*0*/ value: T) + public final val value: T + public final operator /*synthesized*/ fun component1(): T + public final /*synthesized*/ fun copy(/*0*/ value: T = ...): Wrapped + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36202.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36202.kt new file mode 100644 index 00000000000..e39dfe42af3 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36202.kt @@ -0,0 +1,22 @@ +// !USE_EXPERIMENTAL: kotlin.RequiresOptIn +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE + +import kotlin.experimental.ExperimentalTypeInference + +interface Build + +@OptIn(ExperimentalTypeInference::class) +fun build(@BuilderInference fn: Builder.() -> Unit): Build = TODO() + +interface Builder { + fun foo(fn: () -> T) +} + +fun main() { + val bar = build { + foo { listOf(1, 2, 3).firstOrNull() } + } + val baz = build { + foo { listOf(1, 2, 3).firstOrNull() ?: 0 } + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36202.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36202.txt new file mode 100644 index 00000000000..9fa7b2a7e97 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36202.txt @@ -0,0 +1,17 @@ +package + +@kotlin.OptIn(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun build(/*0*/ @kotlin.BuilderInference fn: Builder.() -> kotlin.Unit): Build +public fun main(): kotlin.Unit + +public interface Build { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Builder { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(/*0*/ fn: () -> T): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36220.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36220.kt new file mode 100644 index 00000000000..17490c59289 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36220.kt @@ -0,0 +1,20 @@ +// !USE_EXPERIMENTAL: kotlin.RequiresOptIn +// !DIAGNOSTICS: -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE + +import kotlin.experimental.ExperimentalTypeInference + +class TypeDefinition { + fun parse(parser: (serializedValue: String) -> KotlinType?): Unit = TODO() + fun serialize(parser: (value: KotlinType) -> Any?): Unit = TODO() +} + +@OptIn(ExperimentalTypeInference::class) +fun defineType(@BuilderInference definition: TypeDefinition.() -> Unit): Unit = TODO() + +fun main() { + defineType { + parse { it.toInt() } + serialize { it.toString() } + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36220.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36220.txt new file mode 100644 index 00000000000..de05b946fc6 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36220.txt @@ -0,0 +1,13 @@ +package + +@kotlin.OptIn(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun defineType(/*0*/ @kotlin.BuilderInference definition: TypeDefinition.() -> kotlin.Unit): kotlin.Unit +public fun main(): kotlin.Unit + +public final class TypeDefinition { + public constructor TypeDefinition() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun parse(/*0*/ parser: (serializedValue: kotlin.String) -> KotlinType?): kotlin.Unit + public final fun serialize(/*0*/ parser: (value: KotlinType) -> kotlin.Any?): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.kt index 4b299877c99..e79f2c2119c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.kt @@ -1,7 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER // !WITH_NEW_INFERENCE // FILE: annotation.kt -// NI_EXPECTED_FILE package kotlin @@ -29,8 +28,8 @@ val memberWithoutAnn = build { - extensionAdd("foo") +val extension = build { + extensionAdd("foo") } val safeExtension = build { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.ni.txt deleted file mode 100644 index 4ba791ecafa..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.ni.txt +++ /dev/null @@ -1,30 +0,0 @@ -package - -public val extension: kotlin.collections.List -public val member: kotlin.collections.List -public val memberWithoutAnn: [ERROR : Type for wrongBuild { - add(42) -}] -public val safeExtension: kotlin.collections.List -public fun build(/*0*/ @kotlin.BuilderInference g: Builder.() -> kotlin.Unit): kotlin.collections.List -public fun wrongBuild(/*0*/ g: Builder.() -> kotlin.Unit): kotlin.collections.List -public fun Builder.extensionAdd(/*0*/ s: S): kotlin.Unit -@kotlin.BuilderInference public fun Builder.safeExtensionAdd(/*0*/ s: S): kotlin.Unit - -public final class Builder { - public constructor Builder() - public final fun add(/*0*/ t: T): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -package kotlin { - - public final annotation class BuilderInference : kotlin.Annotation { - public constructor BuilderInference() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.kt index a98f2287976..bc2077c95d0 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.kt @@ -1,6 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER // !WITH_NEW_INFERENCE -// NI_EXPECTED_FILE // FILE: annotation.kt @@ -25,8 +24,8 @@ val normal = generate { yield(42) } -val extension = generate { - extensionYield("foo") +val extension = generate { + extensionYield("foo") } val safeExtension = generate { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.ni.txt deleted file mode 100644 index 9a2789c7e6e..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.ni.txt +++ /dev/null @@ -1,26 +0,0 @@ -package - -public val extension: kotlin.collections.List -public val normal: kotlin.collections.List -public val safeExtension: kotlin.collections.List -public fun generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List -public suspend fun GenericController.extensionYield(/*0*/ s: S): kotlin.Unit -@kotlin.BuilderInference public suspend fun GenericController.safeExtensionYield(/*0*/ s: S): kotlin.Unit - -public final class GenericController { - public constructor GenericController() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - public final suspend fun yield(/*0*/ t: T): kotlin.Unit -} - -package kotlin { - - public final annotation class BuilderInference : kotlin.Annotation { - public constructor BuilderInference() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } -} diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt index 38dfe588528..0d297a5dfc1 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt @@ -1,4 +1,71 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt + FUN name:scopedFlow visibility:public modality:FINAL (block:kotlin.Function2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit>) returnType:.Flow.scopedFlow> + TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:block index:0 type:kotlin.Function2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun scopedFlow (block: kotlin.Function2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit>): .Flow.scopedFlow> declared in ' + CALL 'public final fun flow (block: kotlin.Function1<.FlowCollector.flow>, kotlin.Unit>): .Flow.flow> declared in ' type=.Flow.scopedFlow> origin=null + : R of .scopedFlow + block: FUN_EXPR type=kotlin.Function1<.FlowCollector.scopedFlow>, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.FlowCollector.scopedFlow>) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name: type:.FlowCollector.scopedFlow> + BLOCK_BODY + VAR name:collector type:.FlowCollector.scopedFlow> [val] + GET_VAR ': .FlowCollector.scopedFlow> declared in special.' type=.FlowCollector.scopedFlow> origin=null + CALL 'public final fun flowScope (block: kotlin.Function1<.CoroutineScope, R of .flowScope>): R of .flowScope [suspend] declared in ' type=kotlin.Unit origin=null + : kotlin.Unit + block: FUN_EXPR type=kotlin.Function1<.CoroutineScope, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.CoroutineScope) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name: type:.CoroutineScope + BLOCK_BODY + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function2, p2: P2 of kotlin.Function2): R of kotlin.Function2 [operator] declared in kotlin.Function2' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'block: kotlin.Function2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> declared in .scopedFlow' type=kotlin.Function2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> origin=null + p1: GET_VAR ': .CoroutineScope declared in special.' type=.CoroutineScope origin=null + p2: GET_VAR 'val collector: .FlowCollector.scopedFlow> [val] declared in .scopedFlow.' type=.FlowCollector.scopedFlow> origin=null + FUN name:onCompletion visibility:public modality:FINAL ($receiver:.Flow.onCompletion>, action:kotlin.Function2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit>) returnType:.Flow.onCompletion> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.Flow.onCompletion> + VALUE_PARAMETER name:action index:0 type:kotlin.Function2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun onCompletion (action: kotlin.Function2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit>): .Flow.onCompletion> declared in ' + CALL 'public final fun unsafeFlow (block: kotlin.Function1<.FlowCollector.unsafeFlow>, kotlin.Unit>): .Flow.unsafeFlow> [inline] declared in ' type=.Flow.onCompletion> origin=null + : T of .onCompletion + block: FUN_EXPR type=kotlin.Function1<.FlowCollector.onCompletion>, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.FlowCollector.onCompletion>) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name: type:.FlowCollector.onCompletion> + BLOCK_BODY + VAR name:safeCollector type:.SafeCollector.onCompletion> [val] + CONSTRUCTOR_CALL 'public constructor (collector: .FlowCollector.SafeCollector>) [primary] declared in .SafeCollector' type=.SafeCollector.onCompletion> origin=null + : T of .onCompletion + collector: GET_VAR ': .FlowCollector.onCompletion> declared in special.' type=.FlowCollector.onCompletion> origin=null + CALL 'public final fun invokeSafely (action: kotlin.Function2<.FlowCollector.invokeSafely>, kotlin.Throwable?, kotlin.Unit>): kotlin.Unit [suspend] declared in ' type=kotlin.Unit origin=null + : T of .onCompletion + $receiver: GET_VAR 'val safeCollector: .SafeCollector.onCompletion> [val] declared in .onCompletion.' type=.SafeCollector.onCompletion> origin=null + action: GET_VAR 'action: kotlin.Function2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit> declared in .onCompletion' type=kotlin.Function2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit> origin=null + FUN name:invokeSafely visibility:public modality:FINAL ($receiver:.FlowCollector.invokeSafely>, action:kotlin.Function2<.FlowCollector.invokeSafely>, kotlin.Throwable?, kotlin.Unit>) returnType:kotlin.Unit [suspend] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.FlowCollector.invokeSafely> + VALUE_PARAMETER name:action index:0 type:kotlin.Function2<.FlowCollector.invokeSafely>, kotlin.Throwable?, kotlin.Unit> + BLOCK_BODY + FUN name:unsafeFlow visibility:public modality:FINAL (block:kotlin.Function1<.FlowCollector.unsafeFlow>, kotlin.Unit>) returnType:.Flow.unsafeFlow> [inline] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:block index:0 type:kotlin.Function1<.FlowCollector.unsafeFlow>, kotlin.Unit> [crossinline] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun unsafeFlow (block: kotlin.Function1<.FlowCollector.unsafeFlow>, kotlin.Unit>): .Flow.unsafeFlow> [inline] declared in ' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + FUN name:onCompletion visibility:public modality:FINAL ($receiver:.Flow.onCompletion>, action:kotlin.Function1) returnType:IrErrorType + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.Flow.onCompletion> + VALUE_PARAMETER name:action index:0 type:kotlin.Function1 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun onCompletion (action: kotlin.Function1): IrErrorType declared in ' + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function1): R of kotlin.Function1 [operator] declared in kotlin.Function1' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'action: kotlin.Function1 declared in .onCompletion' type=kotlin.Function1 origin=null + p1: ERROR_CALL 'Unresolved reference: #' type=IrErrorType 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<*> @@ -72,6 +139,54 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt if: CONST Boolean type=kotlin.Boolean value=true then: TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any GET_VAR 'val tmp_1: kotlin.Any? [val] declared in .asChannel..' type=kotlin.Any? origin=null + CLASS CLASS name:SafeCollector modality:FINAL visibility:public superTypes:[.FlowCollector.SafeCollector>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.SafeCollector.SafeCollector> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (collector:.FlowCollector.SafeCollector>) returnType:.SafeCollector.SafeCollector> [primary] + VALUE_PARAMETER name:collector index:0 type:.FlowCollector.SafeCollector> + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:SafeCollector modality:FINAL visibility:public superTypes:[.FlowCollector.SafeCollector>]' + PROPERTY name:collector visibility:internal modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:collector type:.FlowCollector.SafeCollector> visibility:private [final] + EXPRESSION_BODY + GET_VAR 'collector: .FlowCollector.SafeCollector> declared in .SafeCollector.' type=.FlowCollector.SafeCollector> origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:internal modality:FINAL <> ($this:.SafeCollector.SafeCollector>) returnType:.FlowCollector.SafeCollector> + correspondingProperty: PROPERTY name:collector visibility:internal modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.SafeCollector.SafeCollector> + BLOCK_BODY + RETURN type=kotlin.Nothing from='internal final fun (): .FlowCollector.SafeCollector> declared in .SafeCollector' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:collector type:.FlowCollector.SafeCollector> visibility:private [final]' type=.FlowCollector.SafeCollector> origin=null + receiver: GET_VAR ': .SafeCollector.SafeCollector> declared in .SafeCollector.' type=.SafeCollector.SafeCollector> origin=null + FUN name:emit visibility:public modality:FINAL <> ($this:.SafeCollector.SafeCollector>, value:T of .SafeCollector) returnType:kotlin.Unit [suspend] + $this: VALUE_PARAMETER name: type:.SafeCollector.SafeCollector> + VALUE_PARAMETER name:value index:0 type:T of .SafeCollector + 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 + FUN name:flow visibility:public modality:FINAL (block:kotlin.Function1<.FlowCollector.flow>, kotlin.Unit>) returnType:.Flow.flow> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:block index:0 type:kotlin.Function1<.FlowCollector.flow>, kotlin.Unit> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun flow (block: kotlin.Function1<.FlowCollector.flow>, kotlin.Unit>): .Flow.flow> declared in ' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + FUN name:flowScope visibility:public modality:FINAL (block:kotlin.Function1<.CoroutineScope, R of .flowScope>) returnType:R of .flowScope [suspend] + TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:block index:0 type:kotlin.Function1<.CoroutineScope, R of .flowScope> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun flowScope (block: kotlin.Function1<.CoroutineScope, R of .flowScope>): R of .flowScope [suspend] declared in ' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing 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> diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt index 7a2bf4beb8e..040b08bc3c0 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt @@ -1,7 +1,35 @@ +// !LANGUAGE: +NewInference // WITH_RUNTIME import kotlin.experimental.ExperimentalTypeInference + +@OptIn(ExperimentalTypeInference::class) +fun scopedFlow(@BuilderInference block: suspend CoroutineScope.(FlowCollector) -> Unit): Flow = + flow { + val collector = this + flowScope { block(collector) } + } + +public fun Flow.onCompletion( + action: suspend FlowCollector.(cause: Throwable?) -> Unit +): Flow = unsafeFlow { + val safeCollector = SafeCollector(this) + safeCollector.invokeSafely(action) +} + +suspend fun FlowCollector.invokeSafely( + action: suspend FlowCollector.(cause: Throwable?) -> Unit +) { +} + +@OptIn(ExperimentalTypeInference::class) +inline fun unsafeFlow(@BuilderInference crossinline block: suspend FlowCollector.() -> Unit): Flow = TODO() + +@Deprecated(level = DeprecationLevel.HIDDEN, message = "binary compatibility with a version w/o FlowCollector receiver") +public fun Flow.onCompletion(action: suspend (cause: Throwable?) -> Unit) = + onCompletion { action(it) } + private fun CoroutineScope.asFairChannel(flow: Flow<*>): ReceiveChannel = produce { val channel = channel as ChannelCoroutine flow.collect { value -> @@ -15,6 +43,18 @@ private fun CoroutineScope.asChannel(flow: Flow<*>): ReceiveChannel = produ } } +class SafeCollector constructor( + internal val collector: FlowCollector +) : FlowCollector { + override suspend fun emit(value: T) {} +} + +@OptIn(ExperimentalTypeInference::class) +fun flow(@BuilderInference block: suspend FlowCollector.() -> Unit): Flow = TODO() + +@OptIn(ExperimentalTypeInference::class) +suspend fun flowScope(@BuilderInference block: suspend CoroutineScope.() -> R): R = TODO() + suspend inline fun Flow.collect(crossinline action: suspend (value: T) -> Unit) {} open class ChannelCoroutine { diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.txt index aa3a60422ab..785ad3c66fb 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.txt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.txt @@ -1,4 +1,84 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt + FUN name:scopedFlow visibility:public modality:FINAL (block:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit>) returnType:.Flow.scopedFlow> + 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:R index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:block index:0 type:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> + annotations: + BuilderInference + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun scopedFlow (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit>): .Flow.scopedFlow> declared in ' + CALL 'public final fun flow (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.FlowCollector.flow>, kotlin.Unit>): .Flow.flow> declared in ' type=.Flow.scopedFlow> origin=null + : R of .scopedFlow + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.FlowCollector.scopedFlow>, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.FlowCollector.scopedFlow>) returnType:kotlin.Unit [suspend] + $receiver: VALUE_PARAMETER name: type:.FlowCollector.scopedFlow> + BLOCK_BODY + VAR name:collector type:.FlowCollector.scopedFlow> [val] + GET_VAR ': .FlowCollector.scopedFlow> declared in .scopedFlow.' type=.FlowCollector.scopedFlow> origin=null + CALL 'public final fun flowScope (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.CoroutineScope, R of .flowScope>): R of .flowScope [suspend] declared in ' type=kotlin.Unit origin=null + : kotlin.Unit + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.CoroutineScope, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.CoroutineScope) returnType:kotlin.Unit [suspend] + $receiver: VALUE_PARAMETER name: type:.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=INVOKE + $this: GET_VAR 'block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> declared in .scopedFlow' type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR ': .CoroutineScope declared in .scopedFlow..' type=.CoroutineScope origin=null + p2: GET_VAR 'val collector: .FlowCollector.scopedFlow> [val] declared in .scopedFlow.' type=.FlowCollector.scopedFlow> origin=null + FUN name:onCompletion visibility:public modality:FINAL ($receiver:.Flow.onCompletion>, action:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit>) returnType:.Flow.onCompletion> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.Flow.onCompletion> + VALUE_PARAMETER name:action index:0 type:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun onCompletion (action: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit>): .Flow.onCompletion> declared in ' + CALL 'public final fun unsafeFlow (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.FlowCollector.unsafeFlow>, kotlin.Unit>): .Flow.unsafeFlow> [inline] declared in ' type=.Flow.onCompletion> origin=null + : T of .onCompletion + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.FlowCollector.onCompletion>, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.FlowCollector.onCompletion>) returnType:kotlin.Unit [suspend] + $receiver: VALUE_PARAMETER name: type:.FlowCollector.onCompletion> + BLOCK_BODY + VAR name:safeCollector type:.SafeCollector.onCompletion> [val] + CONSTRUCTOR_CALL 'public constructor (collector: .FlowCollector.SafeCollector>) [primary] declared in .SafeCollector' type=.SafeCollector.onCompletion> origin=null + : T of .onCompletion + collector: GET_VAR ': .FlowCollector.onCompletion> declared in .onCompletion.' type=.FlowCollector.onCompletion> origin=null + CALL 'public final fun invokeSafely (action: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.invokeSafely>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit>): kotlin.Unit [suspend] declared in ' type=kotlin.Unit origin=null + : T of .onCompletion + $receiver: GET_VAR 'val safeCollector: .SafeCollector.onCompletion> [val] declared in .onCompletion.' type=.SafeCollector.onCompletion> origin=null + action: GET_VAR 'action: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit> declared in .onCompletion' type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit> origin=null + FUN name:invokeSafely visibility:public modality:FINAL ($receiver:.FlowCollector.invokeSafely>, action:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.invokeSafely>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit>) returnType:kotlin.Unit [suspend] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.FlowCollector.invokeSafely> + VALUE_PARAMETER name:action index:0 type:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.invokeSafely>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit> + BLOCK_BODY + FUN name:unsafeFlow visibility:public modality:FINAL (block:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.FlowCollector.unsafeFlow>, kotlin.Unit>) returnType:.Flow.unsafeFlow> [inline] + 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:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:block index:0 type:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.FlowCollector.unsafeFlow>, kotlin.Unit> [crossinline] + annotations: + BuilderInference + BLOCK_BODY + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + FUN name:onCompletion visibility:public modality:FINAL ($receiver:.Flow.onCompletion>, action:kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit>) returnType:.Flow.onCompletion> + annotations: + Deprecated(message = 'binary compatibility with a version w/o FlowCollector receiver', replaceWith = , level = GET_ENUM 'ENUM_ENTRY IR_EXTERNAL_DECLARATION_STUB name:HIDDEN' type=kotlin.DeprecationLevel) + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.Flow.onCompletion> + VALUE_PARAMETER name:action index:0 type:kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun onCompletion (action: kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit>): .Flow.onCompletion> declared in ' + CALL 'public final fun onCompletion (action: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit>): .Flow.onCompletion> declared in ' type=.Flow.onCompletion> origin=null + : T of .onCompletion + $receiver: GET_VAR ': .Flow.onCompletion> declared in .onCompletion' type=.Flow.onCompletion> origin=null + action: FUN_EXPR type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, @[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.FlowCollector.onCompletion>, it:kotlin.Throwable?) returnType:kotlin.Unit [suspend] + $receiver: VALUE_PARAMETER name: type:.FlowCollector.onCompletion> + VALUE_PARAMETER name:it index:0 type: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=INVOKE + $this: GET_VAR 'action: kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit> declared in .onCompletion' type=kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR 'it: kotlin.Throwable? declared in .onCompletion.' type=kotlin.Throwable? origin=null 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<*> @@ -72,6 +152,62 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: GET_VAR 'val tmp_1: kotlin.Any? [val] declared in .asChannel..' type=kotlin.Any? origin=null + CLASS CLASS name:SafeCollector modality:FINAL visibility:public superTypes:[.FlowCollector.SafeCollector>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.SafeCollector.SafeCollector> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (collector:.FlowCollector.SafeCollector>) returnType:.SafeCollector.SafeCollector> [primary] + VALUE_PARAMETER name:collector index:0 type:.FlowCollector.SafeCollector> + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:SafeCollector modality:FINAL visibility:public superTypes:[.FlowCollector.SafeCollector>]' + PROPERTY name:collector visibility:internal modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:collector type:.FlowCollector.SafeCollector> visibility:private [final] + EXPRESSION_BODY + GET_VAR 'collector: .FlowCollector.SafeCollector> declared in .SafeCollector.' type=.FlowCollector.SafeCollector> origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:internal modality:FINAL <> ($this:.SafeCollector.SafeCollector>) returnType:.FlowCollector.SafeCollector> + correspondingProperty: PROPERTY name:collector visibility:internal modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.SafeCollector.SafeCollector> + BLOCK_BODY + RETURN type=kotlin.Nothing from='internal final fun (): .FlowCollector.SafeCollector> declared in .SafeCollector' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:collector type:.FlowCollector.SafeCollector> visibility:private [final]' type=.FlowCollector.SafeCollector> origin=null + receiver: GET_VAR ': .SafeCollector.SafeCollector> declared in .SafeCollector.' type=.SafeCollector.SafeCollector> origin=null + FUN name:emit visibility:public modality:OPEN <> ($this:.SafeCollector.SafeCollector>, value:T of .SafeCollector) returnType:kotlin.Unit [suspend] + overridden: + public abstract fun emit (value: T of .FlowCollector): kotlin.Unit [suspend] declared in .FlowCollector + $this: VALUE_PARAMETER name: type:.SafeCollector.SafeCollector> + VALUE_PARAMETER name:value index:0 type:T of .SafeCollector + 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 [fake_override,operator] declared in .FlowCollector + $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 .FlowCollector + $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 .FlowCollector + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:flow visibility:public modality:FINAL (block:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.FlowCollector.flow>, kotlin.Unit>) returnType:.Flow.flow> + 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:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:block index:0 type:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.FlowCollector.flow>, kotlin.Unit> + annotations: + BuilderInference + BLOCK_BODY + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + FUN name:flowScope visibility:public modality:FINAL (block:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.CoroutineScope, R of .flowScope>) returnType:R of .flowScope [suspend] + 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:R index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:block index:0 type:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.CoroutineScope, R of .flowScope> + annotations: + BuilderInference + BLOCK_BODY + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing 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> diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index fa97d991fd5..95427eef8ae 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -1967,6 +1967,16 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt15516.kt"); } + @TestMetadata("kt32097.kt") + public void testKt32097() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32097.kt"); + } + + @TestMetadata("kt32203.kt") + public void testKt32203() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32203.kt"); + } + @TestMetadata("kt32271.kt") public void testKt32271() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32271.kt"); @@ -1977,11 +1987,26 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt33542.kt"); } + @TestMetadata("kt35306.kt") + public void testKt35306() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35306.kt"); + } + @TestMetadata("kt35684.kt") public void testKt35684() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35684.kt"); } + @TestMetadata("kt36202.kt") + public void testKt36202() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36202.kt"); + } + + @TestMetadata("kt36220.kt") + public void testKt36220() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36220.kt"); + } + @TestMetadata("nestedLambdaInferenceWithListMap.kt") public void testNestedLambdaInferenceWithListMap() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/nestedLambdaInferenceWithListMap.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index bbb317f149e..38735cc15fe 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -1967,6 +1967,16 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt15516.kt"); } + @TestMetadata("kt32097.kt") + public void testKt32097() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32097.kt"); + } + + @TestMetadata("kt32203.kt") + public void testKt32203() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32203.kt"); + } + @TestMetadata("kt32271.kt") public void testKt32271() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32271.kt"); @@ -1977,11 +1987,26 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt33542.kt"); } + @TestMetadata("kt35306.kt") + public void testKt35306() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35306.kt"); + } + @TestMetadata("kt35684.kt") public void testKt35684() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt35684.kt"); } + @TestMetadata("kt36202.kt") + public void testKt36202() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36202.kt"); + } + + @TestMetadata("kt36220.kt") + public void testKt36220() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt36220.kt"); + } + @TestMetadata("nestedLambdaInferenceWithListMap.kt") public void testNestedLambdaInferenceWithListMap() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/nestedLambdaInferenceWithListMap.kt");