[kotlin] JavaCollectionWithNullableTypeArgumentInspection: skip super type qualifier

Thus avoiding the exception from Analysis API,
which will only be fixed after the next kt-master merge in the best case.

Since the check is safe and not very complicated,
it can be left in the code even after the AA bug is fixed.

KT-77333

GitOrigin-RevId: 0a6312f12a97d87a783193384541451994b0926f
This commit is contained in:
Alexey Belkov
2025-05-05 17:31:59 +04:00
committed by intellij-monorepo-bot
parent 74e1bb2cbd
commit d666b6a123
3 changed files with 16 additions and 0 deletions

View File

@@ -105,6 +105,7 @@ internal class JavaCollectionWithNullableTypeArgumentInspection :
override fun KaSession.prepareContext(element: KtElement): Context? {
if (PsiTreeUtil.hasErrorElements(element)) return null // Temporary check until KT-77222 is fixed
if (element is KtTypeReference && element.parent is KtSuperExpression) return null // super type qualifier `super<Foo>`
val typeArguments = element.getTypeArguments() ?: return null
val canMakeNonNullable: Boolean

View File

@@ -15730,6 +15730,11 @@ public abstract class K2LocalInspectionTestGenerated extends AbstractK2LocalInsp
runTest("../../../idea/tests/testData/inspectionsLocal/javaCollectionsWithNullableTypes/nullableTypealias.kt");
}
@TestMetadata("superTypeQualifier.kt")
public void testSuperTypeQualifier() throws Exception {
runTest("../../../idea/tests/testData/inspectionsLocal/javaCollectionsWithNullableTypes/superTypeQualifier.kt");
}
@TestMetadata("typeReference.kt")
public void testTypeReference() throws Exception {
runTest("../../../idea/tests/testData/inspectionsLocal/javaCollectionsWithNullableTypes/typeReference.kt");

View File

@@ -0,0 +1,10 @@
// PROBLEM: none
interface I {
fun foo() {}
}
class C : I {
override fun foo() {
super<<caret>I>.foo()
}
}