Change Signature: Fix replacement of implicit Unit return type
This commit is contained in:
+1
-6
@@ -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() {
|
||||
|
||||
}
|
||||
}
|
||||
+4
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user