Minor. Extract PSICallResolver::createCallableReferenceKotlinCallArgument

This commit is contained in:
Denis Zharkov
2019-12-25 11:48:10 +03:00
committed by Mikhail Zarechenskiy
parent 840acbac68
commit 534718794c
@@ -383,6 +383,7 @@ class PSICallResolver(
// todo may be for invoke for case variable + invoke we should create separate dynamicScope(by newCall for invoke) // todo may be for invoke for case variable + invoke we should create separate dynamicScope(by newCall for invoke)
override val dynamicScope: MemberScope = override val dynamicScope: MemberScope =
dynamicCallableDescriptors.createDynamicDescriptorScope(context.call, context.scope.ownerDescriptor) dynamicCallableDescriptors.createDynamicDescriptorScope(context.call, context.scope.ownerDescriptor)
// same for location // same for location
override val location: LookupLocation = context.call.createLookupLocation() override val location: LookupLocation = context.call.createLookupLocation()
@@ -690,6 +691,25 @@ class PSICallResolver(
.expandContextForCatchClause(ktExpression) .expandContextForCatchClause(ktExpression)
if (ktExpression is KtCallableReferenceExpression) { if (ktExpression is KtCallableReferenceExpression) {
return createCallableReferenceKotlinCallArgument(
context, ktExpression, startDataFlowInfo, valueArgument, argumentName,
outerCallContext
)
}
// argumentExpression instead of ktExpression is hack -- type info should be stored also for parenthesized expression
val typeInfo = expressionTypingServices.getTypeInfo(argumentExpression, context)
return createSimplePSICallArgument(context, valueArgument, typeInfo) ?: createParseErrorElement()
}
private fun createCallableReferenceKotlinCallArgument(
context: BasicCallResolutionContext,
ktExpression: KtCallableReferenceExpression,
startDataFlowInfo: DataFlowInfo,
valueArgument: ValueArgument,
argumentName: Name?,
outerCallContext: BasicCallResolutionContext
): CallableReferenceKotlinCallArgumentImpl {
checkNoSpread(outerCallContext, valueArgument) checkNoSpread(outerCallContext, valueArgument)
val expressionTypingContext = ExpressionTypingContext.newContext(context) val expressionTypingContext = ExpressionTypingContext.newContext(context)
@@ -731,10 +751,6 @@ class PSICallResolver(
) )
} }
// argumentExpression instead of ktExpression is hack -- type info should be stored also for parenthesized expression
val typeInfo = expressionTypingServices.getTypeInfo(argumentExpression, context)
return createSimplePSICallArgument(context, valueArgument, typeInfo) ?: createParseErrorElement()
}
private fun BasicCallResolutionContext.expandContextForCatchClause(ktExpression: Any): BasicCallResolutionContext { private fun BasicCallResolutionContext.expandContextForCatchClause(ktExpression: Any): BasicCallResolutionContext {
if (ktExpression !is KtExpression) return this if (ktExpression !is KtExpression) return this