[NI] Avoid builder-inference algorithm if types specified explicitly

#KT-30620 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2019-03-26 14:09:56 +03:00
parent 1ac3542036
commit b033b9180b
5 changed files with 72 additions and 0 deletions
@@ -236,6 +236,9 @@ internal object PostponedVariablesInitializerResolutionPart : ResolutionPart() {
val receiverType = parameter.type.getReceiverTypeFromFunctionType() ?: continue
for (freshVariable in resolvedCall.substitutor.freshVariables) {
if (resolvedCall.typeArgumentMappingByOriginal.getTypeArgument(freshVariable.originalTypeParameter) is SimpleTypeArgument)
continue
if (csBuilder.isPostponedTypeVariable(freshVariable)) continue
if (receiverType.contains { it.constructor == freshVariable.originalTypeParameter.typeConstructor }) {
csBuilder.markPostponedVariable(freshVariable)
@@ -0,0 +1,24 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !USE_EXPERIMENTAL: kotlin.Experimental
import kotlin.experimental.ExperimentalTypeInference
class Inv<K>(val value: K)
interface ProducerScope<E> {
val prop: Inv<E>
}
class CoroutineScope
class ReceiveChannel<E>
@UseExperimental(ExperimentalTypeInference::class)
public fun <E> produce(@BuilderInference block: suspend ProducerScope<E>.() -> Unit): ProducerScope<E> = TODO()
fun test(ls: List<Int>) =
produce<Int> {
ls.asReceiveChannel().toChannel(prop)
}
private fun <E> Iterable<E>.asReceiveChannel(): ReceiveChannel<E> = TODO()
public suspend fun <E, C> ReceiveChannel<E>.toChannel(destination: C): C = TODO()
@@ -0,0 +1,35 @@
package
@kotlin.UseExperimental(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ E> produce(/*0*/ @kotlin.BuilderInference block: suspend ProducerScope<E>.() -> kotlin.Unit): ProducerScope<E>
public fun test(/*0*/ ls: kotlin.collections.List<kotlin.Int>): ProducerScope<kotlin.Int>
private fun </*0*/ E> kotlin.collections.Iterable<E>.asReceiveChannel(): ReceiveChannel<E>
public suspend fun </*0*/ E, /*1*/ C> ReceiveChannel<E>.toChannel(/*0*/ destination: C): C
public final class CoroutineScope {
public constructor CoroutineScope()
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 Inv</*0*/ K> {
public constructor Inv</*0*/ K>(/*0*/ value: K)
public final val value: K
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</*0*/ E> {
public abstract val prop: Inv<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 final class ReceiveChannel</*0*/ E> {
public constructor ReceiveChannel</*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
}
@@ -1802,6 +1802,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/applyInsideCoroutine.kt");
}
@TestMetadata("chainCallWithExtensionExplicitTypes.kt")
public void testChainCallWithExtensionExplicitTypes() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/chainCallWithExtensionExplicitTypes.kt");
}
@TestMetadata("correctMember.kt")
public void testCorrectMember() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt");
@@ -1802,6 +1802,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/applyInsideCoroutine.kt");
}
@TestMetadata("chainCallWithExtensionExplicitTypes.kt")
public void testChainCallWithExtensionExplicitTypes() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/chainCallWithExtensionExplicitTypes.kt");
}
@TestMetadata("correctMember.kt")
public void testCorrectMember() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt");