[NI] Fix exception on capturing stub type from coroutine-inference

#KT-30853 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2019-05-06 18:03:20 +03:00
parent 90f11211d3
commit 1fecd15355
5 changed files with 54 additions and 0 deletions
@@ -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'," +