diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java index 84bfdafac4e..820242d007e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java @@ -758,7 +758,7 @@ public class CallResolver { result = OTHER_ERROR; } } - if (safeAccess && (receiverParameter.getType().isNullable() || !receiverArgumentType.isNullable())) { + if (safeAccess && !receiverArgumentType.isNullable()) { context.tracing.unnecessarySafeCall(context.candidateCall.getTrace(), receiverArgumentType); } } diff --git a/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.jet b/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.jet index 02da9a79a31..5d686699a92 100644 --- a/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.jet +++ b/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.jet @@ -66,10 +66,10 @@ import outer.* command.equals(null) command?.equals(null) command.equals1(null) - command?.equals1(null) + command?.equals1(null) val c = Command() c?.equals2(null) if (command == null) 1 - } \ No newline at end of file + } diff --git a/compiler/testData/diagnostics/tests/extensions/kt2317.jet b/compiler/testData/diagnostics/tests/extensions/kt2317.jet new file mode 100644 index 00000000000..6bd8ceac485 --- /dev/null +++ b/compiler/testData/diagnostics/tests/extensions/kt2317.jet @@ -0,0 +1,15 @@ +//KT-2317 Wrong UNNECESSARY_SAFE_CALL + +package kt2317 + +fun Any?.baz() = 1 + +fun foo(l: Long?) = l?.baz() + + +fun Any?.bar(): Unit { } + +fun quux(x: Int?): Unit { + x?.baz() + x?.bar() +} diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/InfixCallNullability.jet b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/InfixCallNullability.jet index 9aaf713e92e..c737813ab55 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/InfixCallNullability.jet +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/InfixCallNullability.jet @@ -32,7 +32,7 @@ fun test(x : Int?, a : A?) { a.times(1) a * 1 a times 1 - a?.times(1) + a?.times(1) 1 in a a contains 1 diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/ReceiverNullability.jet b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/ReceiverNullability.jet index 64e653f486a..611bc9a395f 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/ReceiverNullability.jet +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/ReceiverNullability.jet @@ -12,7 +12,7 @@ fun test(a : A?) { a?.foo() a?.bar() - a?.buzz() // warning + a?.buzz() } fun A.test2() { @@ -40,5 +40,5 @@ fun A?.test3() { this?.foo() this?.bar() - this?.buzz() // warning + this?.buzz() } diff --git a/compiler/testData/diagnostics/tests/regressions/kt557.jet b/compiler/testData/diagnostics/tests/regressions/kt557.jet index 0d1dc9a10e9..4ac9a61049c 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt557.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt557.jet @@ -5,5 +5,5 @@ fun Array.length() : Int { } fun test(array : Array?) { - array?.sure>().length() + array?.sure>().length() } diff --git a/idea/testData/checker/ExtensionFunctions.jet b/idea/testData/checker/ExtensionFunctions.jet index 78561cef3ec..df72388de3d 100644 --- a/idea/testData/checker/ExtensionFunctions.jet +++ b/idea/testData/checker/ExtensionFunctions.jet @@ -61,7 +61,7 @@ fun Int.foo() = this command.equals(null) command?.equals(null) command.equals1(null) - command?.equals1(null) + command?.equals1(null) val c = Command() c?.equals2(null)