diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValueFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValueFactory.java index d774dcb972a..6d2429f42c1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValueFactory.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowValueFactory.java @@ -52,7 +52,7 @@ public class DataFlowValueFactory { @NotNull public DataFlowValue createDataFlowValue(@NotNull ThisReceiverDescriptor receiver) { JetType type = receiver.getType(); - return new DataFlowValue(receiver.getDeclarationDescriptor(), type, true, getImmanentNullability(type)); + return new DataFlowValue(receiver, type, true, getImmanentNullability(type)); } @NotNull diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2109.jet b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2109.jet new file mode 100644 index 00000000000..290fbb84fe4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2109.jet @@ -0,0 +1,20 @@ +//KT-2109 Nullability inference fails in extension function +package kt2109 + +class A { + fun foo() {} +} + +fun A?.bar() { + if (this == null) { + return + } + foo() +} + +fun A.baz() { + if (this == null) { + return + } + foo() +}