Use WarningAwareUpperBoundChecker independently

^KT-47920 Fixed
^KT-48290 Fixed
This commit is contained in:
Victor Petukhov
2021-09-28 13:17:57 +03:00
parent d9c50f0fda
commit b957831683
10 changed files with 22 additions and 19 deletions
@@ -5,11 +5,10 @@
package org.jetbrains.kotlin.resolve
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.container.StorageComponentContainer
interface PlatformConfigurator {
val platformSpecificContainer: StorageComponentContainer
fun configureModuleComponents(container: StorageComponentContainer, languageVersionSettings: LanguageVersionSettings)
fun configureModuleComponents(container: StorageComponentContainer)
fun configureModuleDependentCheckers(container: StorageComponentContainer)
}
@@ -94,11 +94,8 @@ object JvmPlatformConfigurator : PlatformConfiguratorBase(
declarationReturnTypeSanitizer = JvmDeclarationReturnTypeSanitizer
) {
override fun configureModuleComponents(container: StorageComponentContainer, languageVersionSettings: LanguageVersionSettings) {
container.useImplIf<WarningAwareUpperBoundChecker>(
!languageVersionSettings.supportsFeature(LanguageFeature.TypeEnhancementImprovementsInStrictMode)
)
override fun configureModuleComponents(container: StorageComponentContainer) {
container.useImpl<WarningAwareUpperBoundChecker>()
container.useImpl<JavaNullabilityChecker>()
container.useImpl<JvmStaticChecker>()
container.useImpl<JvmReflectionAPICallChecker>()
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.storage.StorageManager
private object CommonPlatformConfigurator : PlatformConfiguratorBase() {
override fun configureModuleComponents(container: StorageComponentContainer, languageVersionSettings: LanguageVersionSettings) {}
override fun configureModuleComponents(container: StorageComponentContainer) {}
}
object CommonPlatformAnalyzerServices : PlatformDependentAnalyzerServices() {
@@ -75,7 +75,7 @@ fun StorageComponentContainer.configureModule(
useInstance(nonTrivialPlatformVersion ?: TargetPlatformVersion.NoVersion)
analyzerServices.platformConfigurator.configureModuleComponents(this, languageVersionSettings)
analyzerServices.platformConfigurator.configureModuleComponents(this)
analyzerServices.platformConfigurator.configureModuleDependentCheckers(this)
for (extension in StorageComponentContainerContributor.getInstances(moduleContext.project)) {
@@ -12,7 +12,8 @@ public class NullnessUnspecifiedTypeParameter<T> {
public class Test {}
// FILE: main.kt
fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeParameter<Any?>, x: Test): Unit {
// jspecify_nullness_mismatch
fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeParameter<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Any?<!>>, x: Test): Unit {
// jspecify_nullness_mismatch
a1.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
a1.foo(1)
@@ -13,7 +13,8 @@ public class NullnessUnspecifiedTypeParameter<T> {
public class Test {}
// FILE: main.kt
fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeParameter<Any?>, x: Test): Unit {
// jspecify_nullness_mismatch
fun main(a1: NullnessUnspecifiedTypeParameter<Any>, a2: NullnessUnspecifiedTypeParameter<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Any?<!>>, x: Test): Unit {
// jspecify_nullness_mismatch
a1.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
a1.foo(1)
@@ -20,22 +20,27 @@ public class B<T> {
public class Test {}
// FILE: main.kt
fun <T : Test> main(a1: A<Any?>, a2: A<Test>, b1: B<Any?>, b2: B<Test>, x: T): Unit {
// jspecify_nullness_mismatch, jspecify_nullness_mismatch
fun <T : Test> main(a1: A<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Any?<!>>, a2: A<Test>, b1: B<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Any?<!>>, b2: B<Test>, x: T): Unit {
a1.foo(null)
a1.bar<T?>(null)
// jspecify_nullness_mismatch
a1.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
a1.bar<T>(x)
a2.foo(null)
a2.bar<T?>(null)
// jspecify_nullness_mismatch
a2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
a2.bar<T>(x)
// jspecify_nullness_mismatch
b1.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
b1.bar<T?>(null)
// jspecify_nullness_mismatch
b1.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
b1.bar<T>(x)
// jspecify_nullness_mismatch
b2.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
b2.bar<T?>(null)
// jspecify_nullness_mismatch
b2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
b2.bar<T>(x)
}
@@ -8,5 +8,5 @@ public class J1<@NonNull T> {}
// FILE: main.kt
fun main() {
J1<Any?>() // violated nullability, no warnings; but there is an error with -Xtype-enhancement-improvements-strict-mode
J1<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Any?<!>>() // violated nullability, no warnings; but there is an error with -Xtype-enhancement-improvements-strict-mode
}
@@ -34,7 +34,7 @@ object JsPlatformConfigurator : PlatformConfiguratorBase(
),
identifierChecker = JsIdentifierChecker
) {
override fun configureModuleComponents(container: StorageComponentContainer, languageVersionSettings: LanguageVersionSettings) {
override fun configureModuleComponents(container: StorageComponentContainer) {
container.useInstance(NameSuggestion())
container.useImpl<JsCallChecker>()
container.useImpl<JsTypeSpecificityComparator>()
@@ -28,7 +28,7 @@ object NativePlatformConfigurator : PlatformConfiguratorBase(
NativeTopLevelSingletonChecker, NativeThreadLocalChecker
)
) {
override fun configureModuleComponents(container: StorageComponentContainer, languageVersionSettings: LanguageVersionSettings) {
override fun configureModuleComponents(container: StorageComponentContainer) {
container.useInstance(NativeInliningRule)
container.useImpl<NativeIdentifierChecker>()
}