[NI] Fix OnlyInputTypes for captured types

Uncapture projections recursively for cases when captured type is not
top-level type or first level type argument
This commit is contained in:
Pavel Kirpichenkov
2019-12-11 16:20:43 +03:00
parent 16db3a8b5f
commit 2fc79856a2
5 changed files with 49 additions and 6 deletions
@@ -265,15 +265,25 @@ fun UnwrappedType.unCapture(): UnwrappedType = when (this) {
}
fun SimpleType.unCapture(): UnwrappedType {
if (this is ErrorType) return this
if (this is NewCapturedType)
return unCaptureTopLevelType()
val newArguments = arguments.map { projection ->
projection.type.constructor.safeAs<NewCapturedTypeConstructor>()?.let {
it.projection
} ?: projection
}
return replace(newArguments)
val newArguments = arguments.map(::unCaptureProjection)
return replace(newArguments).unwrap()
}
fun unCaptureProjection(projection: TypeProjection): TypeProjection {
val unCapturedProjection = projection.type.constructor.safeAs<NewCapturedTypeConstructor>()?.let {
it.projection
} ?: projection
if (unCapturedProjection.type is ErrorType) return unCapturedProjection
val newArguments = unCapturedProjection.type.arguments.map(::unCaptureProjection)
return TypeProjectionImpl(
unCapturedProjection.projectionKind,
unCapturedProjection.type.replace(newArguments)
)
}
fun AbbreviatedType.unCapture(): SimpleType {