Do substitution captured type's super types as well

^KT-45982 Fixed
This commit is contained in:
Victor Petukhov
2021-04-09 13:19:03 +03:00
parent e8275d2527
commit 73a2838555
2 changed files with 4 additions and 2 deletions
@@ -104,6 +104,8 @@ interface NewTypeSubstitutor : TypeSubstitutorMarker {
val innerType = capturedType.lowerType ?: capturedType.constructor.projection.type.unwrap()
val substitutedInnerType = substitute(innerType, keepAnnotation, runCapturedChecks = false)
val substitutedSuperTypes =
capturedType.constructor.supertypes.map { substitute(it, keepAnnotation, runCapturedChecks = false) ?: it }
if (substitutedInnerType != null) {
return if (substitutedInnerType.isCaptured()) substitutedInnerType else {
@@ -112,7 +114,7 @@ interface NewTypeSubstitutor : TypeSubstitutorMarker {
NewCapturedTypeConstructor(
TypeProjectionImpl(typeConstructor.projection.projectionKind, substitutedInnerType),
typeParameter = typeConstructor.typeParameter
),
).also { it.initializeSupertypes(substitutedSuperTypes) },
lowerType = if (capturedType.lowerType != null) substitutedInnerType else null
)
}
@@ -20,7 +20,7 @@ fun foo() {
fun test2(): Sequence<String> = sequence {
yield("")
// id(this::class) // TODO
id(this::class)
}
fun test3(): Sequence<String> = sequence {