diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt index 7a94cc38321..3aca69a1cb5 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt @@ -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 ) } diff --git a/compiler/testData/codegen/box/inference/builderInference/callableReferencesProperCompletion.kt b/compiler/testData/codegen/box/inference/builderInference/callableReferencesProperCompletion.kt index b58671c7534..56334ffec2f 100644 --- a/compiler/testData/codegen/box/inference/builderInference/callableReferencesProperCompletion.kt +++ b/compiler/testData/codegen/box/inference/builderInference/callableReferencesProperCompletion.kt @@ -20,7 +20,7 @@ fun foo() { fun test2(): Sequence = sequence { yield("") -// id(this::class) // TODO + id(this::class) } fun test3(): Sequence = sequence {