[NI] Avoid builder-inference algorithm if types specified explicitly
#KT-30620 Fixed
This commit is contained in:
+3
@@ -236,6 +236,9 @@ internal object PostponedVariablesInitializerResolutionPart : ResolutionPart() {
|
|||||||
val receiverType = parameter.type.getReceiverTypeFromFunctionType() ?: continue
|
val receiverType = parameter.type.getReceiverTypeFromFunctionType() ?: continue
|
||||||
|
|
||||||
for (freshVariable in resolvedCall.substitutor.freshVariables) {
|
for (freshVariable in resolvedCall.substitutor.freshVariables) {
|
||||||
|
if (resolvedCall.typeArgumentMappingByOriginal.getTypeArgument(freshVariable.originalTypeParameter) is SimpleTypeArgument)
|
||||||
|
continue
|
||||||
|
|
||||||
if (csBuilder.isPostponedTypeVariable(freshVariable)) continue
|
if (csBuilder.isPostponedTypeVariable(freshVariable)) continue
|
||||||
if (receiverType.contains { it.constructor == freshVariable.originalTypeParameter.typeConstructor }) {
|
if (receiverType.contains { it.constructor == freshVariable.originalTypeParameter.typeConstructor }) {
|
||||||
csBuilder.markPostponedVariable(freshVariable)
|
csBuilder.markPostponedVariable(freshVariable)
|
||||||
|
|||||||
+24
@@ -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()
|
||||||
+35
@@ -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
|
||||||
|
}
|
||||||
+5
@@ -1802,6 +1802,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/applyInsideCoroutine.kt");
|
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")
|
@TestMetadata("correctMember.kt")
|
||||||
public void testCorrectMember() throws Exception {
|
public void testCorrectMember() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt");
|
||||||
|
|||||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+5
@@ -1802,6 +1802,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/applyInsideCoroutine.kt");
|
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")
|
@TestMetadata("correctMember.kt")
|
||||||
public void testCorrectMember() throws Exception {
|
public void testCorrectMember() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user