FIR Java (raw type bounds erasure): make better protection from recursion

This commit is contained in:
Mikhail Glukhikh
2019-11-19 23:22:36 +03:00
parent 95203e9310
commit 137e54db05
@@ -186,10 +186,11 @@ private fun FirTypeParameter.getErasedUpperBound(
return firstUpperBound.withArguments(firstUpperBound.typeArguments.map { ConeStarProjection }.toTypedArray())
}
val stopAt = potentiallyRecursiveTypeParameter ?: this
val alreadyVisited = mutableSetOf(potentiallyRecursiveTypeParameter, this)
var current = (firstUpperBound as ConeTypeParameterType).lookupTag.typeParameterSymbol.fir
while (current != stopAt) {
while (current !in alreadyVisited) {
alreadyVisited += current
val nextUpperBound = current.bounds.first().coneTypeUnsafe<ConeKotlinType>()
if (nextUpperBound is ConeClassLikeType) {