Introduce compiler flag to manage status of specific Java nullability annotations

This commit is contained in:
Victor Petukhov
2021-05-26 19:21:56 +03:00
parent c3a3e99724
commit c8af1b735f
8 changed files with 150 additions and 21 deletions
@@ -0,0 +1,33 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.jvm.compiler
import org.jetbrains.kotlin.load.java.NULLABILITY_ANNOTATIONS
import org.jetbrains.kotlin.name.isChildOf
import org.jetbrains.kotlin.resolve.jvm.annotations.nullabilityAnnotationSettings
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
class AllNullabilityAnnotationsAreSetUpTest : KtUsefulTestCase() {
fun testAllAnnotationsAreSetUp() {
assert(NULLABILITY_ANNOTATIONS.all { annotation -> nullabilityAnnotationSettings.keys.any { annotation.isChildOf(it) } }) {
val missedAnnotations = NULLABILITY_ANNOTATIONS.filter { annotation ->
nullabilityAnnotationSettings.keys.none { annotation.isChildOf(it) }
}
"Not all nullability annotations are presented in `nullabilityAnnotationSettings`. Missed annotations: $missedAnnotations"
}
}
fun testAllSetUpAnnotationsArePresent() {
assert(nullabilityAnnotationSettings.keys.all { annotationsPackage ->
NULLABILITY_ANNOTATIONS.any { it.isChildOf(annotationsPackage) }
}) {
val missedAnnotations = nullabilityAnnotationSettings.keys.filter { annotationsPackage ->
NULLABILITY_ANNOTATIONS.none { it.isChildOf(annotationsPackage) }
}
"Not all set up nullability annotations are presented in `NULLABILITY_ANNOTATIONS`. Missed annotations: $missedAnnotations"
}
}
}