Fix order of fixing type variables for callable references. KT-25433 Fixed
This commit is contained in:
@@ -18,9 +18,13 @@ import org.jetbrains.kotlin.types.*
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
val KOTLIN_REFLECT_FQ_NAME = FqName("kotlin.reflect")
|
||||
val K_PROPERTY_PREFIX = "KProperty"
|
||||
val K_MUTABLE_PROPERTY_PREFIX = "KMutableProperty"
|
||||
val K_FUNCTION_PREFIX = "KFunction"
|
||||
val K_SUSPEND_FUNCTION_PREFIX = "KSuspendFunction"
|
||||
|
||||
val PREFIXES = listOf(K_PROPERTY_PREFIX, K_MUTABLE_PROPERTY_PREFIX, K_FUNCTION_PREFIX, K_SUSPEND_FUNCTION_PREFIX)
|
||||
|
||||
class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: NotFoundClasses) {
|
||||
private val kotlinReflectScope: MemberScope by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||
module.getPackage(KOTLIN_REFLECT_FQ_NAME).memberScope
|
||||
@@ -122,6 +126,20 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not
|
||||
hasFqName(descriptor, KotlinBuiltIns.FQ_NAMES.kMutableProperty2)
|
||||
}
|
||||
|
||||
fun isNumberedTypeWithOneOrMoreNumber(type: KotlinType): Boolean {
|
||||
val descriptor = type.constructor.declarationDescriptor as? ClassDescriptor ?: return false
|
||||
if (DescriptorUtils.getFqName(descriptor).parent().toSafe() != KOTLIN_REFLECT_FQ_NAME) return false
|
||||
val shortName = descriptor.name.asString()
|
||||
|
||||
for (prefix in PREFIXES) {
|
||||
if (shortName.startsWith(prefix)) {
|
||||
val number = shortName.removePrefix(prefix)
|
||||
return number.isNotEmpty() && number != "0"
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun hasKPropertyTypeFqName(type: KotlinType): Boolean =
|
||||
hasFqName(type.constructor, KotlinBuiltIns.FQ_NAMES.kPropertyFqName)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user