Better texts for quickfixes to change return type

This commit is contained in:
Valentin Kipyatkov
2016-09-20 19:15:05 +03:00
parent 8d67a65ed9
commit dab6f7d13d
86 changed files with 145 additions and 115 deletions
@@ -20,10 +20,6 @@ imports.chooser.title=Imports
rename.kotlin.package.class.error=Can't rename Kotlin package facade class
add.semicolon.after.invocation=Add semicolon after invocation of ''{0}''
add.semicolon.family=Add Semicolon
change.function.return.type=Change ''{0}'' function return type to ''{1}''
change.no.name.function.return.type=Change function return type to ''{0}''
remove.function.return.type=Remove explicitly specified return type in ''{0}'' function
remove.no.name.function.return.type=Remove explicitly specified function return type
change.type=Change type from ''{0}'' to ''{1}''
change.type.family=Change type
change.function.signature=Change the signature of function ''{0}''
@@ -24,10 +24,10 @@ import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil
import org.jetbrains.kotlin.idea.project.builtIns
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.callUtil.getParentResolvedCall
@@ -95,7 +95,7 @@ class ChangeFunctionLiteralReturnTypeFix(
val parentFunctionReturnTypeRef = parentFunction.typeReference
val parentFunctionReturnType = context.get(BindingContext.TYPE, parentFunctionReturnTypeRef)
return if (parentFunctionReturnType != null && !KotlinTypeChecker.DEFAULT.isSubtypeOf(eventualFunctionLiteralType, parentFunctionReturnType))
ChangeFunctionReturnTypeFix(parentFunction, eventualFunctionLiteralType)
ChangeFunctionReturnTypeFix.ForCurrent(parentFunction, eventualFunctionLiteralType)
else
null
}
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.idea.quickfix
import com.intellij.codeInsight.intention.HighPriorityAction
import com.intellij.codeInsight.intention.IntentionAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
@@ -44,9 +45,11 @@ import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
import org.jetbrains.kotlin.types.typeUtil.isUnit
import org.jetbrains.kotlin.utils.addToStdlib.check
import java.util.*
class ChangeFunctionReturnTypeFix(element: KtFunction, type: KotlinType) : KotlinQuickFixAction<KtFunction>(element) {
abstract class ChangeFunctionReturnTypeFix(element: KtFunction, type: KotlinType) : KotlinQuickFixAction<KtFunction>(element) {
private val changeFunctionLiteralReturnTypeFix: ChangeFunctionLiteralReturnTypeFix?
private val typeContainsError = ErrorUtils.containsErrorType(type)
@@ -64,30 +67,61 @@ class ChangeFunctionReturnTypeFix(element: KtFunction, type: KotlinType) : Kotli
}
}
open fun functionPresentation(): String? {
val name = element.name
if (name != null) {
val container = element.resolveToDescriptor().containingDeclaration as? ClassDescriptor
val containerName = container?.name?.check { !it.isSpecial }?.asString()
return "function " + (if (containerName != null) "'$containerName.$name'" else "'$name'")
}
else {
return null
}
}
class OnType(element: KtFunction, type: KotlinType) : ChangeFunctionReturnTypeFix(element, type), HighPriorityAction {
override fun functionPresentation() = null
}
class ForCurrent(element: KtFunction, type: KotlinType) : ChangeFunctionReturnTypeFix(element, type), HighPriorityAction {
override fun functionPresentation(): String? {
val presentation = super.functionPresentation() ?: return "current function"
return "current $presentation"
}
}
class ForInvoked(element: KtFunction, type: KotlinType) : ChangeFunctionReturnTypeFix(element, type) {
override fun functionPresentation(): String? {
val presentation = super.functionPresentation() ?: return "invoked function"
return "invoked $presentation"
}
}
class ForOverridden(element: KtFunction, type: KotlinType) : ChangeFunctionReturnTypeFix(element, type) {
override fun functionPresentation(): String? {
val presentation = super.functionPresentation() ?: return null
return "overridden $presentation"
}
}
override fun getText(): String {
if (changeFunctionLiteralReturnTypeFix != null) {
return changeFunctionLiteralReturnTypeFix.text
}
val shortName = element.name
val functionName = if (shortName != null) {
val containingDescriptor = element.resolveToDescriptor().containingDeclaration as? ClassDescriptor
val containerName = containingDescriptor?.name
if (containerName != null && !containerName.isSpecial) "${containerName.asString()}.$shortName" else shortName
}
else null
val functionPresentation = functionPresentation()
if (isUnitType && element.hasBlockBody()) {
return if (functionName == null)
KotlinBundle.message("remove.no.name.function.return.type")
return if (functionPresentation == null)
"Remove explicitly specified return type"
else
KotlinBundle.message("remove.function.return.type", functionName)
"Remove explicitly specified return type of $functionPresentation"
}
return if (functionName == null)
KotlinBundle.message("change.no.name.function.return.type", typePresentation)
return if (functionPresentation == null)
"Change return type to '$typePresentation'"
else
KotlinBundle.message("change.function.return.type", functionName, typePresentation)
"Change return type of $functionPresentation to '$typePresentation'"
}
override fun getFamilyName() = KotlinBundle.message("change.type.family")
@@ -121,7 +155,7 @@ class ChangeFunctionReturnTypeFix(element: KtFunction, type: KotlinType) : Kotli
val resolvedCall = context.get(BindingContext.COMPONENT_RESOLVED_CALL, entry) ?: return null
val componentFunction = DescriptorToSourceUtils.descriptorToDeclaration(resolvedCall.candidateDescriptor) as KtFunction? ?: return null
val expectedType = context[BindingContext.TYPE, entry.typeReference!!] ?: return null
return ChangeFunctionReturnTypeFix(componentFunction, expectedType)
return ChangeFunctionReturnTypeFix.ForInvoked(componentFunction, expectedType)
}
}
@@ -133,7 +167,7 @@ class ChangeFunctionReturnTypeFix(element: KtFunction, type: KotlinType) : Kotli
val resolvedCall = context[BindingContext.LOOP_RANGE_HAS_NEXT_RESOLVED_CALL, expression] ?: return null
val hasNextDescriptor = resolvedCall.candidateDescriptor
val hasNextFunction = DescriptorToSourceUtils.descriptorToDeclaration(hasNextDescriptor) as KtFunction? ?: return null
return ChangeFunctionReturnTypeFix(hasNextFunction, hasNextDescriptor.builtIns.booleanType)
return ChangeFunctionReturnTypeFix.ForInvoked(hasNextFunction, hasNextDescriptor.builtIns.booleanType)
}
}
@@ -144,7 +178,7 @@ class ChangeFunctionReturnTypeFix(element: KtFunction, type: KotlinType) : Kotli
val resolvedCall = expression.getResolvedCall(context) ?: return null
val compareToDescriptor = resolvedCall.candidateDescriptor
val compareTo = DescriptorToSourceUtils.descriptorToDeclaration(compareToDescriptor) as? KtFunction ?: return null
return ChangeFunctionReturnTypeFix(compareTo, compareToDescriptor.builtIns.intType)
return ChangeFunctionReturnTypeFix.ForInvoked(compareTo, compareToDescriptor.builtIns.intType)
}
}
@@ -158,7 +192,7 @@ class ChangeFunctionReturnTypeFix(element: KtFunction, type: KotlinType) : Kotli
val matchingReturnType = QuickFixUtil.findLowerBoundOfOverriddenCallablesReturnTypes(descriptor)
if (matchingReturnType != null) {
actions.add(ChangeFunctionReturnTypeFix(function, matchingReturnType))
actions.add(ChangeFunctionReturnTypeFix.OnType(function, matchingReturnType))
}
val functionType = descriptor.returnType ?: return actions
@@ -174,7 +208,7 @@ class ChangeFunctionReturnTypeFix(element: KtFunction, type: KotlinType) : Kotli
if (overriddenMismatchingFunctions.size == 1) {
val overriddenFunction = DescriptorToSourceUtils.descriptorToDeclaration(overriddenMismatchingFunctions[0])
if (overriddenFunction is KtFunction) {
actions.add(ChangeFunctionReturnTypeFix(overriddenFunction, functionType))
actions.add(ChangeFunctionReturnTypeFix.ForOverridden(overriddenFunction, functionType))
}
}
@@ -185,14 +219,14 @@ class ChangeFunctionReturnTypeFix(element: KtFunction, type: KotlinType) : Kotli
object ChangingReturnTypeToUnitFactory : KotlinSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
val function = QuickFixUtil.getParentElementOfType(diagnostic, KtFunction::class.java) ?: return null
return ChangeFunctionReturnTypeFix(function, function.builtIns.unitType)
return ChangeFunctionReturnTypeFix.ForCurrent(function, function.builtIns.unitType)
}
}
object ChangingReturnTypeToNothingFactory : KotlinSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
val function = QuickFixUtil.getParentElementOfType(diagnostic, KtFunction::class.java) ?: return null
return ChangeFunctionReturnTypeFix(function, function.builtIns.nothingType)
return ChangeFunctionReturnTypeFix.ForCurrent(function, function.builtIns.nothingType)
}
}
@@ -141,7 +141,7 @@ class QuickFixFactoryForTypeMismatchError : KotlinIntentionActionsFactory() {
if (function is KtFunction && QuickFixUtil.canFunctionOrGetterReturnExpression(function, diagnosticElement)) {
val scope = function.getResolutionScope(context, function.getResolutionFacade())
val typeToInsert = expressionType.approximateWithResolvableType(scope, false)
actions.add(ChangeFunctionReturnTypeFix(function, typeToInsert))
actions.add(ChangeFunctionReturnTypeFix.ForCurrent(function, typeToInsert))
}
// Fixing overloaded operators:
@@ -150,7 +150,7 @@ class QuickFixFactoryForTypeMismatchError : KotlinIntentionActionsFactory() {
if (resolvedCall != null) {
val declaration = getFunctionDeclaration(resolvedCall)
if (declaration != null) {
actions.add(ChangeFunctionReturnTypeFix(declaration, expectedType))
actions.add(ChangeFunctionReturnTypeFix.ForInvoked(declaration, expectedType))
}
}
}
@@ -161,7 +161,7 @@ class QuickFixFactoryForTypeMismatchError : KotlinIntentionActionsFactory() {
if (resolvedCall != null) {
val declaration = getFunctionDeclaration(resolvedCall)
if (declaration != null) {
actions.add(ChangeFunctionReturnTypeFix(declaration, expectedType))
actions.add(ChangeFunctionReturnTypeFix.ForInvoked(declaration, expectedType))
}
}
}
@@ -1,4 +1,4 @@
// "Change 'A.foo' function return type to 'Long'" "true"
// "Change return type of overridden function 'A.foo' to 'Long'" "true"
interface A {
fun foo(): Int
}
@@ -1,4 +1,4 @@
// "Change 'A.foo' function return type to 'Long'" "true"
// "Change return type of overridden function 'A.foo' to 'Long'" "true"
interface A {
fun foo(): Long
}
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Boolean'" "true"
// "Change return type to 'Boolean'" "true"
interface A {
fun foo(): Boolean
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Boolean'" "true"
// "Change return type to 'Boolean'" "true"
interface A {
fun foo(): Boolean
@@ -1,4 +1,4 @@
// "Change 'B.foo' function return type to 'T'" "true"
// "Change return type to 'T'" "true"
open class S {}
open class T : S() {}
@@ -1,4 +1,4 @@
// "Change 'B.foo' function return type to 'T'" "true"
// "Change return type to 'T'" "true"
open class S {}
open class T : S() {}
@@ -1,4 +1,4 @@
// "Change 'B.foo' function return type to 'Int'" "true"
// "Change return type to 'Int'" "true"
abstract class A {
abstract fun foo() : Int;
}
@@ -1,4 +1,4 @@
// "Change 'B.foo' function return type to 'Int'" "true"
// "Change return type to 'Int'" "true"
abstract class A {
abstract fun foo() : Int;
}
@@ -1,4 +1,4 @@
// "Change 'B.foo' function return type to 'Int'" "true"
// "Change return type to 'Int'" "true"
abstract class A {
abstract fun foo() : Int;
}
@@ -1,4 +1,4 @@
// "Change 'B.foo' function return type to 'Int'" "true"
// "Change return type to 'Int'" "true"
abstract class A {
abstract fun foo() : Int;
}
@@ -1,4 +1,4 @@
// "Remove explicitly specified return type in 'A.remove' function" "true"
// "Remove explicitly specified return type" "true"
abstract class A : java.util.Iterator<Int> {
public abstract override fun remove() : Int<caret>;
}
@@ -1,4 +1,4 @@
// "Remove explicitly specified return type in 'A.remove' function" "true"
// "Remove explicitly specified return type" "true"
abstract class A : java.util.Iterator<Int> {
public abstract override fun remove();
}
@@ -1,4 +1,4 @@
// "Change 'bar' function return type to 'A'" "true"
// "Change return type of current function 'bar' to 'A'" "true"
fun foo() {
open class A
@@ -1,4 +1,4 @@
// "Change 'bar' function return type to 'A'" "true"
// "Change return type of current function 'bar' to 'A'" "true"
fun foo() {
open class A
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'T'" "true"
// "Change return type of current function 'foo' to 'T'" "true"
interface T
fun foo() {
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'T'" "true"
// "Change return type of current function 'foo' to 'T'" "true"
interface T
fun foo(): T {
+1 -1
View File
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Any'" "true"
// "Change return type of current function 'foo' to 'Any'" "true"
fun foo() {
class A
+1 -1
View File
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Any'" "true"
// "Change return type of current function 'foo' to 'Any'" "true"
fun foo(): Any {
class A
@@ -1,3 +1,3 @@
// "Change 'bar' function return type to 'String'" "true"
// "Change return type of invoked function 'bar' to 'String'" "true"
fun bar(): Any = ""
fun foo(): String = bar(<caret>)
@@ -1,3 +1,3 @@
// "Change 'bar' function return type to 'String'" "true"
// "Change return type of invoked function 'bar' to 'String'" "true"
fun bar(): String = ""
fun foo(): String = bar(<caret>)
@@ -1,4 +1,4 @@
// "Change 'bar' function return type to 'HashSet<Int>'" "true"
// "Change return type of invoked function 'bar' to 'HashSet<Int>'" "true"
fun bar(): Any = java.util.LinkedHashSet<Int>()
fun foo(): java.util.HashSet<Int> = bar(<caret>)
@@ -1,6 +1,6 @@
import java.util.HashSet
// "Change 'bar' function return type to 'HashSet<Int>'" "true"
// "Change return type of invoked function 'bar' to 'HashSet<Int>'" "true"
fun bar(): HashSet<Int> = java.util.LinkedHashSet<Int>()
fun foo(): java.util.HashSet<Int> = bar()
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Int'" "true"
// "Change return type of current function 'foo' to 'Int'" "true"
package foo.bar
fun test() {
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Int'" "true"
// "Change return type of current function 'foo' to 'Int'" "true"
package foo.bar
fun test() {
@@ -1,4 +1,4 @@
// "Change 'Companion.foo' function return type to 'Int'" "true"
// "Change return type of current function 'Companion.foo' to 'Int'" "true"
package foo.bar
class A {
@@ -1,4 +1,4 @@
// "Change 'Companion.foo' function return type to 'Int'" "true"
// "Change return type of current function 'Companion.foo' to 'Int'" "true"
package foo.bar
class A {
@@ -1,4 +1,4 @@
// "Change 'A.foo' function return type to 'Int'" "true"
// "Change return type of current function 'A.foo' to 'Int'" "true"
package foo.bar
fun test() {
@@ -1,4 +1,4 @@
// "Change 'A.foo' function return type to 'Int'" "true"
// "Change return type of current function 'A.foo' to 'Int'" "true"
package foo.bar
fun test() {
@@ -1,4 +1,4 @@
// "Change 'B.foo' function return type to 'Int'" "true"
// "Change return type of current function 'B.foo' to 'Int'" "true"
package foo.bar
class A {
@@ -1,4 +1,4 @@
// "Change 'B.foo' function return type to 'Int'" "true"
// "Change return type of current function 'B.foo' to 'Int'" "true"
package foo.bar
class A {
@@ -1,4 +1,4 @@
// "Change 'A.foo' function return type to 'Int'" "true"
// "Change return type of current function 'A.foo' to 'Int'" "true"
package foo.bar
class A {
@@ -1,4 +1,4 @@
// "Change 'A.foo' function return type to 'Int'" "true"
// "Change return type of current function 'A.foo' to 'Int'" "true"
package foo.bar
class A {
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Int?'" "true"
// "Change return type of current function 'foo' to 'Int?'" "true"
fun foo(): String {
val n: Int? = 1
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Int?'" "true"
// "Change return type of current function 'foo' to 'Int?'" "true"
fun foo(): Int? {
val n: Int? = 1
@@ -1,4 +1,4 @@
// "Remove explicitly specified function return type" "true"
// "Remove explicitly specified return type of current function" "true"
// ERROR: Function declaration must have a name
fun (): Int {
return<caret>
@@ -1,4 +1,4 @@
// "Remove explicitly specified function return type" "true"
// "Remove explicitly specified return type of current function" "true"
// ERROR: Function declaration must have a name
fun () {
return<caret>
@@ -1,4 +1,4 @@
// "Change 'A.hasNext' function return type to 'Boolean'" "true"
// "Change return type of invoked function 'A.hasNext' to 'Boolean'" "true"
abstract class A {
abstract operator fun hasNext
abstract operator fun next(): Int
@@ -1,4 +1,4 @@
// "Change 'A.hasNext' function return type to 'Boolean'" "true"
// "Change return type of invoked function 'A.hasNext' to 'Boolean'" "true"
abstract class A {
abstract operator fun hasNext: Boolean
abstract operator fun next(): Int
@@ -1,4 +1,4 @@
// "Change 'A.compareTo' function return type to 'Int'" "true"
// "Change return type of invoked function 'A.compareTo' to 'Int'" "true"
interface A {
operator fun compareTo(other: Any): String
}
@@ -1,4 +1,4 @@
// "Change 'A.compareTo' function return type to 'Int'" "true"
// "Change return type of invoked function 'A.compareTo' to 'Int'" "true"
interface A {
operator fun compareTo(other: Any): Int
}
@@ -1,4 +1,4 @@
// "Change 'A.component1' function return type to 'Int'" "true"
// "Change return type of invoked function 'A.component1' to 'Int'" "true"
abstract class A {
abstract operator fun component1()
abstract operator fun component2(): Int
@@ -1,4 +1,4 @@
// "Change 'A.component1' function return type to 'Int'" "true"
// "Change return type of invoked function 'A.component1' to 'Int'" "true"
abstract class A {
abstract operator fun component1(): Int
abstract operator fun component2(): Int
@@ -1,4 +1,4 @@
// "Change 'A.component2' function return type to 'Int'" "true"
// "Change return type of invoked function 'A.component2' to 'Int'" "true"
abstract class A {
abstract operator fun component1(): Int
abstract operator fun component2(): String
@@ -1,4 +1,4 @@
// "Change 'A.component2' function return type to 'Int'" "true"
// "Change return type of invoked function 'A.component2' to 'Int'" "true"
abstract class A {
abstract operator fun component1(): Int
abstract operator fun component2(): Int
@@ -1,4 +1,4 @@
// "Remove explicitly specified return type in 'A.component2' function" "true"
// "Remove explicitly specified return type of invoked function 'A.component2'" "true"
abstract class A {
abstract operator fun component1(): Int
abstract operator fun component2(): Int
@@ -1,4 +1,4 @@
// "Remove explicitly specified return type in 'A.component2' function" "true"
// "Remove explicitly specified return type of invoked function 'A.component2'" "true"
abstract class A {
abstract operator fun component1(): Int
abstract operator fun component2()
@@ -1,4 +1,4 @@
// "Change 'A.component2' function return type to 'Unit'" "true"
// "Change return type of invoked function 'A.component2' to 'Unit'" "true"
// ERROR: The integer literal does not conform to the expected type Unit
abstract class A {
abstract operator fun component1(): Int
@@ -1,4 +1,4 @@
// "Change 'A.component2' function return type to 'Unit'" "true"
// "Change return type of invoked function 'A.component2' to 'Unit'" "true"
// ERROR: The integer literal does not conform to the expected type Unit
abstract class A {
abstract operator fun component1(): Int
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Int'" "true"
// "Change return type of current function 'foo' to 'Int'" "true"
fun foo(): String {
return <caret>1
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Int'" "true"
// "Change return type of current function 'foo' to 'Int'" "true"
fun foo(): Int {
return <caret>1
@@ -1,4 +1,4 @@
// "Change 'A.not' function return type to 'A'" "true"
// "Change return type of invoked function 'A.not' to 'A'" "true"
interface A {
operator fun not(): String
operator fun times(a: A): A
@@ -1,4 +1,4 @@
// "Change 'A.not' function return type to 'A'" "true"
// "Change return type of invoked function 'A.not' to 'A'" "true"
interface A {
operator fun not(): A
operator fun times(a: A): A
@@ -1,4 +1,4 @@
// "Change 'A.plus' function return type to '() -> Int'" "true"
// "Change return type of invoked function 'A.plus' to '() -> Int'" "true"
interface A {
operator fun plus(a: A): String
}
@@ -1,4 +1,4 @@
// "Change 'A.plus' function return type to '() -> Int'" "true"
// "Change return type of invoked function 'A.plus' to '() -> Int'" "true"
interface A {
operator fun plus(a: A): () -> Int
}
@@ -1,4 +1,4 @@
// "Change 'A.hasNext' function return type to 'Boolean'" "true"
// "Change return type of invoked function 'A.hasNext' to 'Boolean'" "true"
abstract class A {
abstract operator fun hasNext(): Int
abstract operator fun next(): Int
@@ -1,4 +1,4 @@
// "Change 'A.hasNext' function return type to 'Boolean'" "true"
// "Change return type of invoked function 'A.hasNext' to 'Boolean'" "true"
abstract class A {
abstract operator fun hasNext(): Boolean
abstract operator fun next(): Int
+1 -1
View File
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'U'" "true"
// "Change return type of current function 'foo' to 'U'" "true"
interface T
interface U
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'U'" "true"
// "Change return type of current function 'foo' to 'U'" "true"
interface T
interface U
+1 -1
View File
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'T'" "true"
// "Change return type of current function 'foo' to 'T'" "true"
interface T
fun foo() {
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'T'" "true"
// "Change return type of current function 'foo' to 'T'" "true"
interface T
fun foo(): T {
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'String?'" "true"
// "Change return type of current function 'foo' to 'String?'" "true"
fun foo(): String {
return <caret>null
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'String?'" "true"
// "Change return type of current function 'foo' to 'String?'" "true"
fun foo(): String? {
return null
@@ -1,3 +1,3 @@
// "Remove explicitly specified return type in 'foo' function" "true"
// "Remove explicitly specified return type of current function 'foo'" "true"
fun foo(): Int {
<caret>}
@@ -1,3 +1,3 @@
// "Remove explicitly specified return type in 'foo' function" "true"
// "Remove explicitly specified return type of current function 'foo'" "true"
fun foo() {
<caret>}
+1 -1
View File
@@ -1,4 +1,4 @@
// "Remove explicitly specified return type in 'foo' function" "true"
// "Remove explicitly specified return type of current function 'foo'" "true"
fun foo(): Int {
return<caret>
}
@@ -1,4 +1,4 @@
// "Remove explicitly specified return type in 'foo' function" "true"
// "Remove explicitly specified return type of current function 'foo'" "true"
fun foo() {
return<caret>
}
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to '(Long) -> Int'" "true"
// "Change return type of current function 'foo' to '(Long) -> Int'" "true"
fun foo(x: Any): Int {
return {x: Long -> 42}<caret>
}
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to '(Long) -> Int'" "true"
// "Change return type of current function 'foo' to '(Long) -> Int'" "true"
fun foo(x: Any): (Long) -> Int {
return {x: Long -> 42}<caret>
}
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to '() -> Any'" "true"
// "Change return type of current function 'foo' to '() -> Any'" "true"
fun foo(x: Any): () -> Int {
return {x<caret>}
}
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to '() -> Any'" "true"
// "Change return type of current function 'foo' to '() -> Any'" "true"
fun foo(x: Any): () -> Any {
return {x<caret>}
}
@@ -1,5 +1,5 @@
// "Change 'AA.f' function return type to 'Boolean'" "false"
// ACTION: Change 'AAA.g' function return type to 'Int'
// "Change return type of invoked function 'AA.f' to 'Boolean'" "false"
// ACTION: Change return type of current function 'AAA.g' to 'Int'
// ACTION: Convert to expression body
// ERROR: Type mismatch: inferred type is Int but Boolean was expected
interface A {
@@ -1,5 +1,5 @@
// "Change 'AA.contains' function return type to 'Int'" "false"
// ACTION: Change 'AAA.g' function return type to 'Boolean'
// "Change return type of invoked function 'AA.contains' to 'Int'" "false"
// ACTION: Change return type of current function 'AAA.g' to 'Boolean'
// ACTION: Convert to expression body
// ACTION: Replace overloaded operator with function call
// ERROR: Type mismatch: inferred type is Boolean but Int was expected
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Int'" "true"
// "Change return type of current function 'foo' to 'Int'" "true"
fun foo(n: Int): Boolean {
n.let {
return <caret>1
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Int'" "true"
// "Change return type of current function 'foo' to 'Int'" "true"
fun foo(n: Int): Int {
n.let {
return 1
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Int'" "true"
// "Change return type of current function 'foo' to 'Int'" "true"
fun foo(n: Int): Boolean {
n.let {
return@foo <caret>1
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'Int'" "true"
// "Change return type of current function 'foo' to 'Int'" "true"
fun foo(n: Int): Int {
n.let {
return@foo 1
@@ -1,4 +1,4 @@
// "Change 'boo' function return type to 'String'" "true"
// "Change return type of current function 'boo' to 'String'" "true"
fun boo(): Int {
return ((if (true) {
val a = ""
@@ -1,4 +1,4 @@
// "Change 'boo' function return type to 'String'" "true"
// "Change return type of current function 'boo' to 'String'" "true"
fun boo(): String {
return ((if (true) {
val a = ""
@@ -1,2 +1,2 @@
// "Change 'foo' function return type to 'String'" "true"
// "Change return type of current function 'foo' to 'String'" "true"
fun foo(): Int = <caret>""
@@ -1,2 +1,2 @@
// "Change 'foo' function return type to 'String'" "true"
fun foo(): String = <caret>""
// "Change return type of current function 'foo' to 'String'" "true"
fun foo(): String = ""
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'String'" "true"
// "Change return type of current function 'foo' to 'String'" "true"
fun foo() {
return ""<caret>
}
@@ -1,4 +1,4 @@
// "Change 'foo' function return type to 'String'" "true"
// "Change return type of current function 'foo' to 'String'" "true"
fun foo(): String {
return ""<caret>
}