diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.java
index 70055e48e39..ef3ab5aefa0 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.java
@@ -151,7 +151,7 @@ public class FunctionDescriptorImpl extends DeclarationDescriptorImpl implements
ReceiverDescriptor substitutedExpectedThis = NO_RECEIVER;
if (expectedThisObject.exists()) {
- JetType substitutedType = substitutor.substitute(expectedThisObject.getType(), Variance.IN_VARIANCE);
+ JetType substitutedType = substitutor.substitute(expectedThisObject.getType(), Variance.INVARIANT);
if (substitutedType == null) {
return null;
}
diff --git a/idea/testData/checker/When.jet b/idea/testData/checker/When.jet
index 53177aea4ec..a7bd2a87103 100644
--- a/idea/testData/checker/When.jet
+++ b/idea/testData/checker/When.jet
@@ -1,3 +1,5 @@
+fun Int.foo() : Boolean = true
+
fun foo() : Int {
val s = ""
val x = 1
@@ -17,7 +19,7 @@ fun foo() : Int {
else => 1
}
return when (x?:null) {
- .equals(1) => 1
+ .foo() => 1
?.equals(1).equals(2) => 1
}
}