diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt index 145de6475b3..fb07d15d4b2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt @@ -88,13 +88,18 @@ public class KtPsiFactory(private val project: Project) { } public fun createType(type: String): KtTypeReference { - val typeReference = createProperty("val x : $type").typeReference + val typeReference = createTypeIfPossible(type) if (typeReference == null || typeReference.text != type) { throw IllegalArgumentException("Incorrect type: $type") } return typeReference } + public fun createTypeIfPossible(type: String): KtTypeReference? { + val typeReference = createProperty("val x : $type").typeReference + return if (typeReference?.text == type) typeReference else null + } + public fun createStar(): PsiElement { return createType("List<*>").findElementAt(5)!! } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt index ac0d13d0aba..b32d94d7a9d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt @@ -247,7 +247,13 @@ public open class KotlinChangeInfo( if (kind == Kind.FUNCTION) { receiverParameterInfo?.let { - buffer.append(it.currentTypeText).append('.') + // TODO: Temporary solution until Change Signature is able to infer actual KotlinType from code fragments instead of using text representation + if (KtPsiFactory(context).createTypeIfPossible(it.currentTypeText)?.typeElement is KtFunctionType) { + buffer.append("(${it.currentTypeText})") + } else { + buffer.append(it.currentTypeText) + } + buffer.append('.') } }