K2: report only warning on lambda parameters with missing dependencies
During the fix of KT-62525, we've forbidden to use lambda parameters with inaccessible types at all. After it, some impact was noticed, so we decided to forbid them only in case it's necessary (the case when associated types have type arguments, see KT-62525 description), and to deprecate them in other cases. #KT-64266 Fixed
This commit is contained in:
committed by
Space Team
parent
44aa2d86d3
commit
c322644860
+7
@@ -431,6 +431,13 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.MISSING_DEPENDENCY_CLASS_IN_LAMBDA_PARAMETER) { firDiagnostic ->
|
||||
MissingDependencyClassInLambdaParameterImpl(
|
||||
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS) { firDiagnostic ->
|
||||
CreatingAnInstanceOfAbstractClassImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
|
||||
+5
@@ -348,6 +348,11 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
val declarationType: KtType
|
||||
}
|
||||
|
||||
interface MissingDependencyClassInLambdaParameter : KtFirDiagnostic<PsiElement> {
|
||||
override val diagnosticClass get() = MissingDependencyClassInLambdaParameter::class
|
||||
val type: KtType
|
||||
}
|
||||
|
||||
interface CreatingAnInstanceOfAbstractClass : KtFirDiagnostic<KtExpression> {
|
||||
override val diagnosticClass get() = CreatingAnInstanceOfAbstractClass::class
|
||||
}
|
||||
|
||||
+6
@@ -401,6 +401,12 @@ internal class MissingDependencySuperclassImpl(
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.MissingDependencySuperclass
|
||||
|
||||
internal class MissingDependencyClassInLambdaParameterImpl(
|
||||
override val type: KtType,
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.MissingDependencyClassInLambdaParameter
|
||||
|
||||
internal class CreatingAnInstanceOfAbstractClassImpl(
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
|
||||
+6
@@ -22892,6 +22892,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/javac/LambdaNonGeneric.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("LambdaNonGenericForbidden.kt")
|
||||
public void testLambdaNonGenericForbidden() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/javac/LambdaNonGenericForbidden.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/javac/fieldsResolution")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+6
@@ -22892,6 +22892,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/javac/LambdaNonGeneric.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("LambdaNonGenericForbidden.kt")
|
||||
public void testLambdaNonGenericForbidden() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/javac/LambdaNonGenericForbidden.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/javac/fieldsResolution")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
Reference in New Issue
Block a user