[FIR] Support builder (coroutine) inference
#KT-37431 Fixed
This commit is contained in:
@@ -6,10 +6,31 @@
|
||||
package org.jetbrains.kotlin.fir.types
|
||||
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.utils.SmartSet
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
val ConeKotlinType.isNullable: Boolean get() = nullability != ConeNullability.NOT_NULL
|
||||
|
||||
val ConeKotlinType.isMarkedNullable: Boolean get() = nullability == ConeNullability.NULLABLE
|
||||
|
||||
val ConeKotlinType.classId: ClassId? get() = this.safeAs<ConeClassLikeType>()?.lookupTag?.classId
|
||||
val ConeKotlinType.classId: ClassId? get() = this.safeAs<ConeClassLikeType>()?.lookupTag?.classId
|
||||
|
||||
fun ConeKotlinType.contains(predicate: (ConeKotlinType) -> Boolean): Boolean {
|
||||
return contains(predicate, null)
|
||||
}
|
||||
|
||||
private fun ConeKotlinType.contains(predicate: (ConeKotlinType) -> Boolean, visited: SmartSet<ConeKotlinType>?): Boolean {
|
||||
if (visited?.contains(this) == true) return false
|
||||
if (predicate(this)) return true
|
||||
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val visited = visited ?: SmartSet.create()
|
||||
visited += this
|
||||
|
||||
return when (this) {
|
||||
is ConeFlexibleType -> lowerBound.contains(predicate, visited) || upperBound.contains(predicate, visited)
|
||||
is ConeDefinitelyNotNullType -> original.contains(predicate, visited)
|
||||
is ConeIntersectionType -> intersectedTypes.any { it.contains(predicate, visited) }
|
||||
else -> typeArguments.any { it is ConeKotlinTypeProjection && it.type.contains(predicate, visited) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user