[NI] Minor renaming

Use words 'returnArgument' instead of 'resultArgument' when talking
about values, which can be possibly returned from lambda.

Correct 'addSubsystemForArgument' -> 'addSubsystemFromArgument'
This commit is contained in:
Dmitry Savvinov
2017-11-22 19:21:49 +03:00
parent 30a51af931
commit aaee401240
5 changed files with 16 additions and 19 deletions
@@ -67,7 +67,7 @@ class KotlinResolutionCallbacksImpl(
} }
} }
override fun analyzeAndGetLambdaResultArguments( override fun analyzeAndGetLambdaReturnArguments(
lambdaArgument: LambdaKotlinCallArgument, lambdaArgument: LambdaKotlinCallArgument,
isSuspend: Boolean, isSuspend: Boolean,
receiverType: UnwrappedType?, receiverType: UnwrappedType?,
@@ -37,7 +37,7 @@ interface KotlinResolutionStatelessCallbacks {
// This components hold state (trace). Work with this carefully. // This components hold state (trace). Work with this carefully.
interface KotlinResolutionCallbacks { interface KotlinResolutionCallbacks {
fun analyzeAndGetLambdaResultArguments( fun analyzeAndGetLambdaReturnArguments(
lambdaArgument: LambdaKotlinCallArgument, lambdaArgument: LambdaKotlinCallArgument,
isSuspend: Boolean, isSuspend: Boolean,
receiverType: UnwrappedType?, receiverType: UnwrappedType?,
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.resolve.calls.components package org.jetbrains.kotlin.resolve.calls.components
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
import org.jetbrains.kotlin.resolve.calls.inference.addSubsystemForArgument import org.jetbrains.kotlin.resolve.calls.inference.addSubsystemFromArgument
import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
import org.jetbrains.kotlin.resolve.calls.inference.model.LambdaArgumentConstraintPosition import org.jetbrains.kotlin.resolve.calls.inference.model.LambdaArgumentConstraintPosition
@@ -64,19 +64,19 @@ class PostponedArgumentsAnalyzer(
val parameters = lambda.parameters.map(::substitute) val parameters = lambda.parameters.map(::substitute)
val expectedType = lambda.returnType.takeIf { c.canBeProper(it) }?.let(::substitute) val expectedType = lambda.returnType.takeIf { c.canBeProper(it) }?.let(::substitute)
val resultArguments = resolutionCallbacks.analyzeAndGetLambdaResultArguments(lambda.atom, lambda.isSuspend, receiver, parameters, expectedType) val returnArguments = resolutionCallbacks.analyzeAndGetLambdaReturnArguments(lambda.atom, lambda.isSuspend, receiver, parameters, expectedType)
resultArguments.forEach { c.addSubsystemForArgument(it) } returnArguments.forEach { c.addSubsystemFromArgument(it) }
val subResolvedKtPrimitives = resultArguments.map { val subResolvedKtPrimitives = returnArguments.map {
checkSimpleArgument(c.getBuilder(), it, lambda.returnType.let(::substitute), diagnosticHolder, isReceiver = false) checkSimpleArgument(c.getBuilder(), it, lambda.returnType.let(::substitute), diagnosticHolder, isReceiver = false)
} }
if (resultArguments.isEmpty()) { if (returnArguments.isEmpty()) {
val unitType = lambda.returnType.builtIns.unitType val unitType = lambda.returnType.builtIns.unitType
c.getBuilder().addSubtypeConstraint(lambda.returnType.let(::substitute), unitType, LambdaArgumentConstraintPosition(lambda)) c.getBuilder().addSubtypeConstraint(lambda.returnType.let(::substitute), unitType, LambdaArgumentConstraintPosition(lambda))
} }
lambda.setAnalyzedResults(resultArguments, subResolvedKtPrimitives) lambda.setAnalyzedResults(returnArguments, subResolvedKtPrimitives)
} }
} }
@@ -21,10 +21,7 @@ import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzer
import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintPosition import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintPosition
import org.jetbrains.kotlin.resolve.calls.inference.model.NewTypeVariable import org.jetbrains.kotlin.resolve.calls.inference.model.NewTypeVariable
import org.jetbrains.kotlin.resolve.calls.model.CallableReferenceKotlinCallArgument import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.resolve.calls.model.KotlinCallArgument
import org.jetbrains.kotlin.resolve.calls.model.LHSResult
import org.jetbrains.kotlin.resolve.calls.model.SubKotlinCallArgument
import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.TypeConstructor
import org.jetbrains.kotlin.types.UnwrappedType import org.jetbrains.kotlin.types.UnwrappedType
import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@@ -57,11 +54,11 @@ fun ConstraintSystemBuilder.addSubtypeConstraintIfCompatible(lowerType: Unwrappe
} }
fun PostponedArgumentsAnalyzer.Context.addSubsystemForArgument(argument: KotlinCallArgument?) { fun PostponedArgumentsAnalyzer.Context.addSubsystemFromArgument(argument: KotlinCallArgument?) {
when (argument) { when (argument) {
is SubKotlinCallArgument -> addOtherSystem(argument.callResult.constraintSystem) is SubKotlinCallArgument -> addOtherSystem(argument.callResult.constraintSystem)
is CallableReferenceKotlinCallArgument -> { is CallableReferenceKotlinCallArgument -> {
addSubsystemForArgument(argument.lhsResult.safeAs<LHSResult.Expression>()?.lshCallArgument) addSubsystemFromArgument(argument.lhsResult.safeAs<LHSResult.Expression>()?.lshCallArgument)
} }
} }
} }
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.resolve.calls.components.* import org.jetbrains.kotlin.resolve.calls.components.*
import org.jetbrains.kotlin.resolve.calls.inference.addSubsystemForArgument import org.jetbrains.kotlin.resolve.calls.inference.addSubsystemFromArgument
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintInjector import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintInjector
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl
@@ -54,12 +54,12 @@ class SimpleCandidateFactory(
init { init {
val baseSystem = NewConstraintSystemImpl(callComponents.constraintInjector, callComponents.builtIns) val baseSystem = NewConstraintSystemImpl(callComponents.constraintInjector, callComponents.builtIns)
baseSystem.addSubsystemForArgument(kotlinCall.explicitReceiver) baseSystem.addSubsystemFromArgument(kotlinCall.explicitReceiver)
baseSystem.addSubsystemForArgument(kotlinCall.dispatchReceiverForInvokeExtension) baseSystem.addSubsystemFromArgument(kotlinCall.dispatchReceiverForInvokeExtension)
for (argument in kotlinCall.argumentsInParenthesis) { for (argument in kotlinCall.argumentsInParenthesis) {
baseSystem.addSubsystemForArgument(argument) baseSystem.addSubsystemFromArgument(argument)
} }
baseSystem.addSubsystemForArgument(kotlinCall.externalArgument) baseSystem.addSubsystemFromArgument(kotlinCall.externalArgument)
this.baseSystem = baseSystem.asReadOnlyStorage() this.baseSystem = baseSystem.asReadOnlyStorage()
} }