[NI] Fix composite substitution for stubbed type in builder-inference

#KT-32038 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2019-06-18 15:03:31 +03:00
parent 7df13c986e
commit 5cf7c7e5bf
5 changed files with 67 additions and 1 deletions
@@ -217,6 +217,8 @@ class CoroutineInferenceSession(
class ComposedSubstitutor(val left: NewTypeSubstitutor, val right: NewTypeSubstitutor) : NewTypeSubstitutor {
override fun substituteNotNullTypeWithConstructor(constructor: TypeConstructor): UnwrappedType? {
return left.safeSubstitute(right.substituteNotNullTypeWithConstructor(constructor) ?: return null)
return left.substituteNotNullTypeWithConstructor(
right.substituteNotNullTypeWithConstructor(constructor)?.constructor ?: constructor
)
}
}
@@ -0,0 +1,29 @@
// !USE_EXPERIMENTAL: kotlin.Experimental
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:UseExperimental(ExperimentalTypeInference::class)
import kotlin.experimental.ExperimentalTypeInference
interface MyFlow<out T>
interface MyFlowCollector<in T>
fun <F> flow(@BuilderInference block: MyFlowCollector<F>.() -> Unit): MyFlow<F> = TODO()
interface SendChannel<in E> {
fun send(element: E)
}
fun <P> produce(@BuilderInference block: SendChannel<P>.() -> Unit) {}
fun <C> MyFlow<C>.collect(action: (C) -> Unit) {}
private fun <T> MyFlow<T>.idScoped(): MyFlow<T> {
return flow {
produce {
collect {
send(it)
}
}
}
}
@@ -0,0 +1,25 @@
package
public fun </*0*/ F> flow(/*0*/ @kotlin.BuilderInference block: MyFlowCollector<F>.() -> kotlin.Unit): MyFlow<F>
public fun </*0*/ P> produce(/*0*/ @kotlin.BuilderInference block: SendChannel<P>.() -> kotlin.Unit): kotlin.Unit
public fun </*0*/ C> MyFlow<C>.collect(/*0*/ action: (C) -> kotlin.Unit): kotlin.Unit
private fun </*0*/ T> MyFlow<T>.idScoped(): MyFlow<T>
public interface MyFlow</*0*/ out 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface MyFlowCollector</*0*/ in 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface SendChannel</*0*/ in 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 abstract fun send(/*0*/ element: E): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -1932,6 +1932,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWrongUpperBound.kt");
}
@TestMetadata("twoReceiversInScope.kt")
public void testTwoReceiversInScope() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/twoReceiversInScope.kt");
}
@TestMetadata("typeFromReceiver.kt")
public void testTypeFromReceiver() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/typeFromReceiver.kt");
@@ -1932,6 +1932,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWrongUpperBound.kt");
}
@TestMetadata("twoReceiversInScope.kt")
public void testTwoReceiversInScope() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/twoReceiversInScope.kt");
}
@TestMetadata("typeFromReceiver.kt")
public void testTypeFromReceiver() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/typeFromReceiver.kt");