Refactoring: move getRepresentativeUpperBound method to core
Plus prettify it a bit
This commit is contained in:
@@ -228,3 +228,14 @@ fun UnwrappedType.canHaveUndefinedNullability(): Boolean =
|
||||
constructor is NewTypeVariableConstructor ||
|
||||
constructor.declarationDescriptor is TypeParameterDescriptor ||
|
||||
this is NewCapturedType
|
||||
|
||||
val TypeParameterDescriptor.representativeUpperBound: KotlinType
|
||||
get() {
|
||||
assert(upperBounds.isNotEmpty()) { "Upper bounds should not be empty: $this" }
|
||||
|
||||
return upperBounds.firstOrNull {
|
||||
val classDescriptor = it.constructor.declarationDescriptor as? ClassDescriptor ?: return@firstOrNull false
|
||||
classDescriptor.kind != ClassKind.INTERFACE && classDescriptor.kind != ClassKind.ANNOTATION_CLASS
|
||||
} ?: upperBounds.first()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user