[NI] Fix exception on capturing stub type from coroutine-inference
#KT-30853 Fixed
This commit is contained in:
+8
@@ -75,6 +75,14 @@ interface NewTypeSubstitutor: TypeSubstitutorMarker {
|
||||
}
|
||||
val capturedType = if (type is DefinitelyNotNullType) type.original as NewCapturedType else type as NewCapturedType
|
||||
val lower = capturedType.lowerType?.let { substitute(it, keepAnnotation, runCapturedChecks = false) }
|
||||
if (lower != null && capturedType.lowerType is StubType) {
|
||||
return NewCapturedType(
|
||||
capturedType.captureStatus,
|
||||
NewCapturedTypeConstructor(TypeProjectionImpl(typeConstructor.projection.projectionKind, lower)),
|
||||
lower
|
||||
)
|
||||
}
|
||||
|
||||
if (lower != null) throw IllegalStateException(
|
||||
"Illegal type substitutor: $this, " +
|
||||
"because for captured type '$type' lower type approximation should be null, but it is: '$lower'," +
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !USE_EXPERIMENTAL: kotlin.Experimental
|
||||
|
||||
import kotlin.experimental.ExperimentalTypeInference
|
||||
|
||||
suspend fun main() {
|
||||
iFlow { emit(1) }
|
||||
}
|
||||
|
||||
|
||||
@UseExperimental(ExperimentalTypeInference::class)
|
||||
fun <K> iFlow(@BuilderInference block: suspend iFlowCollector<in K>.() -> Unit): iFlow<K> = TODO()
|
||||
|
||||
interface iFlowCollector<S> {
|
||||
suspend fun emit(value: S)
|
||||
}
|
||||
|
||||
interface iFlow<out V>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package
|
||||
|
||||
@kotlin.UseExperimental(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ K> iFlow(/*0*/ @kotlin.BuilderInference block: suspend iFlowCollector<in K>.() -> kotlin.Unit): iFlow<K>
|
||||
public suspend fun main(): kotlin.Unit
|
||||
|
||||
public interface iFlow</*0*/ out V> {
|
||||
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 iFlowCollector</*0*/ S> {
|
||||
public abstract suspend fun emit(/*0*/ value: S): kotlin.Unit
|
||||
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
@@ -1822,6 +1822,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/chainCallWithExtensionExplicitTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("coroutineInferenceWithCapturedTypeVariable.kt")
|
||||
public void testCoroutineInferenceWithCapturedTypeVariable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/coroutineInferenceWithCapturedTypeVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("correctMember.kt")
|
||||
public void testCorrectMember() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt");
|
||||
|
||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+5
@@ -1822,6 +1822,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/chainCallWithExtensionExplicitTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("coroutineInferenceWithCapturedTypeVariable.kt")
|
||||
public void testCoroutineInferenceWithCapturedTypeVariable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/coroutineInferenceWithCapturedTypeVariable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("correctMember.kt")
|
||||
public void testCorrectMember() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt");
|
||||
|
||||
Reference in New Issue
Block a user