KT-1274 fixed tests
This commit is contained in:
@@ -41,6 +41,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
|||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.lang.types.NamespaceType;
|
import org.jetbrains.jet.lang.types.NamespaceType;
|
||||||
|
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||||
import org.jetbrains.jet.lang.types.Variance;
|
import org.jetbrains.jet.lang.types.Variance;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -170,7 +171,8 @@ public final class TipsManager {
|
|||||||
@NotNull final ReceiverDescriptor receiverDescriptor
|
@NotNull final ReceiverDescriptor receiverDescriptor
|
||||||
) {
|
) {
|
||||||
// It's impossible to add extension function for namespace
|
// It's impossible to add extension function for namespace
|
||||||
if (receiverDescriptor.getType() instanceof NamespaceType) {
|
JetType receiverType = receiverDescriptor.getType();
|
||||||
|
if (receiverType instanceof NamespaceType) {
|
||||||
return descriptors;
|
return descriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,11 +191,25 @@ public final class TipsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Checks if receiver declaration could be resolved to call expected receiver.
|
* Checks if receiver declaration could be resolved to call expected receiver.
|
||||||
*/
|
*/
|
||||||
private static boolean checkReceiverResolution (
|
private static boolean checkReceiverResolution (
|
||||||
@NotNull ReceiverDescriptor expectedReceiver,
|
@NotNull ReceiverDescriptor expectedReceiver,
|
||||||
@NotNull CallableDescriptor receiverArgument
|
@NotNull CallableDescriptor receiverArgument
|
||||||
|
) {
|
||||||
|
JetType type = expectedReceiver.getType();
|
||||||
|
if (checkReceiverResolution(expectedReceiver, type, receiverArgument)) return true;
|
||||||
|
if (type.isNullable()) {
|
||||||
|
JetType notNullableType = TypeUtils.makeNotNullable(type);
|
||||||
|
if (checkReceiverResolution(expectedReceiver, notNullableType, receiverArgument)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkReceiverResolution (
|
||||||
|
@NotNull ReceiverDescriptor expectedReceiver,
|
||||||
|
@NotNull JetType receiverType,
|
||||||
|
@NotNull CallableDescriptor receiverArgument
|
||||||
) {
|
) {
|
||||||
ConstraintSystem constraintSystem = new ConstraintSystemImpl(ConstraintResolutionListener.DO_NOTHING);
|
ConstraintSystem constraintSystem = new ConstraintSystemImpl(ConstraintResolutionListener.DO_NOTHING);
|
||||||
for (TypeParameterDescriptor typeParameterDescriptor : receiverArgument.getTypeParameters()) {
|
for (TypeParameterDescriptor typeParameterDescriptor : receiverArgument.getTypeParameters()) {
|
||||||
@@ -203,7 +219,7 @@ public final class TipsManager {
|
|||||||
ReceiverDescriptor receiverParameter = receiverArgument.getReceiverParameter();
|
ReceiverDescriptor receiverParameter = receiverArgument.getReceiverParameter();
|
||||||
if (expectedReceiver.exists() && receiverParameter.exists()) {
|
if (expectedReceiver.exists() && receiverParameter.exists()) {
|
||||||
constraintSystem.addSubtypingConstraint(
|
constraintSystem.addSubtypingConstraint(
|
||||||
RECEIVER.assertSubtyping(expectedReceiver.getType(), receiverParameter.getType()));
|
RECEIVER.assertSubtyping(receiverType, receiverParameter.getType()));
|
||||||
}
|
}
|
||||||
else if (expectedReceiver.exists() || receiverParameter.exists()) {
|
else if (expectedReceiver.exists() || receiverParameter.exists()) {
|
||||||
// Only one of receivers exist
|
// Only one of receivers exist
|
||||||
|
|||||||
@@ -106,10 +106,12 @@ public class TypeUtils {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static JetType makeNullable(@NotNull JetType type) {
|
public static JetType makeNullable(@NotNull JetType type) {
|
||||||
return makeNullableAsSpecified(type, true);
|
return makeNullableAsSpecified(type, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static JetType makeNotNullable(@NotNull JetType type) {
|
public static JetType makeNotNullable(@NotNull JetType type) {
|
||||||
return makeNullableAsSpecified(type, false);
|
return makeNullableAsSpecified(type, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ open class A(x: Int) {
|
|||||||
fun m(x: Int) = 1
|
fun m(x: Int) = 1
|
||||||
|
|
||||||
fun d(x: Int) {
|
fun d(x: Int) {
|
||||||
m(1, false, false)
|
m(<caret>1, false, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
Text: (x: Int), Disabled: false, Strikeout: false, Green: false
|
||||||
|
Text: (x: Int, y: Boolean), Disabled: false, Strikeout: false, Green: false
|
||||||
*/
|
*/
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
class A()
|
||||||
|
|
||||||
|
fun A.index(x: Int) : Int {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
fun A.index(x: Int, y: Int) : Int {
|
||||||
|
return x + y
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
val command : A? = null
|
||||||
|
if (command != null){
|
||||||
|
command.index(<caret>)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Text: (x: Int), Disabled: false, Strikeout: false, Green: false
|
||||||
|
Text: (x: Int, y: Int), Disabled: false, Strikeout: false, Green: false
|
||||||
|
*/
|
||||||
@@ -52,6 +52,10 @@ public class JetFunctionParameterInfoTest extends LightCodeInsightFixtureTestCas
|
|||||||
doTest();
|
doTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testNullableTypeCall() {
|
||||||
|
doTest();
|
||||||
|
}
|
||||||
|
|
||||||
public void testPrintln() {
|
public void testPrintln() {
|
||||||
doTest();
|
doTest();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user