[FIR] Extension point for function calls

This extension point allows changing the return type of call
 from a declared type to its subtype.
With an idea that such a plugin needs the ability to
control available (extension) properties for this type.
A set of properties should be decided based on the resolved function,
provided arguments, types, and resolved lambdas.
It is not a goal to enable plugins to affect resolution in any way.
Types are not intended to have any structured capabilities

In other words.
The goal was to come up with a way to enable a limited form
of an "extensible records" mechanism through plugins.
- It should give enough value for a practical use.
(more info in the ticket).
- It should have minimal effect on the compilation process
This appears to be an extension point that solves this problem.

^KT-65859 Fixed
This commit is contained in:
Nikita Klimenko
2024-02-09 21:10:56 +02:00
committed by Space Team
parent 4d04546652
commit c49edfef04
14 changed files with 225 additions and 6 deletions
@@ -499,6 +499,15 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.PLUGIN_AMBIGUOUS_INTERCEPTED_SYMBOL) { firDiagnostic ->
PluginAmbiguousInterceptedSymbolImpl(
firDiagnostic.a.map { string ->
string
},
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.RESOLUTION_TO_CLASSIFIER) { firDiagnostic ->
ResolutionToClassifierImpl(
firSymbolBuilder.classifierBuilder.buildClassLikeSymbol(firDiagnostic.a),
@@ -396,6 +396,11 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
val classSymbol: KtClassLikeSymbol
}
interface PluginAmbiguousInterceptedSymbol : KtFirDiagnostic<PsiElement> {
override val diagnosticClass get() = PluginAmbiguousInterceptedSymbol::class
val names: List<String>
}
interface ResolutionToClassifier : KtFirDiagnostic<PsiElement> {
override val diagnosticClass get() = ResolutionToClassifier::class
val classSymbol: KtClassLikeSymbol
@@ -459,6 +459,12 @@ internal class InnerClassConstructorNoReceiverImpl(
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.InnerClassConstructorNoReceiver
internal class PluginAmbiguousInterceptedSymbolImpl(
override val names: List<String>,
firDiagnostic: KtPsiDiagnostic,
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.PluginAmbiguousInterceptedSymbol
internal class ResolutionToClassifierImpl(
override val classSymbol: KtClassLikeSymbol,
firDiagnostic: KtPsiDiagnostic,