diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt index 591632693ff..c20546dc2bf 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt @@ -45,10 +45,10 @@ public class SubstitutingScope(private val workerScope: MemberScope, private val } private fun substitute(descriptors: Collection): Collection { - if (substitutor.isEmpty()) return descriptors + if (substitutor.isEmpty) return descriptors if (descriptors.isEmpty()) return descriptors - val result = newHashSetWithExpectedSize(descriptors.size()) + val result = newHashSetWithExpectedSize(descriptors.size) for (descriptor in descriptors) { val substitute = substitute(descriptor) if (substitute != null) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt b/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt index 322a780fe3f..5943fb5bb48 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/CapturedTypeApproximation.kt @@ -53,9 +53,9 @@ private fun TypeArgument.toTypeProjection(): TypeProjection { } private fun TypeProjection.toTypeArgument(typeParameter: TypeParameterDescriptor) = - when (TypeSubstitutor.combine(typeParameter.getVariance(), getProjectionKind())) { - Variance.INVARIANT -> TypeArgument(typeParameter, getType(), getType()) - Variance.IN_VARIANCE -> TypeArgument(typeParameter, getType(), typeParameter.builtIns.nullableAnyType) + when (TypeSubstitutor.combine(typeParameter.variance, projectionKind)) { + Variance.INVARIANT -> TypeArgument(typeParameter, type, type) + Variance.IN_VARIANCE -> TypeArgument(typeParameter, type, typeParameter.builtIns.nullableAnyType) Variance.OUT_VARIANCE -> TypeArgument(typeParameter, typeParameter.builtIns.nothingType, type) } @@ -86,25 +86,25 @@ private fun substituteCapturedTypes(typeProjection: TypeProjection): TypeProject } public fun approximateCapturedTypes(type: KotlinType): ApproximationBounds { - val typeConstructor = type.getConstructor() + val typeConstructor = type.constructor if (type.isCaptured()) { val typeProjection = (typeConstructor as CapturedTypeConstructor).typeProjection // todo: preserve flexibility as well - fun KotlinType.makeNullableIfNeeded() = TypeUtils.makeNullableIfNeeded(this, type.isMarkedNullable()) - val bound = typeProjection.getType().makeNullableIfNeeded() + fun KotlinType.makeNullableIfNeeded() = TypeUtils.makeNullableIfNeeded(this, type.isMarkedNullable) + val bound = typeProjection.type.makeNullableIfNeeded() - return when (typeProjection.getProjectionKind()) { + return when (typeProjection.projectionKind) { Variance.IN_VARIANCE -> ApproximationBounds(bound, type.builtIns.nullableAnyType) Variance.OUT_VARIANCE -> ApproximationBounds(type.builtIns.nothingType.makeNullableIfNeeded(), bound) else -> throw AssertionError("Only nontrivial projections should have been captured, not: $typeProjection") } } - if (type.getArguments().isEmpty()) { + if (type.arguments.isEmpty()) { return ApproximationBounds(type, type) } val lowerBoundArguments = ArrayList() val upperBoundArguments = ArrayList() - for ((typeProjection, typeParameter) in type.getArguments().zip(typeConstructor.getParameters())) { + for ((typeProjection, typeParameter) in type.arguments.zip(typeConstructor.parameters)) { val (lower, upper) = approximateProjection(typeProjection.toTypeArgument(typeParameter)) lowerBoundArguments.add(lower) upperBoundArguments.add(upper) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt index 5807ff50fc2..509a2277788 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt @@ -29,15 +29,15 @@ public abstract class TypeSubstitution { } } - public abstract operator fun get(key: KotlinType): TypeProjection? + abstract operator fun get(key: KotlinType): TypeProjection? - public open fun isEmpty(): Boolean = false + open fun isEmpty(): Boolean = false - public open fun approximateCapturedTypes(): Boolean = false + open fun approximateCapturedTypes(): Boolean = false - public open fun filterAnnotations(annotations: Annotations) = annotations + open fun filterAnnotations(annotations: Annotations) = annotations - public fun buildSubstitutor(): TypeSubstitutor = TypeSubstitutor.create(this) + fun buildSubstitutor(): TypeSubstitutor = TypeSubstitutor.create(this) } public abstract class TypeConstructorSubstitution : TypeSubstitution() { @@ -131,7 +131,7 @@ private class CompositeTypeSubstitution( } override fun isEmpty() = first.isEmpty() && second.isEmpty() - // + override fun approximateCapturedTypes() = first.approximateCapturedTypes() || second.approximateCapturedTypes() override fun filterAnnotations(annotations: Annotations): Annotations = second.filterAnnotations(first.filterAnnotations(annotations))