don't use data flow info while checking for receiver

receiver with smart cast is checked separately
This commit is contained in:
Svetlana Isakova
2013-12-03 14:26:18 +04:00
parent 46b77f4472
commit ab1d27dd6b
3 changed files with 16 additions and 2 deletions
@@ -891,8 +891,7 @@ public class CandidateResolver {
BindingContext bindingContext = trace.getBindingContext();
boolean safeAccess = isExplicitReceiver && !implicitInvokeCheck && candidateCall.isSafeCall();
AutoCastServiceImpl autoCastService = new AutoCastServiceImpl(context.dataFlowInfo, bindingContext);
if (!safeAccess && !receiverParameter.getType().isNullable() && !autoCastService.isNotNull(receiverArgument)) {
if (!safeAccess && !receiverParameter.getType().isNullable() && receiverArgument.getType().isNullable()) {
context.tracing.unsafeCall(trace, receiverArgumentType, implicitInvokeCheck);
return UNSAFE_CALL_ERROR;
@@ -0,0 +1,10 @@
public class A() {
public val foo: Int? = 1
}
fun Int.bar(i: Int) = i
fun test() {
val p = A()
if (p.foo is Int) <!AUTOCAST_IMPOSSIBLE!>p.foo<!> bar 11
}
@@ -6178,6 +6178,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
doTest("compiler/testData/diagnostics/tests/smartCasts/noUnnecessarySmartCastForReceiver.kt");
}
@TestMetadata("publicVal.kt")
public void testPublicVal() throws Exception {
doTest("compiler/testData/diagnostics/tests/smartCasts/publicVal.kt");
}
@TestMetadata("thisWithLabel.kt")
public void testThisWithLabel() throws Exception {
doTest("compiler/testData/diagnostics/tests/smartCasts/thisWithLabel.kt");