ParameterName annotation on type argument used to hold parameter name

This commit is contained in:
Valentin Kipyatkov
2016-09-14 19:37:44 +03:00
parent 3bd39df587
commit 59269ef1ae
37 changed files with 158 additions and 140 deletions
@@ -129,7 +129,7 @@ class FindImplicitNothingAction : AnAction() {
private fun KotlinType.isNothingOrNothingFunctionType(): Boolean {
return KotlinBuiltIns.isNothing(this) ||
(isFunctionType && getReturnTypeFromFunctionType(this).isNothingOrNothingFunctionType())
(isFunctionType && this.getReturnTypeFromFunctionType().isNothingOrNothingFunctionType())
}
override fun update(e: AnActionEvent) {
@@ -69,7 +69,7 @@ class ConvertLambdaToReferenceIntention : SelfTargetingOffsetIndependentIntentio
// For lambda parameter with receiver, conversion is not allowed
if (lambdaParameterType.isExtensionFunctionType) return false
// Special Unit case (non-Unit returning lambda is accepted here, but non-Unit returning reference is not)
lambdaMustReturnUnit = getReturnTypeFromFunctionType(lambdaParameterType).isUnit()
lambdaMustReturnUnit = lambdaParameterType.getReturnTypeFromFunctionType().isUnit()
}
}
val context = statement.analyze()
@@ -52,7 +52,7 @@ class ConvertExtensionToFunctionTypeFix(element: KtTypeReference, type: KotlinTy
append('(')
arguments.dropLast(1).map { renderer.renderType(it.type) }.joinTo(this@buildString, ", ")
append(") -> ")
append(renderer.renderType(getReturnTypeFromFunctionType(this@renderType)))
append(renderer.renderType(this@renderType.getReturnTypeFromFunctionType()))
}
companion object Factory : KotlinIntentionActionsFactory() {
@@ -47,18 +47,18 @@ object CreateFunctionFromCallableReferenceActionFactory : CreateCallableMemberFr
.guessTypes(context, resolutionFacade.moduleDescriptor)
.filter(KotlinType::isFunctionType)
.mapNotNull {
val expectedReceiverType = getReceiverTypeFromFunctionType(it)
val expectedReceiverType = it.getReceiverTypeFromFunctionType()
val receiverExpression = element.receiverExpression
val qualifierType = (context.get(BindingContext.DOUBLE_COLON_LHS, receiverExpression) as? DoubleColonLHS.Type)?.type
val receiverTypeInfo = qualifierType?.let { TypeInfo(it, Variance.IN_VARIANCE) } ?: TypeInfo.Empty
val returnTypeInfo = TypeInfo(getReturnTypeFromFunctionType(it), Variance.OUT_VARIANCE)
val returnTypeInfo = TypeInfo(it.getReturnTypeFromFunctionType(), Variance.OUT_VARIANCE)
val containers = element.getExtractionContainers(includeAll = true).ifEmpty { return@mapNotNull null }
val parameterInfos = SmartList<ParameterInfo>().apply {
if (receiverExpression == null && expectedReceiverType != null) {
add(ParameterInfo(TypeInfo(expectedReceiverType, Variance.IN_VARIANCE)))
}
getValueParameterTypesFromFunctionType(it)
it.getValueParameterTypesFromFunctionType()
.let {
if (receiverExpression != null && expectedReceiverType == null && it.isNotEmpty())
it.subList(1, it.size)