[NI] Resolve collection literals arguments as postponed ones

This commit is contained in:
Mikhail Zarechenskiy
2017-06-07 16:17:29 +03:00
parent c0c94910e2
commit bc2a8555a3
12 changed files with 78 additions and 17 deletions
@@ -194,4 +194,16 @@ class KotlinResolutionCallbacksImpl(
doubleColonExpressionResolver.checkReferenceIsToAllowedMember(callableCandidate.candidate, topLevelCallContext.trace, callableReferenceExpression)
}
override fun completeCollectionLiteralCalls(collectionLiteralArgument: ResolvedCollectionLiteralArgument) {
val psiCallArgument = collectionLiteralArgument.argument.psiCallArgument as CollectionLiteralKotlinCallArgumentImpl
val context = psiCallArgument.outerCallContext
val actualContext = context
.replaceBindingTrace(trace)
.replaceExpectedType(collectionLiteralArgument.expectedType)
.replaceContextDependency(ContextDependency.INDEPENDENT)
expressionTypingServices.getTypeInfo(psiCallArgument.collectionLiteralExpression, actualContext)
}
}
@@ -115,6 +115,17 @@ class CallableReferenceKotlinCallArgumentImpl(
override val rhsName: Name
) : CallableReferenceKotlinCallArgument, PSIKotlinCallArgument()
class CollectionLiteralKotlinCallArgumentImpl(
override val valueArgument: ValueArgument,
override val argumentName: Name?,
override val dataFlowInfoBeforeThisArgument: DataFlowInfo,
override val dataFlowInfoAfterThisArgument: DataFlowInfo,
val collectionLiteralExpression: KtCollectionLiteralExpression,
val outerCallContext: BasicCallResolutionContext
) : CollectionLiteralKotlinCallArgument, PSIKotlinCallArgument() {
override val isSpread: Boolean get() = valueArgument.getSpreadElement() != null
}
class SubKotlinCallArgumentImpl(
override val valueArgument: ValueArgument,
override val dataFlowInfoBeforeThisArgument: DataFlowInfo,
@@ -510,6 +510,11 @@ class PSICallResolver(
return lambdaArgument
}
if (ktExpression is KtCollectionLiteralExpression) {
return CollectionLiteralKotlinCallArgumentImpl(
valueArgument, argumentName, startDataFlowInfo, startDataFlowInfo, ktExpression, outerCallContext)
}
val context = outerCallContext.replaceContextDependency(ContextDependency.DEPENDENT)
.replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE).replaceDataFlowInfo(startDataFlowInfo)