Change Signature: Avoid explicit Unit return type
This commit is contained in:
+2
-1
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.ChangeSignaturePack
|
|||||||
import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo;
|
import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo;
|
||||||
import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetParameterInfo;
|
import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetParameterInfo;
|
||||||
import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetValVar;
|
import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetValVar;
|
||||||
|
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers;
|
||||||
import org.jetbrains.kotlin.idea.util.ShortenReferences;
|
import org.jetbrains.kotlin.idea.util.ShortenReferences;
|
||||||
import org.jetbrains.kotlin.idea.util.ShortenReferences.Options;
|
import org.jetbrains.kotlin.idea.util.ShortenReferences.Options;
|
||||||
import org.jetbrains.kotlin.lexer.JetModifierKeywordToken;
|
import org.jetbrains.kotlin.lexer.JetModifierKeywordToken;
|
||||||
@@ -236,7 +237,7 @@ public class JetCallableDefinitionUsage<T extends PsiElement> extends JetUsageIn
|
|||||||
String returnTypeText = changeInfo.renderReturnType((JetCallableDefinitionUsage<PsiElement>) this);
|
String returnTypeText = changeInfo.renderReturnType((JetCallableDefinitionUsage<PsiElement>) this);
|
||||||
|
|
||||||
//TODO use ChangeFunctionReturnTypeFix.invoke when JetTypeCodeFragment.getType() is ready
|
//TODO use ChangeFunctionReturnTypeFix.invoke when JetTypeCodeFragment.getType() is ready
|
||||||
if (!KotlinBuiltIns.getInstance().getUnitType().toString().equals(returnTypeText)) {
|
if (!(returnTypeText.equals("Unit") || returnTypeText.equals("kotlin.Unit"))) {
|
||||||
ShortenPackage.addToShorteningWaitSet(
|
ShortenPackage.addToShorteningWaitSet(
|
||||||
callable.setTypeReference(JetPsiFactory(callable).createType(returnTypeText)),
|
callable.setTypeReference(JetPsiFactory(callable).createType(returnTypeText)),
|
||||||
Options.DEFAULT
|
Options.DEFAULT
|
||||||
|
|||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
open class X: A() {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
class A {
|
||||||
|
void <caret>foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
open class X: A() {
|
||||||
|
override fun foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
class A {
|
||||||
|
void <caret>foo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
open class C: A() {
|
open class C: A() {
|
||||||
override fun foo(n: Int, s: String): Unit {
|
override fun foo(n: Int, s: String) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
@@ -1296,6 +1296,10 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase {
|
|||||||
doTest(changeInfo);
|
doTest(changeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testJavaMethodOverridesOmitUnitType() throws Exception {
|
||||||
|
doJavaTest(new JavaRefactoringProvider());
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private LinkedHashSet<PsiMethod> findCallers(@NotNull PsiMethod method) {
|
private LinkedHashSet<PsiMethod> findCallers(@NotNull PsiMethod method) {
|
||||||
KotlinMethodNode rootNode =
|
KotlinMethodNode rootNode =
|
||||||
|
|||||||
Reference in New Issue
Block a user