From a60f32b919d075548ff42450dfa6e76c5f14ff03 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 28 Nov 2014 15:50:54 +0300 Subject: [PATCH] More correct and simple code --- .../jetbrains/jet/plugin/util/extensionsUtils.kt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/idea/ide-common/src/org/jetbrains/jet/plugin/util/extensionsUtils.kt b/idea/ide-common/src/org/jetbrains/jet/plugin/util/extensionsUtils.kt index 21f5e778341..a4de58f4f8e 100644 --- a/idea/ide-common/src/org/jetbrains/jet/plugin/util/extensionsUtils.kt +++ b/idea/ide-common/src/org/jetbrains/jet/plugin/util/extensionsUtils.kt @@ -30,7 +30,6 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor import org.jetbrains.jet.lang.types.Variance import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintPosition import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintsUtil -import org.jetbrains.jet.lang.resolve.name.Name import org.jetbrains.jet.utils.addIfNotNull import java.util.HashSet import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor @@ -66,14 +65,14 @@ private fun checkReceiverResolution( receiverParameter: ReceiverParameterDescriptor, typeParameters: List ): Boolean { - val typeNamesInReceiver = HashSet() - typeNamesInReceiver.addUsedTypeNames(receiverParameter.getType()) + val typeNamesInReceiver = HashSet() + typeNamesInReceiver.addUsedTypeParameters(receiverParameter.getType()) val constraintSystem = ConstraintSystemImpl() val typeVariables = LinkedHashMap() for (typeParameter in typeParameters) { - if (typeNamesInReceiver.contains(typeParameter.getName())) { - typeVariables.put(typeParameter, Variance.INVARIANT) + if (typeNamesInReceiver.contains(typeParameter)) { + typeVariables[typeParameter] = Variance.INVARIANT } } constraintSystem.registerTypeVariables(typeVariables) @@ -82,12 +81,11 @@ private fun checkReceiverResolution( return constraintSystem.getStatus().isSuccessful() && ConstraintsUtil.checkBoundsAreSatisfied(constraintSystem, true) } -private fun MutableSet.addUsedTypeNames(jetType: JetType) { - val descriptor = jetType.getConstructor().getDeclarationDescriptor() - addIfNotNull(descriptor?.getName()) +private fun MutableSet.addUsedTypeParameters(jetType: JetType) { + addIfNotNull(jetType.getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor) for (argument in jetType.getArguments()) { - addUsedTypeNames(argument.getType()) + addUsedTypeParameters(argument.getType()) } }