Change Signature: Fix replacement of implicit Unit return type

This commit is contained in:
Alexey Sedunov
2017-08-10 15:17:12 +03:00
parent 386b1fc002
commit f455f06a9e
4 changed files with 27 additions and 6 deletions
@@ -148,12 +148,7 @@ class KotlinCallableDefinitionUsage<T : PsiElement>(
if (element !is KtCallableDeclaration) return
if (element is KtConstructor<*>) return
val returnTypeIsNeeded = if (element is KtFunction) {
element !is KtFunctionLiteral && (changeInfo.isRefactoringTarget(originalCallableDescriptor) || element.typeReference != null)
}
else {
element is KtProperty || element is KtParameter
}
val returnTypeIsNeeded = (element is KtFunction && element !is KtFunctionLiteral) || element is KtProperty || element is KtParameter
if (changeInfo.isReturnTypeChanged && returnTypeIsNeeded) {
element.typeReference = null
@@ -0,0 +1,11 @@
open class A {
open fun foo(): Int {
}
}
class B : A() {
override fun foo(): Int {
}
}
@@ -0,0 +1,11 @@
open class A {
open fun <caret>foo() {
}
}
class B : A() {
override fun foo() {
}
}
@@ -956,4 +956,8 @@ class KotlinChangeSignatureTest : KotlinLightCodeInsightFixtureTestCase() {
newName = "bar"
newReturnTypeInfo = resolveType("A<T, U>", true, true)
}
fun testChangeReturnTypeToNonUnit() = doTest {
newReturnTypeInfo = KotlinTypeInfo(true, BUILT_INS.intType)
}
}