diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt b/idea/src/org/jetbrains/jet/plugin/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt index 2d1f31f338a..7ec405dcb7f 100644 --- a/idea/src/org/jetbrains/jet/plugin/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt @@ -80,7 +80,7 @@ class TypeCandidate(val theType: JetType, scope: JetScope? = null) { var renderedTypeParameters: List? = null private set - fun render(typeParameterNameMap: Map, fakeFunction: FunctionDescriptor) { + fun render(typeParameterNameMap: Map, fakeFunction: FunctionDescriptor?) { renderedType = theType.renderShort(typeParameterNameMap); renderedTypeParameters = typeParameters.map { RenderedTypeParameter(it, it.getContainingDeclaration() == fakeFunction, typeParameterNameMap[it]!!) @@ -114,7 +114,8 @@ class CallableBuilderConfiguration( val callableInfos: List, val originalExpression: JetExpression, val currentFile: JetFile, - val currentEditor: Editor + val currentEditor: Editor, + val enableSubstitutions: Boolean = true ) fun CallableBuilderConfiguration( @@ -254,18 +255,24 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { (receiverClassDescriptor as ClassDescriptorWithResolutionScopes).getScopeForMemberDeclarationResolution() } + val fakeFunction: FunctionDescriptor? // figure out type substitutions for type parameters val substitutionMap = LinkedHashMap() - collectSubstitutionsForReceiverTypeParameters(receiverType, substitutionMap) - val typeArgumentsForFakeFunction = callableInfo.typeParameterInfos - .map { - val typeCandidates = computeTypeCandidates(it) - assert (typeCandidates.size == 1, "Ambiguous type candidates for type parameter $it: $typeCandidates") - typeCandidates.first().theType - } - .subtract(substitutionMap.keySet()) - val fakeFunction = createFakeFunctionDescriptor(scope, typeArgumentsForFakeFunction.size) - collectSubstitutionsForCallableTypeParameters(fakeFunction, typeArgumentsForFakeFunction, substitutionMap) + if (config.enableSubstitutions) { + collectSubstitutionsForReceiverTypeParameters(receiverType, substitutionMap) + val typeArgumentsForFakeFunction = callableInfo.typeParameterInfos + .map { + val typeCandidates = computeTypeCandidates(it) + assert (typeCandidates.size == 1, "Ambiguous type candidates for type parameter $it: $typeCandidates") + typeCandidates.first().theType + } + .subtract(substitutionMap.keySet()) + fakeFunction = createFakeFunctionDescriptor(scope, typeArgumentsForFakeFunction.size) + collectSubstitutionsForCallableTypeParameters(fakeFunction!!, typeArgumentsForFakeFunction, substitutionMap) + } + else { + fakeFunction = null + } substitutions = substitutionMap.map { JetTypeSubstitution(it.key, it.value) } callableInfo.parameterInfos.forEach { @@ -336,7 +343,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { private fun renderTypeCandidates( typeInfo: TypeInfo, typeParameterNameMap: Map, - fakeFunction: FunctionDescriptor + fakeFunction: FunctionDescriptor? ) { typeCandidates[typeInfo]?.forEach { it.render(typeParameterNameMap, fakeFunction) } }