FIR Java (raw type bounds erasure): make better protection from recursion
This commit is contained in:
@@ -186,10 +186,11 @@ private fun FirTypeParameter.getErasedUpperBound(
|
|||||||
return firstUpperBound.withArguments(firstUpperBound.typeArguments.map { ConeStarProjection }.toTypedArray())
|
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
|
var current = (firstUpperBound as ConeTypeParameterType).lookupTag.typeParameterSymbol.fir
|
||||||
|
|
||||||
while (current != stopAt) {
|
while (current !in alreadyVisited) {
|
||||||
|
alreadyVisited += current
|
||||||
|
|
||||||
val nextUpperBound = current.bounds.first().coneTypeUnsafe<ConeKotlinType>()
|
val nextUpperBound = current.bounds.first().coneTypeUnsafe<ConeKotlinType>()
|
||||||
if (nextUpperBound is ConeClassLikeType) {
|
if (nextUpperBound is ConeClassLikeType) {
|
||||||
|
|||||||
Reference in New Issue
Block a user