Minor. Rename TypeUtils.containsSpecialType -> contains

This commit is contained in:
Denis Zharkov
2016-01-22 14:46:28 +03:00
parent a5c13ce8cf
commit 5baa0ed4bb
11 changed files with 17 additions and 17 deletions
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.types.replace
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
// 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 ->
parameter.upperBounds.first().check {
t -> !t.containsSpecialType { it.constructor.declarationDescriptor in parametersSet }
t -> !t.contains { it.constructor.declarationDescriptor in parametersSet }
}?.asTypeProjection() ?: return@nonProjectionParametrization null
else -> projection.type.asTypeProjection()
@@ -39,7 +39,7 @@ fun ResolutionContext<*>.reportTypeMismatchDueToTypeProjection(
expectedType: KotlinType,
expressionType: KotlinType?
): 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 (resolvedCall, correspondingNotApproximatedTypeByDescriptor: (CallableDescriptor) -> KotlinType?) = when (callPosition) {
@@ -71,7 +71,7 @@ fun ResolutionContext<*>.reportTypeMismatchDueToTypeProjection(
.buildSubstitutor().let { callableDescriptor.substitute(it) } ?: 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 (callPosition is CallPosition.PropertyAssignment) {
@@ -843,7 +843,7 @@ class DeclarationsChecker(
descriptor: PropertyDescriptor): Boolean {
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) =
@@ -326,7 +326,7 @@ class FunctionDescriptorResolver(
}
else {
if (isFunctionLiteral(functionDescriptor) || isFunctionExpression(functionDescriptor)) {
val containsUninferredParameter = TypeUtils.containsSpecialType(expectedType) {
val containsUninferredParameter = TypeUtils.contains(expectedType) {
TypeUtils.isDontCarePlaceholder(it) || ErrorUtils.isUninferredParameter(it)
}
if (expectedType == null || containsUninferredParameter) {
@@ -44,7 +44,7 @@ enum class ResolveArgumentsMode {
fun hasUnknownFunctionParameter(type: KotlinType): Boolean {
assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" }
return getParameterArgumentsOfCallableType(type).any {
TypeUtils.containsSpecialType(it.type, DONT_CARE) || ErrorUtils.containsUninferredParameter(it.type)
TypeUtils.contains(it.type, DONT_CARE) || ErrorUtils.containsUninferredParameter(it.type)
}
}
@@ -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) }
}
@@ -119,7 +119,7 @@ internal class ConstraintSystemImpl(
if (substituteOriginal) variable.originalTypeParameter.typeConstructor
else variable.type.constructor
val type =
if (value != null && !TypeUtils.containsSpecialType(value, DONT_CARE)) value
if (value != null && !TypeUtils.contains(value, DONT_CARE)) value
else getDefaultType(variable)
substitutionContext.put(typeConstructor, TypeProjectionImpl(type))
}
@@ -65,7 +65,7 @@ fun approximateCapturedTypesIfNecessary(typeProjection: TypeProjection?, approxi
if (typeProjection.isStarProjection) return typeProjection
val type = typeProjection.type
if (!TypeUtils.containsSpecialType(type, { it.isCaptured() })) {
if (!TypeUtils.contains(type, { it.isCaptured() })) {
return typeProjection
}
val howThisTypeIsUsed = typeProjection.projectionKind
@@ -554,7 +554,7 @@ public class ErrorUtils {
}
public static boolean containsUninferredParameter(@Nullable KotlinType type) {
return TypeUtils.containsSpecialType(type, new Function1<KotlinType, Boolean>() {
return TypeUtils.contains(type, new Function1<KotlinType, Boolean>() {
@Override
public Boolean invoke(KotlinType argumentType) {
return isUninferredParameter(argumentType);
@@ -426,8 +426,8 @@ public class TypeUtils {
return false;
}
public static boolean containsSpecialType(@Nullable KotlinType type, @NotNull final KotlinType specialType) {
return containsSpecialType(type, new Function1<KotlinType, Boolean>() {
public static boolean contains(@Nullable KotlinType type, @NotNull final KotlinType specialType) {
return contains(type, new Function1<KotlinType, Boolean>() {
@Override
public Boolean invoke(KotlinType type) {
return specialType.equals(type);
@@ -435,7 +435,7 @@ public class TypeUtils {
});
}
public static boolean containsSpecialType(
public static boolean contains(
@Nullable KotlinType type,
@NotNull Function1<KotlinType, Boolean> isSpecialType
) {
@@ -443,11 +443,11 @@ public class TypeUtils {
if (isSpecialType.invoke(type)) return true;
Flexibility flexibility = type.getCapability(Flexibility.class);
if (flexibility != null
&& (containsSpecialType(flexibility.getLowerBound(), isSpecialType) || containsSpecialType(flexibility.getUpperBound(), isSpecialType))) {
&& (contains(flexibility.getLowerBound(), isSpecialType) || contains(flexibility.getUpperBound(), isSpecialType))) {
return true;
}
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;
}
@@ -146,4 +146,4 @@ fun KotlinType.getImmediateSuperclassNotAny(): KotlinType? {
}
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)