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 20cc56de330..c910adf326c 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 @@ -162,14 +162,14 @@ class CoroutineInferenceSession( val nonFixedTypesToResultSubstitutor = ComposedSubstitutor(commonSystemSubstitutor, nonFixedToVariablesSubstitutor) for (completedCall in commonCalls) { - val resultCallAtom = completedCall.callResolutionResult.resultCallAtom - val call = resultCallAtom.atom.getResolvedPsiKotlinCall(trace) ?: continue - updateCall(completedCall, nonFixedTypesToResultSubstitutor, nonFixedTypesToResult) - val resultingDescriptor = call.resultingDescriptor kotlinToResolvedCallTransformer.reportCallDiagnostic( - completedCall.context, trace, resultCallAtom, resultingDescriptor, commonSystem.diagnostics + completedCall.context, + trace, + completedCall.callResolutionResult.resultCallAtom, + completedCall.resolvedCall.resultingDescriptor, + commonSystem.diagnostics ) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableCallInsideBuilderFunction.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableCallInsideBuilderFunction.kt new file mode 100644 index 00000000000..17ba9ad9d2f --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableCallInsideBuilderFunction.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER +// !USE_EXPERIMENTAL: kotlin.Experimental + +import kotlin.experimental.ExperimentalTypeInference + +interface ProducerScope { + fun yield(e: E) +} + +@UseExperimental(ExperimentalTypeInference::class) +fun produce(@BuilderInference block: ProducerScope.() -> Unit): ProducerScope = TODO() + +fun filter(e: K, predicate: (K) -> Boolean) = + produce { + predicate(e) + yield(42) + } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableCallInsideBuilderFunction.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableCallInsideBuilderFunction.txt new file mode 100644 index 00000000000..b25dc46daed --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableCallInsideBuilderFunction.txt @@ -0,0 +1,11 @@ +package + +public fun filter(/*0*/ e: K, /*1*/ predicate: (K) -> kotlin.Boolean): ProducerScope +@kotlin.UseExperimental(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun produce(/*0*/ @kotlin.BuilderInference block: ProducerScope.() -> kotlin.Unit): ProducerScope + +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 + public abstract fun yield(/*0*/ e: E): kotlin.Unit +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index 4fb85989384..7a638c63175 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -1912,6 +1912,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.kt"); } + @TestMetadata("variableCallInsideBuilderFunction.kt") + public void testVariableCallInsideBuilderFunction() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableCallInsideBuilderFunction.kt"); + } + @TestMetadata("withParameter.kt") public void testWithParameter() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withParameter.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index 7123b09c73d..f1bb82621a7 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -1912,6 +1912,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.kt"); } + @TestMetadata("variableCallInsideBuilderFunction.kt") + public void testVariableCallInsideBuilderFunction() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableCallInsideBuilderFunction.kt"); + } + @TestMetadata("withParameter.kt") public void testWithParameter() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withParameter.kt");