From 2337f4b9481e3df14fc38c7c9aa4a41058c69bc0 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Tue, 4 Jun 2013 18:08:13 +0400 Subject: [PATCH] bug fix do not combine receiverInfo with error selectorInfo --- .../calls/autocasts/DataFlowValueFactory.java | 5 ++++- .../tests/smartCasts/combineWithNoSelectorInfo.kt | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt 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 5399c1a0af1..4b26bddd5bb 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 @@ -133,6 +133,9 @@ public class DataFlowValueFactory { @NotNull private static IdentifierInfo combineInfo(@Nullable IdentifierInfo receiverInfo, @NotNull IdentifierInfo selectorInfo) { + if (selectorInfo.id == null) { + return ERROR_IDENTIFIER_INFO; + } if (receiverInfo == null || receiverInfo == ERROR_IDENTIFIER_INFO || receiverInfo.isNamespace) { return selectorInfo; } @@ -182,7 +185,7 @@ public class DataFlowValueFactory { DeclarationDescriptor declarationDescriptor = bindingContext.get(REFERENCE_TARGET, simpleNameExpression); if (declarationDescriptor instanceof VariableDescriptor) { ResolvedCall resolvedCall = bindingContext.get(RESOLVED_CALL, simpleNameExpression); - // todo return assert + // todo uncomment assert // for now it fails for resolving 'invoke' convention, return it after 'invoke' algorithm changes // assert resolvedCall != null : "Cannot create right identifier info if the resolved call is not known yet for " + declarationDescriptor; diff --git a/compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt b/compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt new file mode 100644 index 00000000000..705b772b9d2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/combineWithNoSelectorInfo.kt @@ -0,0 +1,13 @@ +package foo + +fun dispatch(request: Request) { + val url = request.getRequestURI() as String + + if (request.getMethod()?.length != 0) { + } +} + +trait Request { + fun getRequestURI(): String? + fun getMethod(): String? +}