diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.kt index a1e6e85f1f5..4d394fc69ad 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.kt @@ -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() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/diagnosticUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/diagnosticUtils.kt index 94e1bac2c8e..e63ad39e3f7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/diagnosticUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/diagnosticUtils.kt @@ -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) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt index c53cfed6470..277d1a9b7c3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt @@ -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) = diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt index 601b65b4d5e..1346290e303 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt @@ -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) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt index ee6c8979c63..b65a6e21546 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt @@ -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) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt index c8295ad38e1..1cd2c69199d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt @@ -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) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index af764befc04..b493a4e9b1d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -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)) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt b/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt index 2c9cda2aac8..1f236bd08cd 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt @@ -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 diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java index 39df4ba3a22..1475e98f7b5 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java @@ -554,7 +554,7 @@ public class ErrorUtils { } public static boolean containsUninferredParameter(@Nullable KotlinType type) { - return TypeUtils.containsSpecialType(type, new Function1() { + return TypeUtils.contains(type, new Function1() { @Override public Boolean invoke(KotlinType argumentType) { return isUninferredParameter(argumentType); diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java index 707531ff814..998433a62f8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java @@ -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() { + public static boolean contains(@Nullable KotlinType type, @NotNull final KotlinType specialType) { + return contains(type, new Function1() { @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 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; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt index e0aabb8285e..5929775975c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt @@ -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)