From c613b991bfd7467f8ba603cf87dfa4c33fd07ad1 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 20 Jun 2012 14:23:02 +0400 Subject: [PATCH] KT-2109 Nullability inference fails in extension function #KT-2109 Fixed --- .../calls/autocasts/DataFlowValueFactory.java | 2 +- .../tests/nullabilityAndAutoCasts/kt2109.jet | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2109.jet 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() +}