diff --git a/compiler/ast/src/main/kotlin/com/uber/xprocessing/ext/XType.kt b/compiler/ast/src/main/kotlin/com/uber/xprocessing/ext/XType.kt index 261291b9..e303ead3 100644 --- a/compiler/ast/src/main/kotlin/com/uber/xprocessing/ext/XType.kt +++ b/compiler/ast/src/main/kotlin/com/uber/xprocessing/ext/XType.kt @@ -312,8 +312,16 @@ fun XType.isPrimitive(): Boolean { } private fun XType.hasCollectionType(): Boolean { - return this.typeElement?.name.orEmpty() in collectionTypes || - typeArguments.any { it.hasCollectionType() } + val visited = mutableSetOf() + val queue = mutableListOf(this@hasCollectionType) + while (queue.isNotEmpty()) { + val type = queue.removeFirst() + if (type in visited) continue + if (type.typeElement?.name in collectionTypes) return true + visited.add(type) + queue.addAll(type.typeArguments) + } + return false } private val collectionTypes =