FIR: allow fun T.() = ... as an instance of (T) -> ...

It was already done by the previous commit by mistake, but it broke if
there are other value parameters because the type of the first parameter
would be inferred to be same as the type of the receiver.
This commit is contained in:
pyos
2021-02-02 18:56:49 +01:00
committed by TeamCityServer
parent 0a25550fc2
commit 474d1d48f7
9 changed files with 37 additions and 16 deletions
@@ -1338,6 +1338,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.CANNOT_INFER_PARAMETER_TYPE) { firDiagnostic ->
CannotInferParameterTypeImpl(
firDiagnostic as FirPsiDiagnostic<*>,
token,
)
}
add(FirErrors.FUN_INTERFACE_CONSTRUCTOR_REFERENCE) { firDiagnostic ->
FunInterfaceConstructorReferenceImpl(
firDiagnostic as FirPsiDiagnostic<*>,
@@ -949,6 +949,10 @@ sealed class KtFirDiagnostic<PSI: PsiElement> : KtDiagnosticWithPsi<PSI> {
override val diagnosticClass get() = ValueParameterWithNoTypeAnnotation::class
}
abstract class CannotInferParameterType : KtFirDiagnostic<KtParameter>() {
override val diagnosticClass get() = CannotInferParameterType::class
}
abstract class FunInterfaceConstructorReference : KtFirDiagnostic<KtExpression>() {
override val diagnosticClass get() = FunInterfaceConstructorReference::class
}
@@ -1529,6 +1529,13 @@ internal class ValueParameterWithNoTypeAnnotationImpl(
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
}
internal class CannotInferParameterTypeImpl(
firDiagnostic: FirPsiDiagnostic<*>,
override val token: ValidityToken,
) : KtFirDiagnostic.CannotInferParameterType(), KtAbstractFirDiagnostic<KtParameter> {
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
}
internal class FunInterfaceConstructorReferenceImpl(
firDiagnostic: FirPsiDiagnostic<*>,
override val token: ValidityToken,