From 55983a780800ae46721ab155f7627875b8c66d0c Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Thu, 8 Dec 2016 13:49:30 +0300 Subject: [PATCH] Support type inference for coroutines. --- .../kotlin/resolve/calls/CallResolver.java | 8 + .../resolve/calls/GenericCandidateResolver.kt | 9 +- .../calls/inference/CoroutineInferenceUtil.kt | 284 ++++++++++++++++++ .../calls/tower/NewResolutionOldInference.kt | 8 +- .../coroutines/inference/correctMember.kt | 20 ++ .../coroutines/inference/correctMember.txt | 14 + .../coroutines/inference/extensionPriority.kt | 21 ++ .../inference/extensionPriority.txt | 23 ++ .../coroutines/inference/extensionSuspend.kt | 37 +++ .../coroutines/inference/extensionSuspend.txt | 37 +++ .../coroutines/inference/incorrectCalls.kt | 30 ++ .../coroutines/inference/incorrectCalls.txt | 27 ++ .../inference/recursiveGenerators.kt | 17 ++ .../inference/recursiveGenerators.txt | 12 + .../inference/recursiveGenerators2.kt | 16 + .../inference/recursiveGenerators2.txt | 13 + .../inference/returnTypeInference.kt | 9 + .../inference/returnTypeInference.txt | 11 + .../inference/returnTypeInference2.kt | 14 + .../inference/returnTypeInference2.txt | 19 ++ .../coroutines/inference/simpleGenerator.kt | 29 ++ .../coroutines/inference/simpleGenerator.txt | 18 ++ .../coroutines/inference/typeFromReceiver.kt | 11 + .../coroutines/inference/typeFromReceiver.txt | 12 + .../coroutines/inference/withParameter.kt | 16 + .../coroutines/inference/withParameter.txt | 20 ++ .../inference/withUninferredParameter.kt | 19 ++ .../inference/withUninferredParameter.txt | 16 + .../checkers/DiagnosticsTestGenerated.java | 81 +++++ 29 files changed, 848 insertions(+), 3 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/CoroutineInferenceUtil.kt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/correctMember.kt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/correctMember.txt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/extensionPriority.kt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/extensionPriority.txt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/extensionSuspend.kt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/extensionSuspend.txt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/incorrectCalls.kt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/incorrectCalls.txt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators.kt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators.txt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators2.kt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators2.txt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference.kt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference.txt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference2.kt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference2.txt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/simpleGenerator.kt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/simpleGenerator.txt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/typeFromReceiver.kt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/typeFromReceiver.txt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/withParameter.kt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/withParameter.txt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/withUninferredParameter.kt create mode 100644 compiler/testData/diagnostics/tests/coroutines/inference/withUninferredParameter.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index ca903b9a67a..86372c7489b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilKt; import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.context.*; +import org.jetbrains.kotlin.resolve.calls.inference.CoroutineInferenceUtilKt; import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments; import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults; import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsImpl; @@ -516,6 +517,13 @@ public class CallResolver { BindingContextUtilsKt.recordDataFlowInfo(newContext, newContext.call.getCalleeExpression()); OverloadResolutionResultsImpl results = doResolveCall(newContext, resolutionTask, tracing); + + // this is necessary because we already run CallCompleter for such calls + if (CoroutineInferenceUtilKt.isResultWithCoroutineInference(results)) { + traceToResolveCall.commit(); + return results; + } + DelegatingBindingTrace deltasTraceForTypeInference = ((OverloadResolutionResultsImpl) results).getTrace(); if (deltasTraceForTypeInference != null) { deltasTraceForTypeInference.addOwnDataTo(traceToResolveCall); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index d8b4a4cfaf9..02da30d1434 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -52,7 +52,10 @@ import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils -class GenericCandidateResolver(private val argumentTypeResolver: ArgumentTypeResolver) { +class GenericCandidateResolver( + private val argumentTypeResolver: ArgumentTypeResolver, + private val coroutineInferenceSupport: CoroutineInferenceSupport +) { fun inferTypeArguments(context: CallCandidateResolutionContext): ResolutionStatus { val candidateCall = context.candidateCall val candidate = candidateCall.candidateDescriptor @@ -299,6 +302,10 @@ class GenericCandidateResolver(private val argumentTypeResolver: ArgumentTypeRes val effectiveExpectedType = getEffectiveExpectedType(valueParameterDescriptor, valueArgument) + if (isCoroutineCallWithAdditionalInference(valueParameterDescriptor, valueArgument)) { + coroutineInferenceSupport.analyzeCoroutine(functionLiteral, valueArgument, constraintSystem, context, effectiveExpectedType) + } + val currentSubstitutor = constraintSystem.build().currentSubstitutor val newSubstitution = object : DelegatedTypeSubstitution(currentSubstitutor.substitution) { override fun approximateContravariantCapturedTypes() = true diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/CoroutineInferenceUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/CoroutineInferenceUtil.kt new file mode 100644 index 00000000000..c6df07f8460 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/CoroutineInferenceUtil.kt @@ -0,0 +1,284 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve.calls.inference + +import org.jetbrains.kotlin.builtins.* +import org.jetbrains.kotlin.coroutines.hasSuspendFunctionType +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor +import org.jetbrains.kotlin.descriptors.annotations.Annotations +import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.KtFunction +import org.jetbrains.kotlin.psi.KtLambdaExpression +import org.jetbrains.kotlin.psi.ValueArgument +import org.jetbrains.kotlin.renderer.DescriptorRenderer +import org.jetbrains.kotlin.renderer.DescriptorRendererOptions +import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver +import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver.getCallableReferenceExpressionIfAny +import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver.getFunctionLiteralArgumentIfAny +import org.jetbrains.kotlin.resolve.calls.CallCompleter +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.getEffectiveExpectedType +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.hasUnknownFunctionParameter +import org.jetbrains.kotlin.resolve.calls.context.* +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind +import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch +import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess +import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsImpl +import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy +import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns +import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue +import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE +import org.jetbrains.kotlin.types.checker.NewKotlinTypeChecker +import org.jetbrains.kotlin.types.checker.TypeCheckerContext +import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices +import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo +import org.jetbrains.kotlin.types.typeUtil.asTypeProjection +import org.jetbrains.kotlin.types.typeUtil.builtIns +import org.jetbrains.kotlin.types.typeUtil.contains +import javax.inject.Inject + +class TypeTemplate( + val typeVariable: TypeVariable, + val coroutineInferenceData: CoroutineInferenceData +) : FlexibleType(typeVariable.originalTypeParameter.builtIns.nothingType, typeVariable.originalTypeParameter.builtIns.nullableAnyType) { + override fun replaceAnnotations(newAnnotations: Annotations) = this + + override fun makeNullableAsSpecified(newNullability: Boolean) = this + + override val delegate: SimpleType + get() = upperBound + + override fun render(renderer: DescriptorRenderer, options: DescriptorRendererOptions) = + "~${renderer.renderType(typeVariable.type)}" +} + +class CoroutineInferenceData { + private val csBuilder = ConstraintSystemBuilderImpl() + private val typeTemplates = HashMap() + private var hereIsBadCall = false + + fun getTypeTemplate(typeVariable: TypeVariable) = + typeTemplates.getOrPut(typeVariable) { + TypeTemplate(typeVariable, this) + } + + fun initSystem() { + csBuilder.registerTypeVariables(CallHandle.NONE, typeTemplates.keys.map { it.freshTypeParameter }) + } + + fun toNewVariableType(type: KotlinType): KotlinType { + return (type.unwrap() as? TypeTemplate)?.typeVariable?.freshTypeParameter?.let { typeVariable -> + csBuilder.typeVariableSubstitutors[CallHandle.NONE]?.substitution?.get(typeVariable.defaultType)?.type + } ?: type + } + + fun addConstraint(subType: KotlinType, superType: KotlinType) { + csBuilder.addSubtypeConstraint(toNewVariableType(subType), toNewVariableType(superType), ConstraintPositionKind.SPECIAL.position()) + } + + fun reportInferenceResult(externalCSBuilder: ConstraintSystem.Builder) { + if (hereIsBadCall) return + + val resultingSubstitution = csBuilder.build().resultingSubstitutor.substitution + for ((originalTypeVariable) in typeTemplates) { + resultingSubstitution[originalTypeVariable.type]?.type.let { + externalCSBuilder.addSubtypeConstraint(originalTypeVariable.type, it, ConstraintPositionKind.FROM_COMPLETER.position()) + externalCSBuilder.addSubtypeConstraint(it, originalTypeVariable.type, ConstraintPositionKind.FROM_COMPLETER.position()) + } + } + } + + fun badCallHappened() { + hereIsBadCall = true + } +} + +class CoroutineInferenceSupport( + val argumentTypeResolver: ArgumentTypeResolver, + val expressionTypingServices: ExpressionTypingServices +) { + @set:Inject + lateinit var callCompleter: CallCompleter + + fun analyzeCoroutine( + functionLiteral: KtFunction, + valueArgument: ValueArgument, + csBuilder: ConstraintSystem.Builder, + context: CallCandidateResolutionContext<*>, + lambdaExpectedType: KotlinType + ) { + val argumentExpression = valueArgument.getArgumentExpression() ?: return + if (!lambdaExpectedType.isSuspendFunctionType) return + val lambdaReceiverType = lambdaExpectedType.getReceiverTypeFromFunctionType() ?: return + + val inferenceData = CoroutineInferenceData() + + val constraintSystem = csBuilder.build() + val newSubstitution = object : DelegatedTypeSubstitution(constraintSystem.currentSubstitutor.substitution) { + override fun get(key: KotlinType): TypeProjection? { + val substitutedType = super.get(key) + if (substitutedType?.type != TypeUtils.DONT_CARE) return substitutedType + + // todo: what about nullable type? + val typeVariable = constraintSystem.typeVariables.firstOrNull { + it.originalTypeParameter.defaultType == key + } ?: return substitutedType + + return inferenceData.getTypeTemplate(typeVariable).asTypeProjection() + } + + override fun approximateContravariantCapturedTypes() = true + } + val newReceiverType = newSubstitution.buildSubstitutor().substitute(lambdaReceiverType, Variance.INVARIANT) ?: return + + val approximationSubstitutor = object : DelegatedTypeSubstitution(constraintSystem.currentSubstitutor.substitution) { + override fun approximateContravariantCapturedTypes() = true + } + val approximatedLambdaType = approximationSubstitutor.buildSubstitutor().substitute(lambdaExpectedType, Variance.IN_VARIANCE) ?: return + + val newExpectedType = createFunctionType(newReceiverType.builtIns, approximatedLambdaType.annotations, newReceiverType, + approximatedLambdaType.getValueParameterTypesFromFunctionType().map(TypeProjection::getType), + parameterNames = null, // TODO: parameterNames + returnType = approximatedLambdaType.getReturnTypeFromFunctionType(), + suspendFunction = true) + + if (hasUnknownFunctionParameter(newExpectedType)) return + + inferenceData.initSystem() + + // this trace shouldn't be committed + val temporaryForCoroutine = TemporaryTraceAndCache.create( + context, "trace for type argument inference for coroutine", functionLiteral) + + val newContext = context.replaceExpectedType(newExpectedType) + .replaceDataFlowInfo(context.candidateCall.dataFlowInfoForArguments.getInfo(valueArgument)) + .replaceContextDependency(ContextDependency.INDEPENDENT).replaceTraceAndCache(temporaryForCoroutine) + argumentTypeResolver.getFunctionLiteralTypeInfo(argumentExpression, functionLiteral, newContext, RESOLVE_FUNCTION_ARGUMENTS).type + + inferenceData.reportInferenceResult(csBuilder) + } + + fun checkCoroutineCalls( + context: BasicCallResolutionContext, + tracingStrategy: TracingStrategy, + overloadResults: OverloadResolutionResultsImpl<*> + ) { + val inferenceData = overloadResults.getCoroutineInferenceData() ?: return + + val resultingCall = overloadResults.resultingCall + + forceInferenceForArguments(context) { _: ValueArgument, _: KotlinType -> /* do nothing */ } + + callCompleter.completeCall(context, overloadResults, tracingStrategy) + if (!resultingCall.isReallySuccess()) return + + if (isBadCall(resultingCall.resultingDescriptor)) { + inferenceData.badCallHappened() + } + + forceInferenceForArguments(context) { + valueArgument: ValueArgument, kotlinType: KotlinType -> + val argumentMatch = resultingCall.getArgumentMapping(valueArgument) as? ArgumentMatch + ?: return@forceInferenceForArguments + + with(NewKotlinTypeChecker) { + val parameterType = getEffectiveExpectedType(argumentMatch.valueParameter, valueArgument) + CoroutineTypeCheckerContext().isSubtypeOf(kotlinType.unwrap(), parameterType.unwrap()) + } + } + + val extensionReceiver = resultingCall.resultingDescriptor.extensionReceiverParameter ?: return + resultingCall.extensionReceiver?.let { actualReceiver -> + with(NewKotlinTypeChecker) { + CoroutineTypeCheckerContext().isSubtypeOf(actualReceiver.type.unwrap(), extensionReceiver.value.type.unwrap()) + } + } + } + + private fun isBadCall(resultingDescriptor: CallableDescriptor): Boolean { + fun KotlinType.containsTypeTemplate() = contains { it is TypeTemplate } + + val returnType = resultingDescriptor.returnType ?: return true + if (returnType.containsTypeTemplate()) return true + + if (resultingDescriptor !is FunctionDescriptor || resultingDescriptor.isSuspend) return false + + for (valueParameter in resultingDescriptor.valueParameters) { + if (valueParameter.type.containsTypeTemplate()) return true + } + return false + } + + private class CoroutineTypeCheckerContext : TypeCheckerContext(errorTypeEqualsToAnything = true) { + override fun addSubtypeConstraint(subType: UnwrappedType, superType: UnwrappedType): Boolean? { + (subType as? TypeTemplate ?: superType as? TypeTemplate)?.coroutineInferenceData?.addConstraint(subType, superType) + return null + } + } + + private fun forceInferenceForArguments(context: CallResolutionContext<*>, callback: (argument: ValueArgument, argumentType: KotlinType) -> Unit) { + val infoForArguments = context.dataFlowInfoForArguments + val call = context.call + val baseContext = context.replaceContextDependency(ContextDependency.INDEPENDENT).replaceExpectedType(NO_EXPECTED_TYPE) + + for (argument in call.valueArguments) { + val expression = argument.getArgumentExpression() ?: continue + val typeInfoForCall = getArgumentTypeInfo(expression, baseContext.replaceDataFlowInfo(infoForArguments.getInfo(argument))) + typeInfoForCall.type?.let { callback(argument, it) } + } + } + + private fun getArgumentTypeInfo( + expression: KtExpression, + context: CallResolutionContext<*> + ): KotlinTypeInfo { + getFunctionLiteralArgumentIfAny(expression, context)?.let { + return argumentTypeResolver.getFunctionLiteralTypeInfo(expression, it, context, RESOLVE_FUNCTION_ARGUMENTS) + } + + getCallableReferenceExpressionIfAny(expression, context)?.let { + return argumentTypeResolver.getCallableReferenceTypeInfo(expression, it, context, RESOLVE_FUNCTION_ARGUMENTS) + } + + return expressionTypingServices.getTypeInfo(expression, context) + } +} + +fun isCoroutineCallWithAdditionalInference(parameterDescriptor: ValueParameterDescriptor, argument: ValueArgument) = + parameterDescriptor.hasSuspendFunctionType && + argument.getArgumentExpression() is KtLambdaExpression && + parameterDescriptor.type.let { it.isBuiltinFunctionalType && it.getReceiverTypeFromFunctionType() != null } + + +fun OverloadResolutionResultsImpl<*>.isResultWithCoroutineInference() = getCoroutineInferenceData() != null + +private fun OverloadResolutionResultsImpl<*>.getCoroutineInferenceData(): CoroutineInferenceData? { + if (!isSingleResult) return null + + fun getData(receiverValue: ReceiverValue?): CoroutineInferenceData? { + var coroutineInferenceData: CoroutineInferenceData? = null + receiverValue?.type?.contains { + (it as? TypeTemplate)?.coroutineInferenceData?.let { coroutineInferenceData = it } + false + } + return coroutineInferenceData + } + return getData(resultingCall.dispatchReceiver) ?: getData(resultingCall.extensionReceiver) +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt index a22468ab9de..93a5e5e711d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isConventionCall import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInfixCall import org.jetbrains.kotlin.resolve.calls.callUtil.createLookupLocation import org.jetbrains.kotlin.resolve.calls.context.* +import org.jetbrains.kotlin.resolve.calls.inference.CoroutineInferenceSupport import org.jetbrains.kotlin.resolve.calls.model.MutableResolvedCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedCallImpl import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCallImpl @@ -67,7 +68,8 @@ class NewResolutionOldInference( private val dynamicCallableDescriptors: DynamicCallableDescriptors, private val syntheticScopes: SyntheticScopes, private val syntheticConstructorsProvider: SyntheticConstructorsProvider, - private val languageVersionSettings: LanguageVersionSettings + private val languageVersionSettings: LanguageVersionSettings, + private val coroutineInferenceSupport: CoroutineInferenceSupport ) { sealed class ResolutionKind { abstract internal fun createTowerProcessor( @@ -189,7 +191,9 @@ class NewResolutionOldInference( } } - return convertToOverloadResults(candidates, tracing, context) + val overloadResults = convertToOverloadResults(candidates, tracing, context) + coroutineInferenceSupport.checkCoroutineCalls(context, tracing, overloadResults) + return overloadResults } fun runResolutionForGivenCandidates( diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/correctMember.kt b/compiler/testData/diagnostics/tests/coroutines/inference/correctMember.kt new file mode 100644 index 00000000000..c2a818befbb --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/correctMember.kt @@ -0,0 +1,20 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +interface Controller { + suspend fun yield(t: T) {} + + fun justString(): String = "" + + fun generidFun(t: Z) = t +} + +fun generate(g: suspend Controller.() -> Unit): S = TODO() + +val test1 = generate { + yield(justString()) +} + +val test2 = generate { + yield(generidFun(2)) +} + diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/correctMember.txt b/compiler/testData/diagnostics/tests/coroutines/inference/correctMember.txt new file mode 100644 index 00000000000..288fb4cac8e --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/correctMember.txt @@ -0,0 +1,14 @@ +package + +public val test1: kotlin.String +public val test2: kotlin.Int +public fun generate(/*0*/ g: suspend Controller.() -> kotlin.Unit): S + +public interface Controller { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun generidFun(/*0*/ t: Z): Z + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun justString(): kotlin.String + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public open suspend fun yield(/*0*/ t: T): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/extensionPriority.kt b/compiler/testData/diagnostics/tests/coroutines/inference/extensionPriority.kt new file mode 100644 index 00000000000..573b7e71b14 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/extensionPriority.kt @@ -0,0 +1,21 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +class GenericController + +suspend fun GenericController.yieldAll(s: Collection): String = "" +suspend fun GenericController.yieldAll(s: Set): Int = 4 + +fun generate(g: suspend GenericController.() -> R): Pair = TODO() + +val test1 = generate { + yieldAll(setOf(4)) +} + +val test2 = generate { + yieldAll(listOf(4)) +} + +// Util function +fun setOf(vararg x: X): Set = TODO() +fun listOf(vararg x: X): List = TODO() +class Pair diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/extensionPriority.txt b/compiler/testData/diagnostics/tests/coroutines/inference/extensionPriority.txt new file mode 100644 index 00000000000..edf07576028 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/extensionPriority.txt @@ -0,0 +1,23 @@ +package + +public val test1: Pair +public val test2: Pair +public fun generate(/*0*/ g: suspend GenericController.() -> R): Pair +public fun listOf(/*0*/ vararg x: X /*kotlin.Array*/): kotlin.collections.List +public fun setOf(/*0*/ vararg x: X /*kotlin.Array*/): kotlin.collections.Set +public suspend fun GenericController.yieldAll(/*0*/ s: kotlin.collections.Collection): kotlin.String +public suspend fun GenericController.yieldAll(/*0*/ s: kotlin.collections.Set): kotlin.Int + +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 class Pair { + public constructor Pair() + 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/tests/coroutines/inference/extensionSuspend.kt b/compiler/testData/diagnostics/tests/coroutines/inference/extensionSuspend.kt new file mode 100644 index 00000000000..542c3864c7f --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/extensionSuspend.kt @@ -0,0 +1,37 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +class GenericController { + suspend fun yield(t: T) {} +} + +suspend fun GenericController.yieldAll(s: Collection) {} + +fun generate(g: suspend GenericController.() -> Unit): S = TODO() + +val test1 = generate { + yield(4) + yieldAll(setOf(4, 5)) +} + +val test2 = generate { + yieldAll(setOf(B)) +} + +val test3 = generate { + yieldAll(setOf(B, C)) +} + +val test4 = generate { + yieldAll(setOf(B)) + + yield(C) +} + + + +// Utils +fun setOf(vararg x: X): Set = TODO() + +interface A +object B : A +object C : A \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/extensionSuspend.txt b/compiler/testData/diagnostics/tests/coroutines/inference/extensionSuspend.txt new file mode 100644 index 00000000000..93bdcaf9b80 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/extensionSuspend.txt @@ -0,0 +1,37 @@ +package + +public val test1: kotlin.Int +public val test2: B +public val test3: A +public val test4: A +public fun generate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): S +public fun setOf(/*0*/ vararg x: X /*kotlin.Array*/): kotlin.collections.Set +public suspend fun GenericController.yieldAll(/*0*/ s: kotlin.collections.Collection): kotlin.Unit + +public interface A { + 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 object B : A { + private constructor B() + 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 object C : A { + private constructor C() + 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 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 +} diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/incorrectCalls.kt b/compiler/testData/diagnostics/tests/coroutines/inference/incorrectCalls.kt new file mode 100644 index 00000000000..958ab64a9c3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/incorrectCalls.kt @@ -0,0 +1,30 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +class GenericController { + suspend fun yield(t: T) {} + fun notYield(t: T) {} + + suspend fun yieldBarReturnType(t: T) = t + fun barReturnType(): T = TODO() +} + +fun generate(g: suspend GenericController.() -> Unit): List = TODO() + +val test1 = generate { + yield(3) +} + +val test2 = generate { + yield(3) + notYield(3) +} + +val test3 = generate { + yield(3) + yieldBarReturnType(3) +} + +val test4 = generate { + yield(3) + barReturnType() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/incorrectCalls.txt b/compiler/testData/diagnostics/tests/coroutines/inference/incorrectCalls.txt new file mode 100644 index 00000000000..16d4eec468a --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/incorrectCalls.txt @@ -0,0 +1,27 @@ +package + +public val test1: kotlin.collections.List +public val test2: [ERROR : Type for generate { + yield(3) + notYield(3) +}] +public val test3: [ERROR : Type for generate { + yield(3) + yieldBarReturnType(3) +}] +public val test4: [ERROR : Type for generate { + yield(3) + barReturnType() +}] +public fun generate(/*0*/ 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/tests/coroutines/inference/recursiveGenerators.kt b/compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators.kt new file mode 100644 index 00000000000..d7e3fcde878 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators.kt @@ -0,0 +1,17 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +class GenericController { + suspend fun yield(t: T) {} +} + +fun generate(g: suspend GenericController.() -> Unit): List = TODO() + +val test1 = generate { + yield(generate { + yield(generate { + yield(generate { + yield(3) + }) + }) + }) +} diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators.txt b/compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators.txt new file mode 100644 index 00000000000..6018443cfb9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators.txt @@ -0,0 +1,12 @@ +package + +public val test1: kotlin.collections.List>>> +public fun generate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List + +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 +} diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators2.kt b/compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators2.kt new file mode 100644 index 00000000000..6ace8297843 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators2.kt @@ -0,0 +1,16 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +class GenericController { + suspend fun yield(t: T) {} +} + +fun generate(g: suspend GenericController.() -> Unit): List = TODO() + +suspend fun GenericController>.yieldGenerate(g: suspend GenericController.() -> Unit): Unit = TODO() + +val test1 = generate { + // TODO: KT-15185 + yieldGenerate { + yield(4) + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators2.txt b/compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators2.txt new file mode 100644 index 00000000000..e12e02c141c --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators2.txt @@ -0,0 +1,13 @@ +package + +public val test1: kotlin.collections.List +public fun generate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List +public suspend fun GenericController>.yieldGenerate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): 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 +} diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference.kt b/compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference.kt new file mode 100644 index 00000000000..98725a175e1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference.kt @@ -0,0 +1,9 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +class Controller + +fun generate(g: suspend Controller.() -> R): R = TODO() + +val test1 = generate { + 3 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference.txt b/compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference.txt new file mode 100644 index 00000000000..6bd3c3b362b --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference.txt @@ -0,0 +1,11 @@ +package + +public val test1: kotlin.Int +public fun generate(/*0*/ g: suspend Controller.() -> R): R + +public final class Controller { + public constructor Controller() + 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/tests/coroutines/inference/returnTypeInference2.kt b/compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference2.kt new file mode 100644 index 00000000000..7017b3936da --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference2.kt @@ -0,0 +1,14 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +class Controller { + suspend fun yield(t: T) {} +} + +fun generate(g: suspend Controller.() -> R): Pair = TODO() + +val test1 = generate { + yield("") + 3 +} + +class Pair \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference2.txt b/compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference2.txt new file mode 100644 index 00000000000..2682b299a82 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference2.txt @@ -0,0 +1,19 @@ +package + +public val test1: Pair +public fun generate(/*0*/ g: suspend Controller.() -> R): Pair + +public final class Controller { + public constructor Controller() + 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 +} + +public final class Pair { + public constructor Pair() + 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/tests/coroutines/inference/simpleGenerator.kt b/compiler/testData/diagnostics/tests/coroutines/inference/simpleGenerator.kt new file mode 100644 index 00000000000..61fc621ae7e --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/simpleGenerator.kt @@ -0,0 +1,29 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +class GenericController { + suspend fun yield(t: T) {} + suspend fun yieldSet(t: Set) {} + suspend fun yieldVararg(vararg t: T) {} +} + +fun generate(g: suspend GenericController.() -> Unit): S = TODO() + +val test1 = generate { + yield(4) +} + +val test2 = generate { + yieldSet(setOf(1, 2, 3)) +} + +val test3 = generate { + yieldVararg(1, 2, 3) +} + +val test4 = generate { + yieldVararg(1, 2, "") +} + + +// Util function +fun setOf(vararg x: X): Set = TODO() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/simpleGenerator.txt b/compiler/testData/diagnostics/tests/coroutines/inference/simpleGenerator.txt new file mode 100644 index 00000000000..85d771e19cb --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/simpleGenerator.txt @@ -0,0 +1,18 @@ +package + +public val test1: kotlin.Int +public val test2: kotlin.Int +public val test3: kotlin.Int +public val test4: kotlin.Any +public fun generate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): S +public fun setOf(/*0*/ vararg x: X /*kotlin.Array*/): kotlin.collections.Set + +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 + public final suspend fun yieldSet(/*0*/ t: kotlin.collections.Set): kotlin.Unit + public final suspend fun yieldVararg(/*0*/ vararg t: T /*kotlin.Array*/): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/typeFromReceiver.kt b/compiler/testData/diagnostics/tests/coroutines/inference/typeFromReceiver.kt new file mode 100644 index 00000000000..23d22f03726 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/typeFromReceiver.kt @@ -0,0 +1,11 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +class GenericController + +fun generate(g: suspend GenericController.() -> Unit): List = TODO() + +suspend fun GenericController>.test() {} + +val test1 = generate { + test() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/typeFromReceiver.txt b/compiler/testData/diagnostics/tests/coroutines/inference/typeFromReceiver.txt new file mode 100644 index 00000000000..60aaa9dcf70 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/typeFromReceiver.txt @@ -0,0 +1,12 @@ +package + +public val test1: kotlin.collections.List> +public fun generate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List +public suspend fun GenericController>.test(): 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 +} diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/withParameter.kt b/compiler/testData/diagnostics/tests/coroutines/inference/withParameter.kt new file mode 100644 index 00000000000..ce737158005 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/withParameter.kt @@ -0,0 +1,16 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +class GenericController { + suspend fun yield(t: T) {} +} + +fun generate(p1: P1, p2: List, g: suspend GenericController.(P1, P2) -> R): Four = TODO() + +val test1 = generate(1, listOf("")) { p1, p2 -> + yield(p1) + + p2 +} + +fun listOf(vararg x: X): List = TODO() +class Four \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/withParameter.txt b/compiler/testData/diagnostics/tests/coroutines/inference/withParameter.txt new file mode 100644 index 00000000000..3107d162860 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/withParameter.txt @@ -0,0 +1,20 @@ +package + +public val test1: Four +public fun generate(/*0*/ p1: P1, /*1*/ p2: kotlin.collections.List, /*2*/ g: suspend GenericController.(P1, P2) -> R): Four +public fun listOf(/*0*/ vararg x: X /*kotlin.Array*/): kotlin.collections.List + +public final class Four { + public constructor Four() + 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 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 +} diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/withUninferredParameter.kt b/compiler/testData/diagnostics/tests/coroutines/inference/withUninferredParameter.kt new file mode 100644 index 00000000000..716c9a30460 --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/withUninferredParameter.kt @@ -0,0 +1,19 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +class GenericController { + suspend fun yield(t: T) {} +} + +fun generate(g: suspend GenericController.(S) -> Unit): S = TODO() + +val test1 = generate { + yield(4) +} + +val test2 = generate { + yield(4) +} + +val test3 = generate { bar: Int -> + yield(4) +} diff --git a/compiler/testData/diagnostics/tests/coroutines/inference/withUninferredParameter.txt b/compiler/testData/diagnostics/tests/coroutines/inference/withUninferredParameter.txt new file mode 100644 index 00000000000..5bc218f1a4a --- /dev/null +++ b/compiler/testData/diagnostics/tests/coroutines/inference/withUninferredParameter.txt @@ -0,0 +1,16 @@ +package + +public val test1: [ERROR : Type for generate { + yield(4) +}] +public val test2: kotlin.Int +public val test3: kotlin.Int +public fun generate(/*0*/ g: suspend GenericController.(S) -> kotlin.Unit): S + +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 +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 95945d94ef3..5fc9d8f9360 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -4324,6 +4324,87 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("compiler/testData/diagnostics/tests/coroutines/inference") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inference extends AbstractDiagnosticsTest { + public void testAllFilesPresentInInference() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/inference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("correctMember.kt") + public void testCorrectMember() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/inference/correctMember.kt"); + doTest(fileName); + } + + @TestMetadata("extensionPriority.kt") + public void testExtensionPriority() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/inference/extensionPriority.kt"); + doTest(fileName); + } + + @TestMetadata("extensionSuspend.kt") + public void testExtensionSuspend() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/inference/extensionSuspend.kt"); + doTest(fileName); + } + + @TestMetadata("incorrectCalls.kt") + public void testIncorrectCalls() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/inference/incorrectCalls.kt"); + doTest(fileName); + } + + @TestMetadata("recursiveGenerators.kt") + public void testRecursiveGenerators() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators.kt"); + doTest(fileName); + } + + @TestMetadata("recursiveGenerators2.kt") + public void testRecursiveGenerators2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/inference/recursiveGenerators2.kt"); + doTest(fileName); + } + + @TestMetadata("returnTypeInference.kt") + public void testReturnTypeInference() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference.kt"); + doTest(fileName); + } + + @TestMetadata("returnTypeInference2.kt") + public void testReturnTypeInference2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/inference/returnTypeInference2.kt"); + doTest(fileName); + } + + @TestMetadata("simpleGenerator.kt") + public void testSimpleGenerator() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/inference/simpleGenerator.kt"); + doTest(fileName); + } + + @TestMetadata("typeFromReceiver.kt") + public void testTypeFromReceiver() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/inference/typeFromReceiver.kt"); + doTest(fileName); + } + + @TestMetadata("withParameter.kt") + public void testWithParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/inference/withParameter.kt"); + doTest(fileName); + } + + @TestMetadata("withUninferredParameter.kt") + public void testWithUninferredParameter() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/inference/withUninferredParameter.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionType") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)