From fbbd1a268b5dec5881971f698a0c1dcf9005723d Mon Sep 17 00:00:00 2001 From: Dmitry Savvinov Date: Tue, 23 Apr 2019 20:31:13 +0300 Subject: [PATCH] [Misc] Minor: generalize TypeUtils.closure --- core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt index 77e76db2817..3178c316b0b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt @@ -130,7 +130,7 @@ fun KotlinType.isDefaultBound(): Boolean = KotlinBuiltIns.isDefaultBound(getSupe fun createProjection(type: KotlinType, projectionKind: Variance, typeParameterDescriptor: TypeParameterDescriptor?): TypeProjection = TypeProjectionImpl(if (typeParameterDescriptor?.variance == projectionKind) Variance.INVARIANT else projectionKind, type) -fun Collection.closure(f: (KotlinType) -> Collection): Collection { +fun Collection.closure(f: (T) -> Collection): Collection { if (size == 0) return this val result = HashSet(this) @@ -138,7 +138,7 @@ fun Collection.closure(f: (KotlinType) -> Collection): C var oldSize = 0 while (result.size > oldSize) { oldSize = result.size - val toAdd = hashSetOf() + val toAdd = hashSetOf() elementsToCheck.forEach { toAdd.addAll(f(it)) } result.addAll(toAdd) elementsToCheck = toAdd