Convert to expression body: fixed type selection for public override
This commit is contained in:
@@ -26,7 +26,6 @@ import org.jetbrains.jet.lang.psi.*
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||
import org.jetbrains.jet.lexer.JetTokens
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.siblings
|
||||
import org.jetbrains.jet.plugin.caches.resolve.getLazyResolveSession
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorWithVisibility
|
||||
|
||||
@@ -63,6 +62,7 @@ public class ConvertToExpressionBodyAction : PsiElementBaseIntentionAction() {
|
||||
}
|
||||
|
||||
private fun canOmitType(declaration: JetCallableDeclaration): Boolean {
|
||||
if (declaration.getModifierList()?.hasModifier(JetTokens.OVERRIDE_KEYWORD) ?: false) return true
|
||||
val descriptor = declaration.getLazyResolveSession().resolveToDescriptor(declaration)
|
||||
return !((descriptor as? DeclarationDescriptorWithVisibility)?.getVisibility()?.isPublicAPI() ?: false)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
open class A {
|
||||
public open fun foo(): String = ""
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
public override fun <caret>foo(): String {
|
||||
return "abc"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
open class A {
|
||||
public open fun foo(): String = ""
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
public override fun foo()<selection>: String</selection> = "abc"
|
||||
}
|
||||
@@ -3138,6 +3138,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("overridePublicFun.kt")
|
||||
public void testOverridePublicFun() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/convertToExpressionBody/overridePublicFun.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("protectedFunNoSelection.kt")
|
||||
public void testProtectedFunNoSelection() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/convertToExpressionBody/protectedFunNoSelection.kt");
|
||||
|
||||
Reference in New Issue
Block a user