Callable Builder: Do not skip unused type parameters

This commit is contained in:
Alexey Sedunov
2014-11-10 20:57:20 +03:00
parent 2f98af1a8e
commit 538248cafa
@@ -65,6 +65,7 @@ import org.jetbrains.jet.lang.descriptors.impl.MutablePackageFragmentDescriptor
import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl
import java.util.LinkedHashMap
import org.jetbrains.jet.plugin.util.IdeDescriptorRenderers
import org.jetbrains.jet.utils.addToStdlib.singletonOrEmptyList
private val TYPE_PARAMETER_LIST_VARIABLE_NAME = "typeParameterList"
private val TEMPLATE_FROM_USAGE_FUNCTION_BODY = "New Kotlin Function Body.kt"
@@ -256,6 +257,8 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
(receiverClassDescriptor as ClassDescriptorWithResolutionScopes).getScopeForMemberDeclarationResolution()
}
receiverTypeCandidate = receiverType?.let { TypeCandidate(it, scope) }
val fakeFunction: FunctionDescriptor?
// figure out type substitutions for type parameters
val substitutionMap = LinkedHashMap<JetType, JetType>()
@@ -270,7 +273,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
.subtract(substitutionMap.keySet())
fakeFunction = createFakeFunctionDescriptor(scope, typeArgumentsForFakeFunction.size)
collectSubstitutionsForCallableTypeParameters(fakeFunction!!, typeArgumentsForFakeFunction, substitutionMap)
mandatoryTypeParametersAsCandidates = typeArgumentsForFakeFunction.map { TypeCandidate(substitutionMap[it], scope) }
mandatoryTypeParametersAsCandidates = receiverTypeCandidate.singletonOrEmptyList() + typeArgumentsForFakeFunction.map { TypeCandidate(substitutionMap[it], scope) }
}
else {
fakeFunction = null
@@ -287,9 +290,6 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
&& returnTypeCandidates.size == 1
&& returnTypeCandidates.first().theType.isUnit()
// now that we have done substitutions, we can throw it away
receiverTypeCandidate = receiverType?.let { TypeCandidate(it, scope) }
// figure out type parameter renames to avoid conflicts
typeParameterNameMap = getTypeParameterRenames(scope)
callableInfo.parameterInfos.forEach { renderTypeCandidates(it.typeInfo, typeParameterNameMap, fakeFunction) }