[NI] Report error about unknown parameter type of lambda argument
KT-34335
This commit is contained in:
+4
-2
@@ -81,7 +81,8 @@ class DelegatedPropertyInferenceSession(
|
||||
|
||||
override fun inferPostponedVariables(
|
||||
lambda: ResolvedLambdaAtom,
|
||||
initialStorage: ConstraintStorage
|
||||
initialStorage: ConstraintStorage,
|
||||
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||
): Map<TypeConstructor, UnwrappedType> = emptyMap()
|
||||
|
||||
override fun writeOnlyStubs(callInfo: SingleCallResolutionResult): Boolean = false
|
||||
@@ -101,7 +102,8 @@ object InferenceSessionForExistingCandidates : InferenceSession {
|
||||
override fun currentConstraintSystem(): ConstraintStorage = ConstraintStorage.Empty
|
||||
override fun inferPostponedVariables(
|
||||
lambda: ResolvedLambdaAtom,
|
||||
initialStorage: ConstraintStorage
|
||||
initialStorage: ConstraintStorage,
|
||||
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||
): Map<TypeConstructor, UnwrappedType> = emptyMap()
|
||||
|
||||
override fun writeOnlyStubs(callInfo: SingleCallResolutionResult): Boolean = false
|
||||
|
||||
+14
@@ -182,6 +182,20 @@ class DiagnosticReporterByTrackingStrategy(
|
||||
ResolvedToSamWithVarargDiagnostic::class.java -> {
|
||||
trace.report(TYPE_INFERENCE_CANDIDATE_WITH_SAM_AND_VARARG.on(callArgument.psiCallArgument.valueArgument.asElement()))
|
||||
}
|
||||
|
||||
NotEnoughInformationForLambdaParameter::class.java -> {
|
||||
val unknownParameterTypeDiagnostic = diagnostic as NotEnoughInformationForLambdaParameter
|
||||
val lambdaArgument = unknownParameterTypeDiagnostic.lambdaArgument
|
||||
val parameterIndex = unknownParameterTypeDiagnostic.parameterIndex
|
||||
|
||||
val argumentExpression = KtPsiUtil.deparenthesize(lambdaArgument.psiCallArgument.valueArgument.getArgumentExpression())
|
||||
if (argumentExpression !is KtLambdaExpression) return
|
||||
|
||||
val parameter = argumentExpression.valueParameters.getOrNull(parameterIndex)
|
||||
reportIfNonNull(parameter) {
|
||||
trace.report(CANNOT_INFER_PARAMETER_TYPE.on(it))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -102,7 +102,8 @@ class CoroutineInferenceSession(
|
||||
|
||||
override fun inferPostponedVariables(
|
||||
lambda: ResolvedLambdaAtom,
|
||||
initialStorage: ConstraintStorage
|
||||
initialStorage: ConstraintStorage,
|
||||
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||
): Map<TypeConstructor, UnwrappedType> {
|
||||
val commonSystem = buildCommonSystem(initialStorage)
|
||||
|
||||
@@ -110,7 +111,8 @@ class CoroutineInferenceSession(
|
||||
kotlinConstraintSystemCompleter.completeConstraintSystem(
|
||||
context,
|
||||
builtIns.unitType,
|
||||
partiallyResolvedCallsInfo.map { it.callResolutionResult.resultCallAtom }
|
||||
partiallyResolvedCallsInfo.map { it.callResolutionResult.resultCallAtom },
|
||||
diagnosticsHolder
|
||||
)
|
||||
|
||||
updateCalls(lambda, commonSystem)
|
||||
|
||||
+2
-1
@@ -85,7 +85,8 @@ abstract class ManyCandidatesResolver<D : CallableDescriptor>(
|
||||
constraintSystem.asConstraintSystemCompleterContext(),
|
||||
KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode.FULL,
|
||||
atoms,
|
||||
builtIns.unitType
|
||||
builtIns.unitType,
|
||||
diagnosticHolder
|
||||
) {
|
||||
postponedArgumentsAnalyzer.analyze(
|
||||
constraintSystem.asPostponedArgumentsAnalyzerContext(), resolutionCallbacks, it, diagnosticHolder
|
||||
|
||||
Reference in New Issue
Block a user