Minor. Rename TypeUtils.containsSpecialType -> contains
This commit is contained in:
+2
-2
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.types.KotlinType
|
|||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.types.replace
|
import org.jetbrains.kotlin.types.replace
|
||||||
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
|
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
|
||||||
import org.jetbrains.kotlin.types.typeUtil.containsSpecialType
|
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||||
|
|
||||||
// If type 'samType' contains no projection, then it's non-projection parametrization is 'samType' itself
|
// If type 'samType' contains no projection, then it's non-projection parametrization is 'samType' itself
|
||||||
@@ -44,7 +44,7 @@ internal fun nonProjectionParametrization(samType: KotlinType): KotlinType? {
|
|||||||
|
|
||||||
projection.isStarProjection ->
|
projection.isStarProjection ->
|
||||||
parameter.upperBounds.first().check {
|
parameter.upperBounds.first().check {
|
||||||
t -> !t.containsSpecialType { it.constructor.declarationDescriptor in parametersSet }
|
t -> !t.contains { it.constructor.declarationDescriptor in parametersSet }
|
||||||
}?.asTypeProjection() ?: return@nonProjectionParametrization null
|
}?.asTypeProjection() ?: return@nonProjectionParametrization null
|
||||||
|
|
||||||
else -> projection.type.asTypeProjection()
|
else -> projection.type.asTypeProjection()
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ fun ResolutionContext<*>.reportTypeMismatchDueToTypeProjection(
|
|||||||
expectedType: KotlinType,
|
expectedType: KotlinType,
|
||||||
expressionType: KotlinType?
|
expressionType: KotlinType?
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (!TypeUtils.containsSpecialType(expectedType) { it.isAnyOrNullableAny() || it.isNothing() || it.isNullableNothing() }) return false
|
if (!TypeUtils.contains(expectedType) { it.isAnyOrNullableAny() || it.isNothing() || it.isNullableNothing() }) return false
|
||||||
|
|
||||||
val callPosition = this.callPosition
|
val callPosition = this.callPosition
|
||||||
val (resolvedCall, correspondingNotApproximatedTypeByDescriptor: (CallableDescriptor) -> KotlinType?) = when (callPosition) {
|
val (resolvedCall, correspondingNotApproximatedTypeByDescriptor: (CallableDescriptor) -> KotlinType?) = when (callPosition) {
|
||||||
@@ -71,7 +71,7 @@ fun ResolutionContext<*>.reportTypeMismatchDueToTypeProjection(
|
|||||||
.buildSubstitutor().let { callableDescriptor.substitute(it) } ?: return false
|
.buildSubstitutor().let { callableDescriptor.substitute(it) } ?: return false
|
||||||
|
|
||||||
val nonApproximatedExpectedType = correspondingNotApproximatedTypeByDescriptor(substitutedDescriptor) ?: return false
|
val nonApproximatedExpectedType = correspondingNotApproximatedTypeByDescriptor(substitutedDescriptor) ?: return false
|
||||||
if (!TypeUtils.containsSpecialType(nonApproximatedExpectedType) { it.isCaptured() }) return false
|
if (!TypeUtils.contains(nonApproximatedExpectedType) { it.isCaptured() }) return false
|
||||||
|
|
||||||
if (expectedType.isNothing()) {
|
if (expectedType.isNothing()) {
|
||||||
if (callPosition is CallPosition.PropertyAssignment) {
|
if (callPosition is CallPosition.PropertyAssignment) {
|
||||||
|
|||||||
@@ -843,7 +843,7 @@ class DeclarationsChecker(
|
|||||||
descriptor: PropertyDescriptor): Boolean {
|
descriptor: PropertyDescriptor): Boolean {
|
||||||
val receiverParameter = descriptor.extensionReceiverParameter ?: return false
|
val receiverParameter = descriptor.extensionReceiverParameter ?: return false
|
||||||
|
|
||||||
return TypeUtils.containsSpecialType(receiverParameter.type) { parameter == it.constructor.declarationDescriptor }
|
return TypeUtils.contains(receiverParameter.type) { parameter == it.constructor.declarationDescriptor }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hasDefaultConstructor(classDescriptor: ClassDescriptor) =
|
private fun hasDefaultConstructor(classDescriptor: ClassDescriptor) =
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ class FunctionDescriptorResolver(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isFunctionLiteral(functionDescriptor) || isFunctionExpression(functionDescriptor)) {
|
if (isFunctionLiteral(functionDescriptor) || isFunctionExpression(functionDescriptor)) {
|
||||||
val containsUninferredParameter = TypeUtils.containsSpecialType(expectedType) {
|
val containsUninferredParameter = TypeUtils.contains(expectedType) {
|
||||||
TypeUtils.isDontCarePlaceholder(it) || ErrorUtils.isUninferredParameter(it)
|
TypeUtils.isDontCarePlaceholder(it) || ErrorUtils.isUninferredParameter(it)
|
||||||
}
|
}
|
||||||
if (expectedType == null || containsUninferredParameter) {
|
if (expectedType == null || containsUninferredParameter) {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ enum class ResolveArgumentsMode {
|
|||||||
fun hasUnknownFunctionParameter(type: KotlinType): Boolean {
|
fun hasUnknownFunctionParameter(type: KotlinType): Boolean {
|
||||||
assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" }
|
assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" }
|
||||||
return getParameterArgumentsOfCallableType(type).any {
|
return getParameterArgumentsOfCallableType(type).any {
|
||||||
TypeUtils.containsSpecialType(it.type, DONT_CARE) || ErrorUtils.containsUninferredParameter(it.type)
|
TypeUtils.contains(it.type, DONT_CARE) || ErrorUtils.containsUninferredParameter(it.type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -100,7 +100,7 @@ class ConstraintSystemBuilderImpl : ConstraintSystem.Builder {
|
|||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KotlinType.isProper() = !TypeUtils.containsSpecialType(this) {
|
private fun KotlinType.isProper() = !TypeUtils.contains(this) {
|
||||||
type -> type.constructor.declarationDescriptor.let { it is TypeParameterDescriptor && isMyTypeVariable(it) }
|
type -> type.constructor.declarationDescriptor.let { it is TypeParameterDescriptor && isMyTypeVariable(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -119,7 +119,7 @@ internal class ConstraintSystemImpl(
|
|||||||
if (substituteOriginal) variable.originalTypeParameter.typeConstructor
|
if (substituteOriginal) variable.originalTypeParameter.typeConstructor
|
||||||
else variable.type.constructor
|
else variable.type.constructor
|
||||||
val type =
|
val type =
|
||||||
if (value != null && !TypeUtils.containsSpecialType(value, DONT_CARE)) value
|
if (value != null && !TypeUtils.contains(value, DONT_CARE)) value
|
||||||
else getDefaultType(variable)
|
else getDefaultType(variable)
|
||||||
substitutionContext.put(typeConstructor, TypeProjectionImpl(type))
|
substitutionContext.put(typeConstructor, TypeProjectionImpl(type))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ fun approximateCapturedTypesIfNecessary(typeProjection: TypeProjection?, approxi
|
|||||||
if (typeProjection.isStarProjection) return typeProjection
|
if (typeProjection.isStarProjection) return typeProjection
|
||||||
|
|
||||||
val type = typeProjection.type
|
val type = typeProjection.type
|
||||||
if (!TypeUtils.containsSpecialType(type, { it.isCaptured() })) {
|
if (!TypeUtils.contains(type, { it.isCaptured() })) {
|
||||||
return typeProjection
|
return typeProjection
|
||||||
}
|
}
|
||||||
val howThisTypeIsUsed = typeProjection.projectionKind
|
val howThisTypeIsUsed = typeProjection.projectionKind
|
||||||
|
|||||||
@@ -554,7 +554,7 @@ public class ErrorUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean containsUninferredParameter(@Nullable KotlinType type) {
|
public static boolean containsUninferredParameter(@Nullable KotlinType type) {
|
||||||
return TypeUtils.containsSpecialType(type, new Function1<KotlinType, Boolean>() {
|
return TypeUtils.contains(type, new Function1<KotlinType, Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean invoke(KotlinType argumentType) {
|
public Boolean invoke(KotlinType argumentType) {
|
||||||
return isUninferredParameter(argumentType);
|
return isUninferredParameter(argumentType);
|
||||||
|
|||||||
@@ -426,8 +426,8 @@ public class TypeUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean containsSpecialType(@Nullable KotlinType type, @NotNull final KotlinType specialType) {
|
public static boolean contains(@Nullable KotlinType type, @NotNull final KotlinType specialType) {
|
||||||
return containsSpecialType(type, new Function1<KotlinType, Boolean>() {
|
return contains(type, new Function1<KotlinType, Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean invoke(KotlinType type) {
|
public Boolean invoke(KotlinType type) {
|
||||||
return specialType.equals(type);
|
return specialType.equals(type);
|
||||||
@@ -435,7 +435,7 @@ public class TypeUtils {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean containsSpecialType(
|
public static boolean contains(
|
||||||
@Nullable KotlinType type,
|
@Nullable KotlinType type,
|
||||||
@NotNull Function1<KotlinType, Boolean> isSpecialType
|
@NotNull Function1<KotlinType, Boolean> isSpecialType
|
||||||
) {
|
) {
|
||||||
@@ -443,11 +443,11 @@ public class TypeUtils {
|
|||||||
if (isSpecialType.invoke(type)) return true;
|
if (isSpecialType.invoke(type)) return true;
|
||||||
Flexibility flexibility = type.getCapability(Flexibility.class);
|
Flexibility flexibility = type.getCapability(Flexibility.class);
|
||||||
if (flexibility != null
|
if (flexibility != null
|
||||||
&& (containsSpecialType(flexibility.getLowerBound(), isSpecialType) || containsSpecialType(flexibility.getUpperBound(), isSpecialType))) {
|
&& (contains(flexibility.getLowerBound(), isSpecialType) || contains(flexibility.getUpperBound(), isSpecialType))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (TypeProjection projection : type.getArguments()) {
|
for (TypeProjection projection : type.getArguments()) {
|
||||||
if (!projection.isStarProjection() && containsSpecialType(projection.getType(), isSpecialType)) return true;
|
if (!projection.isStarProjection() && contains(projection.getType(), isSpecialType)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,4 +146,4 @@ fun KotlinType.getImmediateSuperclassNotAny(): KotlinType? {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun KotlinType.asTypeProjection(): TypeProjection = TypeProjectionImpl(this)
|
fun KotlinType.asTypeProjection(): TypeProjection = TypeProjectionImpl(this)
|
||||||
fun KotlinType.containsSpecialType(predicate: (KotlinType) -> Boolean) = TypeUtils.containsSpecialType(this, predicate)
|
fun KotlinType.contains(predicate: (KotlinType) -> Boolean) = TypeUtils.contains(this, predicate)
|
||||||
|
|||||||
Reference in New Issue
Block a user