From dd95439767a1c9e6284684a8e7ce65e9985eb9d3 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 23 Jun 2014 19:12:15 +0400 Subject: [PATCH] Do not update recorded type if it hasn't changed It's important for argument that has a type that shouldn't be updated. Like '(b)' in 'a == (b)', which type is 'Any' (for proper 'equals' resolve). Type for 'b' shouldn't be updated to 'Any' as well. --- .../jetbrains/jet/lang/resolve/calls/CallCompleter.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallCompleter.kt index 205deb5f85b..348e7851dd8 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallCompleter.kt @@ -249,7 +249,7 @@ public class CallCompleter( updatedType = ArgumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context as ResolutionContext<*>, expression) } - updateRecordedTypeForArgument(updatedType, expression, context.trace) + updateRecordedTypeForArgument(updatedType, recordedType, expression, context.trace) // While the expected type is not known, the function literal arguments are not analyzed (to analyze function literal bodies once), // but they should be analyzed when the expected type is known (during the call completion). @@ -292,7 +292,14 @@ public class CallCompleter( return argument?.getCorrespondingCall(bindingContext) } - private fun updateRecordedTypeForArgument(updatedType: JetType?, argumentExpression: JetExpression, trace: BindingTrace) { + private fun updateRecordedTypeForArgument( + updatedType: JetType?, + recordedType: JetType?, + argumentExpression: JetExpression, + trace: BindingTrace + ) { + if (recordedType == updatedType) return + fun deparenthesizeOrGetSelector(expression: JetExpression?): JetExpression? { val deparenthesized = JetPsiUtil.deparenthesizeOnce(expression, /* deparenthesizeBinaryExpressionWithTypeRHS = */ false) if (deparenthesized != expression) return deparenthesized