Create From Usage: Do not fail on qualifier receiver when it doesn't have type
This commit is contained in:
+4
-3
@@ -22,6 +22,7 @@ import org.jetbrains.jet.plugin.refactoring.getExtractionContainers
|
||||
import org.jetbrains.jet.lang.psi.JetClassBody
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.getAssignmentByLHS
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
|
||||
object CreateFunctionOrPropertyFromCallActionFactory : JetSingleIntentionActionFactory() {
|
||||
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
|
||||
@@ -55,9 +56,9 @@ object CreateFunctionOrPropertyFromCallActionFactory : JetSingleIntentionActionF
|
||||
|
||||
val receiverType = when (receiver) {
|
||||
ReceiverValue.NO_RECEIVER -> TypeInfo.Empty
|
||||
is Qualifier -> when {
|
||||
receiver.classifier != null -> TypeInfo(receiver.expression, Variance.IN_VARIANCE)
|
||||
else -> return null
|
||||
is Qualifier -> {
|
||||
val qualifierType = context[BindingContext.EXPRESSION_TYPE, receiver.expression] ?: return null
|
||||
TypeInfo(qualifierType, Variance.IN_VARIANCE)
|
||||
}
|
||||
else -> TypeInfo(receiver.getType(), Variance.IN_VARIANCE)
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Create function 'foo' from usage" "false"
|
||||
// ACTION: Replace with infix function call
|
||||
// ACTION: Split property declaration
|
||||
// ERROR: Unresolved reference: foo
|
||||
|
||||
class A<T>(val n: T)
|
||||
|
||||
fun test() {
|
||||
val a: Int = A.<caret>foo(2)
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Create property 'foo' from usage" "false"
|
||||
// ACTION: Split property declaration
|
||||
// ERROR: Unresolved reference: foo
|
||||
|
||||
class A<T>(val n: T)
|
||||
|
||||
fun test() {
|
||||
val a: Int = A.<caret>foo
|
||||
}
|
||||
@@ -760,6 +760,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeFunOnClassNoClassObject.kt")
|
||||
public void testFunOnClassNoClassObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createFunction/call/beforeFunOnClassNoClassObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeFunOnClassObject.kt")
|
||||
public void testFunOnClassObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createFunction/call/beforeFunOnClassObject.kt");
|
||||
@@ -1541,6 +1547,12 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeValOnClassNoClassObject.kt")
|
||||
public void testValOnClassNoClassObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createVariable/property/beforeValOnClassNoClassObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("beforeValOnClassObject.kt")
|
||||
public void testValOnClassObject() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/createFromUsage/createVariable/property/beforeValOnClassObject.kt");
|
||||
|
||||
Reference in New Issue
Block a user