EA-71185 - assert: CallResolverUtilPackage$CallResolverUtil$fcfb.hasUnknownReturnType
- Accept any subclasses of KCallable<R> as "callable reflection types" (this includes KProperty and KFunction with their subclasses). - Provide more detailed information on the callable reference type in question in case of assertion failures.
This commit is contained in:
@@ -44,19 +44,19 @@ public enum class ResolveArgumentsMode {
|
||||
|
||||
|
||||
public fun hasUnknownFunctionParameter(type: JetType): Boolean {
|
||||
assert(ReflectionTypes.isCallableType(type), "type is not a function or property")
|
||||
assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" }
|
||||
return getParameterArgumentsOfCallableType(type).any {
|
||||
TypeUtils.containsSpecialType(it.getType(), DONT_CARE) || ErrorUtils.containsUninferredParameter(it.getType())
|
||||
}
|
||||
}
|
||||
|
||||
public fun hasUnknownReturnType(type: JetType): Boolean {
|
||||
assert(ReflectionTypes.isCallableType(type), "type is not a function or property")
|
||||
assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" }
|
||||
return ErrorUtils.containsErrorType(getReturnTypeForCallable(type))
|
||||
}
|
||||
|
||||
public fun replaceReturnTypeByUnknown(type: JetType): JetType {
|
||||
assert(ReflectionTypes.isCallableType(type), "type is not a function or property")
|
||||
assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" }
|
||||
val newArguments = Lists.newArrayList<TypeProjection>()
|
||||
newArguments.addAll(getParameterArgumentsOfCallableType(type))
|
||||
newArguments.add(TypeProjectionImpl(Variance.INVARIANT, DONT_CARE))
|
||||
|
||||
@@ -114,22 +114,17 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
|
||||
return containingPackage != null && containingPackage.fqName == KOTLIN_REFLECT_FQ_NAME
|
||||
}
|
||||
|
||||
private val PROPERTY_CLASS_NAMES = hashSetOf(
|
||||
"KProperty", "KMutableProperty",
|
||||
"KProperty0", "KMutableProperty0",
|
||||
"KProperty1", "KMutableProperty1",
|
||||
"KProperty2", "KMutableProperty2"
|
||||
)
|
||||
private val KCALLABLE_CLASS_NAME = "KCallable"
|
||||
|
||||
public fun isCallableType(type: JetType): Boolean =
|
||||
KotlinBuiltIns.isFunctionOrExtensionFunctionType(type) ||
|
||||
isPropertyType(type)
|
||||
isCallableReflectionType(type)
|
||||
|
||||
public fun isPropertyType(type: JetType): Boolean =
|
||||
isExactPropertyType(type) ||
|
||||
type.getConstructor().getSupertypes().any { isPropertyType(it) }
|
||||
public fun isCallableReflectionType(type: JetType): Boolean =
|
||||
isExactCallableReflectionType(type) ||
|
||||
type.constructor.getSupertypes().any { isCallableReflectionType(it) }
|
||||
|
||||
public fun isExactPropertyType(type: JetType): Boolean {
|
||||
public fun isExactCallableReflectionType(type: JetType): Boolean {
|
||||
val descriptor = type.getConstructor().getDeclarationDescriptor()
|
||||
if (descriptor is ClassDescriptor) {
|
||||
val fqName = DescriptorUtils.getFqName(descriptor)
|
||||
@@ -137,7 +132,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
|
||||
if (parentName != KOTLIN_REFLECT_FQ_NAME.asString())
|
||||
return false
|
||||
val shortName = fqName.shortName().asString()
|
||||
return PROPERTY_CLASS_NAMES.contains(shortName)
|
||||
return KCALLABLE_CLASS_NAME == shortName
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user