[kotlin][inspection] fix SOE from UnnecessaryOptInAnnotationInspection

^KTIJ-22084 Fixed

GitOrigin-RevId: b5c605bb7cc5ba1420e96f329632545ba84816d1
This commit is contained in:
Dmitry Gridin
2022-08-15 17:42:08 +00:00
committed by intellij-monorepo-bot
parent 05e3463f19
commit d5e406563b
4 changed files with 38 additions and 1 deletions
@@ -236,7 +236,12 @@ private class MarkerCollector(private val resolutionFacade: ResolutionFacade) {
* @param moduleApiVersion the API version of the current module to check `@WasExperimental` annotations
*/
private fun KotlinType.collectMarkers(moduleApiVersion: ApiVersion) {
arguments.forEach { it.type.collectMarkers(moduleApiVersion) }
arguments.forEach {
if (!it.isStarProjection) {
it.type.collectMarkers(moduleApiVersion)
}
}
val descriptor = this.constructor.declarationDescriptor ?: return
descriptor.collectMarkers(moduleApiVersion)
}
@@ -15414,6 +15414,11 @@ public abstract class LocalInspectionTestGenerated extends AbstractLocalInspecti
runTest("testData/inspectionsLocal/unnecessaryOptInAnnotation/noArguments.kt");
}
@TestMetadata("recursive.kt")
public void testRecursive() throws Exception {
runTest("testData/inspectionsLocal/unnecessaryOptInAnnotation/recursive.kt");
}
@TestMetadata("redundantClassTwoMarkers.kt")
public void testRedundantClassTwoMarkers() throws Exception {
runTest("testData/inspectionsLocal/unnecessaryOptInAnnotation/redundantClassTwoMarkers.kt");
@@ -0,0 +1,14 @@
// WITH_STDLIB
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
@RequiresOptIn
annotation class Marker
lateinit var variable: RecType<*>
@OptIn(<caret>Marker::class)
fun t() {
variable
}
interface RecType<R : RecType<R>>
@@ -0,0 +1,13 @@
// WITH_STDLIB
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn
@RequiresOptIn
annotation class Marker
lateinit var variable: RecType<*>
fun t() {
variable
}
interface RecType<R : RecType<R>>