[NI] Builder-inference: fix unresolved reference for variable calls

This commit is contained in:
Mikhail Zarechenskiy
2019-03-28 03:20:52 +03:00
parent d6db1a1b35
commit 017f9aea35
5 changed files with 44 additions and 5 deletions
@@ -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<CallableDescriptor>(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
)
}
@@ -0,0 +1,18 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !USE_EXPERIMENTAL: kotlin.Experimental
import kotlin.experimental.ExperimentalTypeInference
interface ProducerScope<E> {
fun yield(e: E)
}
@UseExperimental(ExperimentalTypeInference::class)
fun <E> produce(@BuilderInference block: ProducerScope<E>.() -> Unit): ProducerScope<E> = TODO()
fun <K> filter(e: K, predicate: (K) -> Boolean) =
produce {
predicate(e)
yield(42)
}
@@ -0,0 +1,11 @@
package
public fun </*0*/ K> filter(/*0*/ e: K, /*1*/ predicate: (K) -> kotlin.Boolean): ProducerScope<kotlin.Int>
@kotlin.UseExperimental(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ E> produce(/*0*/ @kotlin.BuilderInference block: ProducerScope<E>.() -> kotlin.Unit): ProducerScope<E>
public interface ProducerScope</*0*/ E> {
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
}
@@ -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");
@@ -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");