FE KT-47939 callable references to functional interface constructors

Allow callable references to Kotlin 'fun interface' constructors.
Prohibit callable references to Java SAM interface constructors.
This commit is contained in:
Dmitry Petrov
2021-11-29 15:10:14 +03:00
committed by TeamCityServer
parent bfb6e73728
commit 1fd0dec5e7
26 changed files with 188 additions and 43 deletions
@@ -4333,4 +4333,10 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirJvmErrors.JAVA_SAM_INTERFACE_CONSTRUCTOR_REFERENCE) { firDiagnostic ->
JavaSamInterfaceConstructorReferenceImpl(
firDiagnostic as KtPsiDiagnostic,
token,
)
}
}
@@ -3016,4 +3016,8 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
override val diagnosticClass get() = SpreadOnSignaturePolymorphicCallWarning::class
}
abstract class JavaSamInterfaceConstructorReference : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = JavaSamInterfaceConstructorReference::class
}
}
@@ -3646,3 +3646,8 @@ internal class SpreadOnSignaturePolymorphicCallWarningImpl(
override val token: ValidityToken,
) : KtFirDiagnostic.SpreadOnSignaturePolymorphicCallWarning(), KtAbstractFirDiagnostic<PsiElement>
internal class JavaSamInterfaceConstructorReferenceImpl(
override val firDiagnostic: KtPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.JavaSamInterfaceConstructorReference(), KtAbstractFirDiagnostic<PsiElement>