[FIR] Unwrap definitely not-null types in type parameter cycle checks

#KT-58944 Fixed
This commit is contained in:
Brian Norman
2023-06-09 07:19:47 -05:00
committed by Space Team
parent 2bbf57c15e
commit a71437335b
4 changed files with 13 additions and 4 deletions
@@ -289,8 +289,14 @@ open class FirTypeResolveTransformer(
if (visited.isNotEmpty() && currentTypeParameter == typeParameter) return true
if (!visited.add(currentTypeParameter)) return false
fun ConeKotlinType.toNextTypeParameter(): FirTypeParameter? = when (this) {
is ConeTypeParameterType -> lookupTag.typeParameterSymbol.fir
is ConeDefinitelyNotNullType -> original.toNextTypeParameter()
else -> null
}
return currentTypeParameter.bounds.any {
val nextTypeParameter = it.coneTypeSafe<ConeTypeParameterType>()?.lookupTag?.typeParameterSymbol?.fir ?: return@any false
val nextTypeParameter = it.coneTypeOrNull?.toNextTypeParameter() ?: return@any false
hasSupertypePathToParameter(nextTypeParameter, typeParameter, visited)
}