From 1bc68e073d8489879a14332585ff62e971ed398f Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Fri, 23 Jun 2017 04:27:56 +0300 Subject: [PATCH] [NI] Minor. Clarified type for arguments from lambda --- .../calls/tower/KotlinResolutionCallbacksImpl.kt | 2 +- .../kotlin/resolve/calls/tower/NewCallArguments.kt | 10 ++++++---- .../resolve/calls/components/ExternalComponents.kt | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt index fafc4369480..91898d61ce0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinResolutionCallbacksImpl.kt @@ -77,7 +77,7 @@ class KotlinResolutionCallbacksImpl( receiverType: UnwrappedType?, parameters: List, expectedReturnType: UnwrappedType? - ): List { + ): List { val psiCallArgument = lambdaArgument.psiCallArgument val outerCallContext = (psiCallArgument as? LambdaKotlinCallArgumentImpl)?.outerCallContext ?: (psiCallArgument as FunctionExpressionImpl).outerCallContext diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewCallArguments.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewCallArguments.kt index 4b30b66bf0c..72f14da29cc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewCallArguments.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewCallArguments.kt @@ -49,6 +49,8 @@ abstract class PSIKotlinCallArgument : KotlinCallArgument { override fun toString() = valueArgument.getArgumentExpression()?.text?.replace('\n', ' ') ?: valueArgument.toString() } +abstract class SimplePSIKotlinCallArgument : PSIKotlinCallArgument(), SimpleKotlinCallArgument + val KotlinCallArgument.psiCallArgument: PSIKotlinCallArgument get() { assert(this is PSIKotlinCallArgument) { "Incorrect KotlinCallArgument: $this. Java class: ${javaClass.canonicalName}" @@ -67,7 +69,7 @@ class ParseErrorKotlinCallArgument( override val valueArgument: ValueArgument, override val dataFlowInfoAfterThisArgument: DataFlowInfo, builtIns: KotlinBuiltIns -): ExpressionKotlinCallArgument, PSIKotlinCallArgument() { +): ExpressionKotlinCallArgument, SimplePSIKotlinCallArgument() { override val receiver = ReceiverValueWithSmartCastInfo(TransientReceiver(builtIns.nothingType), emptySet(), isStable = true) override val isSafeCall: Boolean get() = false @@ -132,7 +134,7 @@ class SubKotlinCallArgumentImpl( override val dataFlowInfoAfterThisArgument: DataFlowInfo, override val receiver: ReceiverValueWithSmartCastInfo, override val resolvedCall: ResolvedKotlinCall.OnlyResolvedKotlinCall -): PSIKotlinCallArgument(), SubKotlinCallArgument { +): SimplePSIKotlinCallArgument(), SubKotlinCallArgument { override val isSpread: Boolean get() = valueArgument.getSpreadElement() != null override val argumentName: Name? get() = valueArgument.getArgumentName()?.asName override val isSafeCall: Boolean get() = false @@ -143,7 +145,7 @@ class ExpressionKotlinCallArgumentImpl( override val dataFlowInfoBeforeThisArgument: DataFlowInfo, override val dataFlowInfoAfterThisArgument: DataFlowInfo, override val receiver: ReceiverValueWithSmartCastInfo -): PSIKotlinCallArgument(), ExpressionKotlinCallArgument { +): SimplePSIKotlinCallArgument(), ExpressionKotlinCallArgument { override val isSpread: Boolean get() = valueArgument.getSpreadElement() != null override val argumentName: Name? get() = valueArgument.getArgumentName()?.asName override val isSafeCall: Boolean get() = false @@ -185,7 +187,7 @@ internal fun createSimplePSICallArgument( valueArgument: ValueArgument, dataFlowInfoBeforeThisArgument: DataFlowInfo, typeInfoForArgument: KotlinTypeInfo -): PSIKotlinCallArgument? { +): SimplePSIKotlinCallArgument? { val ktExpression = KtPsiUtil.getLastElementDeparenthesized(valueArgument.getArgumentExpression(), statementFilter) ?: return null val onlyResolvedCall = ktExpression.getCall(bindingContext)?.let { diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ExternalComponents.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ExternalComponents.kt index 4f66b073027..50d1c1cebf3 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ExternalComponents.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ExternalComponents.kt @@ -32,7 +32,7 @@ interface KotlinResolutionCallbacks { receiverType: UnwrappedType?, parameters: List, expectedReturnType: UnwrappedType? // null means, that return type is not proper i.e. it depends on some type variables - ): List + ): List // todo this is hack for some client which try to read ResolvedCall from trace before all calls completed fun bindStubResolvedCallForCandidate(candidate: KotlinResolutionCandidate)