[FIR] Change diagnostic INITIALIZER_TYPE_MISMATCH to work with for loop

^KTIJ-25251 fixed


Merge-request: KT-MR-10507
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
This commit is contained in:
Egor Kulikov
2023-06-08 09:40:09 +00:00
committed by Space Team
parent 7087ba3ca9
commit f2f979134d
12 changed files with 60 additions and 7 deletions
@@ -2142,7 +2142,7 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
val usedTypeParameter: KtTypeParameterSymbol
}
interface InitializerTypeMismatch : KtFirDiagnostic<KtProperty> {
interface InitializerTypeMismatch : KtFirDiagnostic<KtNamedDeclaration> {
override val diagnosticClass get() = InitializerTypeMismatch::class
val expectedType: KtType
val actualType: KtType
@@ -2583,7 +2583,7 @@ internal class InitializerTypeMismatchImpl(
override val isMismatchDueToNullability: Boolean,
firDiagnostic: KtPsiDiagnostic,
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<KtProperty>(firDiagnostic, token), KtFirDiagnostic.InitializerTypeMismatch
) : KtAbstractFirDiagnostic<KtNamedDeclaration>(firDiagnostic, token), KtFirDiagnostic.InitializerTypeMismatch
internal class GetterVisibilityDiffersFromPropertyVisibilityImpl(
firDiagnostic: KtPsiDiagnostic,
@@ -7072,6 +7072,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/controlStructures/forLoopWithNullableRange.kt");
}
@Test
@TestMetadata("forWithIncorrectTypeSpecializer.kt")
public void testForWithIncorrectTypeSpecializer() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlStructures/forWithIncorrectTypeSpecializer.kt");
}
@Test
@TestMetadata("forWithNullableIterator.kt")
public void testForWithNullableIterator() throws Exception {
@@ -7072,6 +7072,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/controlStructures/forLoopWithNullableRange.kt");
}
@Test
@TestMetadata("forWithIncorrectTypeSpecializer.kt")
public void testForWithIncorrectTypeSpecializer() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlStructures/forWithIncorrectTypeSpecializer.kt");
}
@Test
@TestMetadata("forWithNullableIterator.kt")
public void testForWithNullableIterator() throws Exception {