From a6fdeeb7df95f3457c88f43a7d91cebf9cd7675a Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Wed, 20 Sep 2023 15:34:48 +0200 Subject: [PATCH] [FIR] Implement warnings for java nullability type mismatch #KT-56989 --- .../diagnostics/KtFirDataClassConverters.kt | 16 ++ .../api/fir/diagnostics/KtFirDiagnostics.kt | 12 ++ .../fir/diagnostics/KtFirDiagnosticsImpl.kt | 14 ++ ...nAnnotationsCompiledJavaTestGenerated.java | 6 + ...dJavaWithPsiClassReadingTestGenerated.java | 6 + ...ignAnnotationsSourceJavaTestGenerated.java | 6 + .../diagnostics/FirJvmDiagnosticsList.kt | 10 + .../analysis/diagnostics/jvm/FirJvmErrors.kt | 2 + .../jvm/FirJvmErrorsDefaultMessages.kt | 17 ++ .../jvm/checkers/JvmDeclarationCheckers.kt | 7 + .../jvm/checkers/JvmExpressionCheckers.kt | 26 +++ ...clarationJavaNullabilityWarningCheckers.kt | 59 ++++++ ...xpressionJavaNullabilityWarningCheckers.kt | 190 ++++++++++++++++++ .../EnhancedTypeForWarningAttribute.kt | 42 +++- compiler/testData/cli/jvm/jspecifyWarn.out | 6 + .../testData/cli/jvm/jsr305DeprecatedWarn.out | 3 + .../cli/jvm/jsr305MigrationFqNameIgnore.out | 6 + .../cli/jvm/jsr305MigrationIgnore.out | 6 + .../testData/cli/jvm/jsr305MigrationWarn.out | 9 + compiler/testData/cli/jvm/jsr305NoFlag.out | 3 + compiler/testData/cli/jvm/jsr305Warn.out | 3 + .../moduleAnnotations/warn/basic.fir.kt | 25 --- .../jspecify/moduleAnnotations/warn/basic.kt | 1 + .../composeWithClassDefaultAnnotation.fir.kt | 28 --- .../warn/composeWithClassDefaultAnnotation.kt | 1 + ...composeWithPackageDefaultAnnotation.fir.kt | 31 --- .../composeWithPackageDefaultAnnotation.kt | 1 + .../warn/dependentModulesNullMarked.fir.kt | 30 --- .../warn/dependentModulesNullMarked.kt | 1 + .../warn/dotNamedModule.fir.kt | 25 --- .../moduleAnnotations/warn/dotNamedModule.kt | 1 + .../warn/inheritanceAcrossModules.fir.kt | 45 ----- .../warn/inheritanceAcrossModules.kt | 1 + .../warn/nestedClasses.fir.kt | 8 +- .../severalModulesDifferentPackages.fir.kt | 39 ---- .../warn/severalModulesDifferentPackages.kt | 1 + .../moduleAnnotations/warn/basic.fir.kt | 25 --- .../moduleAnnotations/warn/basic.kt | 1 + .../composeWithClassDefaultAnnotation.fir.kt | 28 --- .../warn/composeWithClassDefaultAnnotation.kt | 1 + ...composeWithPackageDefaultAnnotation.fir.kt | 31 --- .../composeWithPackageDefaultAnnotation.kt | 1 + .../warn/dependentModulesNullMarked.fir.kt | 30 --- .../warn/dependentModulesNullMarked.kt | 1 + .../warn/dotNamedModule.fir.kt | 25 --- .../moduleAnnotations/warn/dotNamedModule.kt | 1 + .../warn/inheritanceAcrossModules.fir.kt | 45 ----- .../warn/inheritanceAcrossModules.kt | 1 + .../warn/nestedClasses.fir.kt | 8 +- .../severalModulesDifferentPackages.fir.kt | 39 ---- .../warn/severalModulesDifferentPackages.kt | 1 + .../java8Tests/jspecify/default.fir.kt | 14 +- .../warnMode/AnnotatedBoundsOfWildcard.fir.kt | 80 -------- .../warnMode/AnnotatedBoundsOfWildcard.kt | 1 + .../jspecify/warnMode/Defaults.fir.kt | 45 ----- .../java8Tests/jspecify/warnMode/Defaults.kt | 1 + .../warnMode/IgnoreAnnotations.fir.kt | 43 ---- .../jspecify/warnMode/IgnoreAnnotations.kt | 1 + .../NullnessUnspecifiedTypeParameter.fir.kt | 12 +- .../jspecify/warnMode/Simple.fir.kt | 36 ---- .../java8Tests/jspecify/warnMode/Simple.kt | 1 + .../TypeArgumentsFromParameterBounds.fir.kt | 45 ----- .../TypeArgumentsFromParameterBounds.kt | 1 + .../warnMode/TypeParameterBounds.fir.kt | 3 +- .../warnMode/UnannotatedWildcard.fir.kt | 17 ++ .../jspecify/warnMode/UnannotatedWildcard.kt | 1 - .../jspecify/warnMode/kt47899.fir.kt | 15 -- .../java8Tests/jspecify/warnMode/kt47899.kt | 4 +- .../java8Tests/jspecifyOld/default.fir.kt | 10 +- .../warnMode/AnnotatedBoundsOfWildcard.fir.kt | 89 -------- .../warnMode/AnnotatedBoundsOfWildcard.kt | 1 + .../jspecifyOld/warnMode/Defaults.fir.kt | 50 ----- .../jspecifyOld/warnMode/Defaults.kt | 1 + .../warnMode/IgnoreAnnotations.fir.kt | 48 ----- .../jspecifyOld/warnMode/IgnoreAnnotations.kt | 1 + .../NullnessUnspecifiedTypeParameter.fir.kt | 8 +- .../jspecifyOld/warnMode/Simple.fir.kt | 39 ---- .../java8Tests/jspecifyOld/warnMode/Simple.kt | 1 + .../TypeArgumentsFromParameterBounds.fir.kt | 48 ----- .../TypeArgumentsFromParameterBounds.kt | 1 + .../warnMode/TypeParameterBounds.fir.kt | 2 +- .../warnMode/UnannotatedWildcard.fir.kt | 16 ++ .../warnMode/UnannotatedWildcard.kt | 1 - .../tests/androidRecently.fir.kt | 12 +- .../constructorParameterNotNull.fir.kt | 2 +- .../constructorParameterNotNull2.fir.kt | 4 +- .../methodParameterNotNull.fir.kt | 4 +- .../methodParameterNotNull2.fir.kt | 2 +- .../expressionBodiedFunction.kt | 15 ++ .../fromPlatformTypes/arithmetic.fir.kt | 24 +-- .../fromPlatformTypes/arithmetic.kt | 8 +- .../fromPlatformTypes/arithmetic.txt | 3 + .../fromPlatformTypes/array.fir.kt | 25 --- .../fromPlatformTypes/array.kt | 1 + .../fromPlatformTypes/assignToVar.fir.kt | 24 --- .../fromPlatformTypes/assignToVar.kt | 1 + .../fromPlatformTypes/conditions.fir.kt | 12 +- .../fromPlatformTypes/dataFlowInfo.fir.kt | 29 --- .../fromPlatformTypes/dataFlowInfo.kt | 1 + .../defaultParameters.fir.kt | 22 -- .../fromPlatformTypes/defaultParameters.kt | 1 + .../delegatedProperties.fir.kt | 21 -- .../fromPlatformTypes/delegatedProperties.kt | 1 + .../derefenceExtension.fir.kt | 4 +- .../fromPlatformTypes/derefenceMember.fir.kt | 4 +- .../fromPlatformTypes/expectedType.fir.kt | 26 --- .../fromPlatformTypes/expectedType.kt | 1 + .../fromPlatformTypes/for.fir.kt | 23 --- .../fromPlatformTypes/for.kt | 1 + .../functionArguments.fir.kt | 13 +- .../fromPlatformTypes/functionArguments.kt | 11 + .../fromPlatformTypes/functionArguments.txt | 2 + .../fromPlatformTypes/invoke.fir.kt | 21 -- .../fromPlatformTypes/invoke.kt | 1 + .../fromPlatformTypes/kt6829.fir.kt | 21 -- .../fromPlatformTypes/kt6829.kt | 1 + .../fromPlatformTypes/multiDeclaration.fir.kt | 2 +- .../fromPlatformTypes/passToJava.fir.kt | 88 -------- .../fromPlatformTypes/passToJava.kt | 23 +++ .../fromPlatformTypes/primitiveArray.fir.kt | 25 --- .../fromPlatformTypes/primitiveArray.kt | 1 + .../fromPlatformTypes/throw.fir.kt | 23 --- .../fromPlatformTypes/throw.kt | 1 + .../nullabilityGenerics.fir.kt | 40 ---- .../nullabilityGenerics.kt | 1 + .../nullabilityNicknames.fir.kt | 10 +- .../fieldsAreNullable.fir.kt | 57 ------ .../typeQualifierDefault/fieldsAreNullable.kt | 1 + .../nullabilityFromOverridden.fir.kt | 16 +- .../overridingDefaultQualifier.fir.kt | 20 +- .../parametersAreNonnullByDefault.fir.kt | 33 --- .../parametersAreNonnullByDefault.kt | 1 + ...arametersAreNonnullByDefaultPackage.fir.kt | 68 ------- .../parametersAreNonnullByDefaultPackage.kt | 1 + .../springNullable.fir.kt | 4 +- .../springNullablePackage.fir.kt | 4 +- .../migration/customMigration.fir.kt | 82 -------- .../migration/customMigration.kt | 1 + .../migration/globalIgnore.fir.kt | 2 +- .../globalWarningMigrationIgnore.fir.kt | 2 +- .../migration/migrationError.fir.kt | 76 ------- .../migration/migrationError.kt | 1 + .../migration/migrationIgnore.fir.kt | 55 ----- .../migration/migrationIgnore.kt | 1 + .../migration/migrationWarning.fir.kt | 2 +- .../migration/overrideConflicts.fir.kt | 85 -------- .../migration/overrideConflicts.kt | 1 + .../migration/stateRefinement.fir.kt | 6 +- .../tests/multiple.fir.kt | 12 +- .../tests/rxjava3Default.fir.kt | 13 +- .../tests/rxjava3Default.kt | 1 + .../tests/rxjava3Warnings.fir.kt | 12 +- .../defaultAndNicknameMigrationPolicy.fir.kt | 64 ------ .../defaultAndNicknameMigrationPolicy.kt | 1 + ...nAnnotationsCompiledJavaTestGenerated.java | 6 + ...dJavaWithPsiClassReadingTestGenerated.java | 6 + ...ignAnnotationsSourceJavaTestGenerated.java | 6 + .../JspecifyDiagnosticComplianceHandler.kt | 6 +- 158 files changed, 741 insertions(+), 2021 deletions(-) create mode 100644 compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/declaration/FirDeclarationJavaNullabilityWarningCheckers.kt create mode 100644 compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/expression/FirExpressionJavaNullabilityWarningCheckers.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/basic.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dotNamedModule.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/basic.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithClassDefaultAnnotation.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dependentModulesNullMarked.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dotNamedModule.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/inheritanceAcrossModules.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/severalModulesDifferentPackages.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/IgnoreAnnotations.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Simple.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeArgumentsFromParameterBounds.fir.kt create mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/UnannotatedWildcard.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/AnnotatedBoundsOfWildcard.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Defaults.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/IgnoreAnnotations.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Simple.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/TypeArgumentsFromParameterBounds.fir.kt create mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/UnannotatedWildcard.fir.kt create mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/expressionBodiedFunction.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/nullabilityGenerics.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/customMigration.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationError.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationIgnore.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/overrideConflicts.fir.kt delete mode 100644 compiler/testData/diagnostics/foreignAnnotationsTests/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.fir.kt diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt index 5e6bd250a72..ef2be5302e8 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -5033,6 +5033,22 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } + add(FirJvmErrors.RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS) { firDiagnostic -> + ReceiverNullabilityMismatchBasedOnJavaAnnotationsImpl( + firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a), + firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.b), + firDiagnostic as KtPsiDiagnostic, + token, + ) + } + add(FirJvmErrors.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS) { firDiagnostic -> + NullabilityMismatchBasedOnJavaAnnotationsImpl( + firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a), + firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.b), + firDiagnostic as KtPsiDiagnostic, + token, + ) + } add(FirJvmErrors.UPPER_BOUND_CANNOT_BE_ARRAY) { firDiagnostic -> UpperBoundCannotBeArrayImpl( firDiagnostic as KtPsiDiagnostic, diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt index 5e75963e894..2daf50f5196 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt @@ -3501,6 +3501,18 @@ sealed interface KtFirDiagnostic : KtDiagnosticWithPsi { val actualType: KtType } + interface ReceiverNullabilityMismatchBasedOnJavaAnnotations : KtFirDiagnostic { + override val diagnosticClass get() = ReceiverNullabilityMismatchBasedOnJavaAnnotations::class + val actualType: KtType + val expectedType: KtType + } + + interface NullabilityMismatchBasedOnJavaAnnotations : KtFirDiagnostic { + override val diagnosticClass get() = NullabilityMismatchBasedOnJavaAnnotations::class + val actualType: KtType + val expectedType: KtType + } + interface UpperBoundCannotBeArray : KtFirDiagnostic { override val diagnosticClass get() = UpperBoundCannotBeArray::class } diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index fb4b31500b7..7632be8bbd9 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -4224,6 +4224,20 @@ internal class JavaTypeMismatchImpl( token: KtLifetimeToken, ) : KtAbstractFirDiagnostic(firDiagnostic, token), KtFirDiagnostic.JavaTypeMismatch +internal class ReceiverNullabilityMismatchBasedOnJavaAnnotationsImpl( + override val actualType: KtType, + override val expectedType: KtType, + firDiagnostic: KtPsiDiagnostic, + token: KtLifetimeToken, +) : KtAbstractFirDiagnostic(firDiagnostic, token), KtFirDiagnostic.ReceiverNullabilityMismatchBasedOnJavaAnnotations + +internal class NullabilityMismatchBasedOnJavaAnnotationsImpl( + override val actualType: KtType, + override val expectedType: KtType, + firDiagnostic: KtPsiDiagnostic, + token: KtLifetimeToken, +) : KtAbstractFirDiagnostic(firDiagnostic, token), KtFirDiagnostic.NullabilityMismatchBasedOnJavaAnnotations + internal class UpperBoundCannotBeArrayImpl( firDiagnostic: KtPsiDiagnostic, token: KtLifetimeToken, diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated.java index b5cbd7c3e8f..38ad3ab3b3f 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated.java @@ -216,6 +216,12 @@ public class FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated extend runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/elvis.kt"); } + @Test + @TestMetadata("expressionBodiedFunction.kt") + public void testExpressionBodiedFunction() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/expressionBodiedFunction.kt"); + } + @Test @TestMetadata("localInference.kt") public void testLocalInference() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java index bcf8a719415..c443fa4d26d 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java @@ -274,6 +274,12 @@ public class FirPsiOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingT runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/elvis.kt"); } + @Test + @TestMetadata("expressionBodiedFunction.kt") + public void testExpressionBodiedFunction() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/expressionBodiedFunction.kt"); + } + @Test @TestMetadata("localInference.kt") public void testLocalInference() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated.java index ff73002b2eb..0fc845e3ab2 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated.java @@ -274,6 +274,12 @@ public class FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated extends runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/elvis.kt"); } + @Test + @TestMetadata("expressionBodiedFunction.kt") + public void testExpressionBodiedFunction() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/expressionBodiedFunction.kt"); + } + @Test @TestMetadata("localInference.kt") public void testLocalInference() throws Exception { diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirJvmDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirJvmDiagnosticsList.kt index ed4336320cd..ea9d77adcdb 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirJvmDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirJvmDiagnosticsList.kt @@ -9,6 +9,7 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.config.LanguageFeature.* import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.DiagnosticList import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.PositioningStrategy +import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.name.ClassId @@ -45,6 +46,15 @@ object JVM_DIAGNOSTICS_LIST : DiagnosticList("FirJvmErrors") { parameter("expectedType") parameter("actualType") } + + val RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS by warning { + parameter("actualType") + parameter("expectedType") + } + val NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS by warning { + parameter("actualType") + parameter("expectedType") + } } val TYPE_PARAMETERS by object : DiagnosticGroup("Type parameters") { diff --git a/compiler/fir/checkers/checkers.jvm/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/jvm/FirJvmErrors.kt b/compiler/fir/checkers/checkers.jvm/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/jvm/FirJvmErrors.kt index 34c2f5dce97..ee9d0bd5516 100644 --- a/compiler/fir/checkers/checkers.jvm/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/jvm/FirJvmErrors.kt +++ b/compiler/fir/checkers/checkers.jvm/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/jvm/FirJvmErrors.kt @@ -44,6 +44,8 @@ object FirJvmErrors { // Types val JAVA_TYPE_MISMATCH by error2() + val RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS by warning2() + val NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS by warning2() // Type parameters val UPPER_BOUND_CANNOT_BE_ARRAY by error0() diff --git a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/diagnostics/jvm/FirJvmErrorsDefaultMessages.kt b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/diagnostics/jvm/FirJvmErrorsDefaultMessages.kt index 0cbaf2b05bb..f5f93635179 100644 --- a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/diagnostics/jvm/FirJvmErrorsDefaultMessages.kt +++ b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/diagnostics/jvm/FirJvmErrorsDefaultMessages.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.analysis.diagnostics.jvm import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap +import org.jetbrains.kotlin.diagnostics.KtDiagnosticRenderers.NOT_RENDERED import org.jetbrains.kotlin.diagnostics.KtDiagnosticRenderers.TO_STRING import org.jetbrains.kotlin.diagnostics.rendering.BaseDiagnosticRendererFactory import org.jetbrains.kotlin.diagnostics.rendering.CommonRenderers.STRING @@ -52,6 +53,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.NON_DATA_C import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.NON_FINAL_JVM_RECORD import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.NON_SOURCE_REPEATED_ANNOTATION import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.NO_REFLECTION_IN_CLASS_PATH +import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.OVERLOADS_ABSTRACT import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.OVERLOADS_ANNOTATION_CLASS_CONSTRUCTOR import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.OVERLOADS_INTERFACE @@ -60,6 +62,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.OVERLOADS_ import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.OVERRIDE_CANNOT_BE_STATIC import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION +import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.REDUNDANT_REPEATABLE_ANNOTATION import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors.REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER @@ -82,6 +85,20 @@ object FirJvmErrorsDefaultMessages : BaseDiagnosticRendererFactory() { override val MAP = KtDiagnosticFactoryToRendererMap("FIR").also { map -> map.put(JAVA_TYPE_MISMATCH, "Java type mismatch: expected ''{0}'' but found ''{1}''. Use explicit cast.", RENDER_TYPE, RENDER_TYPE) + + map.put( + NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS, + "Java type mismatch: inferred type is ''{1}'', but ''{0}'' was expected.", + RENDER_TYPE, + RENDER_TYPE + ) + map.put( + RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS, + "Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type ''{0}''.", + RENDER_TYPE, + NOT_RENDERED + ) + map.put(UPPER_BOUND_CANNOT_BE_ARRAY, "Upper bound of type parameter cannot be an array.") map.put(STRICTFP_ON_CLASS, "'@Strictfp' annotation on classes is not yet supported.") map.put(SYNCHRONIZED_ON_ABSTRACT, "'@Synchronized' annotation cannot be used on abstract functions.") diff --git a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/JvmDeclarationCheckers.kt b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/JvmDeclarationCheckers.kt index 2477f228c32..5fa4a34b674 100644 --- a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/JvmDeclarationCheckers.kt +++ b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/JvmDeclarationCheckers.kt @@ -38,12 +38,14 @@ object JvmDeclarationCheckers : DeclarationCheckers() { get() = setOf( FirJvmFieldApplicabilityChecker, FirJvmSyntheticApplicabilityChecker, + FirPropertyJavaNullabilityWarningChecker, ) override val functionCheckers: Set get() = setOf( FirSynchronizedAnnotationChecker, FirOverloadsChecker, + FirFunctionJavaNullabilityWarningChecker, ) override val typeParameterCheckers: Set @@ -55,4 +57,9 @@ object JvmDeclarationCheckers : DeclarationCheckers() { get() = setOf( FirInlineBodySimpleFunctionChecker, ) + + override val valueParameterCheckers: Set + get() = setOf( + FirValueParameterJavaNullabilityWarningChecker + ) } diff --git a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/JvmExpressionCheckers.kt b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/JvmExpressionCheckers.kt index f527bd5156e..facde70f6e4 100644 --- a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/JvmExpressionCheckers.kt +++ b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/JvmExpressionCheckers.kt @@ -19,6 +19,7 @@ object JvmExpressionCheckers : ExpressionCheckers() { get() = setOf( FirInterfaceDefaultMethodCallChecker, FirJavaSamInterfaceConstructorReferenceChecker, + FirQualifiedAccessJavaNullabilityWarningChecker, ) override val callableReferenceAccessCheckers: Set @@ -41,4 +42,29 @@ object JvmExpressionCheckers : ExpressionCheckers() { FirJvmPackageNameAnnotationsChecker, FirJvmSerializableLambdaChecker, ) + + override val loopExpressionCheckers: Set + get() = setOf( + FirLoopConditionJavaNullabilityWarningChecker, + ) + + override val whenExpressionCheckers: Set + get() = setOf( + FirWhenConditionJavaNullabilityWarningChecker, + ) + + override val logicExpressionCheckers: Set + get() = setOf( + FirLogicExpressionTypeJavaNullabilityWarningChecker, + ) + + override val throwExpressionCheckers: Set + get() = setOf( + FirThrowJavaNullabilityWarningChecker, + ) + + override val variableAssignmentCheckers: Set + get() = setOf( + FirAssignmentJavaNullabilityWarningChecker, + ) } diff --git a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/declaration/FirDeclarationJavaNullabilityWarningCheckers.kt b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/declaration/FirDeclarationJavaNullabilityWarningCheckers.kt new file mode 100644 index 00000000000..80aa36ed58e --- /dev/null +++ b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/declaration/FirDeclarationJavaNullabilityWarningCheckers.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2023 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.fir.analysis.jvm.checkers.declaration + +import org.jetbrains.kotlin.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirFunctionChecker +import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirPropertyChecker +import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirValueParameterChecker +import org.jetbrains.kotlin.fir.analysis.checkers.declaration.hasExplicitReturnType +import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors +import org.jetbrains.kotlin.fir.analysis.jvm.checkers.expression.checkExpressionForEnhancedTypeMismatch +import org.jetbrains.kotlin.fir.declarations.FirFunction +import org.jetbrains.kotlin.fir.declarations.FirProperty +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.expressions.FirReturnExpression +import org.jetbrains.kotlin.fir.expressions.impl.FirSingleExpressionBlock +import org.jetbrains.kotlin.fir.types.coneType + +object FirPropertyJavaNullabilityWarningChecker : FirPropertyChecker() { + override fun check(declaration: FirProperty, context: CheckerContext, reporter: DiagnosticReporter) { + if (declaration.symbol.hasExplicitReturnType) { + declaration.initializer?.checkExpressionForEnhancedTypeMismatch( + declaration.returnTypeRef.coneType, + reporter, + context, + FirJvmErrors.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS, + ) + } + } +} + +object FirFunctionJavaNullabilityWarningChecker : FirFunctionChecker() { + override fun check(declaration: FirFunction, context: CheckerContext, reporter: DiagnosticReporter) { + val body = declaration.body + if (body is FirSingleExpressionBlock && declaration.symbol.hasExplicitReturnType) { + (body.statement as? FirReturnExpression)?.result?.checkExpressionForEnhancedTypeMismatch( + declaration.returnTypeRef.coneType, + reporter, + context, + FirJvmErrors.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS, + ) + } + } +} + +object FirValueParameterJavaNullabilityWarningChecker : FirValueParameterChecker() { + override fun check(declaration: FirValueParameter, context: CheckerContext, reporter: DiagnosticReporter) { + declaration.defaultValue?.checkExpressionForEnhancedTypeMismatch( + declaration.returnTypeRef.coneType, + reporter, + context, + FirJvmErrors.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS, + ) + } +} diff --git a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/expression/FirExpressionJavaNullabilityWarningCheckers.kt b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/expression/FirExpressionJavaNullabilityWarningCheckers.kt new file mode 100644 index 00000000000..c9161028989 --- /dev/null +++ b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/expression/FirExpressionJavaNullabilityWarningCheckers.kt @@ -0,0 +1,190 @@ +/* + * Copyright 2010-2023 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.fir.analysis.jvm.checkers.expression + +import org.jetbrains.kotlin.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactory2 +import org.jetbrains.kotlin.diagnostics.reportOn +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.expression.* +import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors +import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition +import org.jetbrains.kotlin.fir.java.enhancement.EnhancedForWarningConeSubstitutor +import org.jetbrains.kotlin.fir.resolve.FirSamResolver +import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor +import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutorByMap +import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol +import org.jetbrains.kotlin.fir.types.* +import java.util.* + +// TODO reimplement using AdditionalTypeChecker KT-62864 +object FirQualifiedAccessJavaNullabilityWarningChecker : FirQualifiedAccessExpressionChecker() { + override fun check(expression: FirQualifiedAccessExpression, context: CheckerContext, reporter: DiagnosticReporter) { + val symbol = expression.toResolvedCallableSymbol() ?: return + val substitutor = buildSubstitutor(expression, symbol, context.session) + + expression.dispatchReceiver?.checkExpressionForEnhancedTypeMismatch( + expectedType = symbol.dispatchReceiverType, + reporter, + context, + FirJvmErrors.RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS + ) + + val receiverType = symbol.receiverParameter?.typeRef?.coneType + expression.extensionReceiver?.checkExpressionForEnhancedTypeMismatch( + expectedType = receiverType?.let(substitutor::substituteOrSelf), + reporter, + context, + FirJvmErrors.RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS + ) + + for ((contextArgument, contextParameter) in expression.contextReceiverArguments.zip(symbol.resolvedContextReceivers)) { + contextArgument.checkExpressionForEnhancedTypeMismatch( + expectedType = substitutor.substituteOrSelf(contextParameter.typeRef.coneType), + reporter, + context, + FirJvmErrors.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS + ) + } + + if (expression is FirFunctionCall) { + expression.resolvedArgumentMapping?.forEach { (argument, parameter) -> + argument.checkExpressionForEnhancedTypeMismatch( + expectedType = substitutor.substituteOrSelf(parameter.returnTypeRef.coneType), + reporter, + context, + FirJvmErrors.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS + ) + } + } + } + + private fun buildSubstitutor( + expression: FirQualifiedAccessExpression, + symbol: FirCallableSymbol<*>, + session: FirSession, + ): ConeSubstitutor { + if (expression.typeArguments.isEmpty()) return ConeSubstitutor.Empty + + val substitutionMap = buildMap { + for ((parameter, argument) in symbol.typeParameterSymbols.zip(expression.typeArguments)) { + if (argument is FirTypeProjectionWithVariance) { + put(parameter, argument.typeRef.coneType) + } + } + } + + return ConeSubstitutorByMap(substitutionMap, session) + } +} + +object FirThrowJavaNullabilityWarningChecker : FirThrowExpressionChecker() { + override fun check(expression: FirThrowExpression, context: CheckerContext, reporter: DiagnosticReporter) { + expression.exception.checkExpressionForEnhancedTypeMismatch( + expectedType = context.session.builtinTypes.throwableType.coneType, + reporter, + context, + FirJvmErrors.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS + ) + } +} + +object FirAssignmentJavaNullabilityWarningChecker : FirVariableAssignmentChecker() { + override fun check(expression: FirVariableAssignment, context: CheckerContext, reporter: DiagnosticReporter) { + expression.rValue.checkExpressionForEnhancedTypeMismatch( + expectedType = expression.lValue.resolvedType, + reporter, + context, + FirJvmErrors.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS, + ) + } +} + +object FirLogicExpressionTypeJavaNullabilityWarningChecker : FirLogicExpressionChecker() { + override fun check(expression: FirBinaryLogicExpression, context: CheckerContext, reporter: DiagnosticReporter) { + expression.leftOperand.checkConditionForEnhancedTypeMismatch(context, reporter) + expression.rightOperand.checkConditionForEnhancedTypeMismatch(context, reporter) + } +} + +object FirLoopConditionJavaNullabilityWarningChecker : FirLoopExpressionChecker() { + override fun check(expression: FirLoop, context: CheckerContext, reporter: DiagnosticReporter) { + if (expression is FirErrorLoop) return + val condition = expression.condition + condition.checkConditionForEnhancedTypeMismatch(context, reporter) + } +} + +object FirWhenConditionJavaNullabilityWarningChecker : FirWhenExpressionChecker() { + override fun check(expression: FirWhenExpression, context: CheckerContext, reporter: DiagnosticReporter) { + for (branch in expression.branches) { + val condition = branch.condition + if (condition is FirElseIfTrueCondition) continue + condition.checkConditionForEnhancedTypeMismatch(context, reporter) + } + } +} + +private fun FirExpression.checkConditionForEnhancedTypeMismatch(context: CheckerContext, reporter: DiagnosticReporter) { + checkExpressionForEnhancedTypeMismatch( + context.session.builtinTypes.booleanType.type, + reporter, + context, + FirJvmErrors.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS + ) +} + +internal fun FirExpression.checkExpressionForEnhancedTypeMismatch( + expectedType: ConeKotlinType?, + reporter: DiagnosticReporter, + context: CheckerContext, + factory: KtDiagnosticFactory2, +) { + if (expectedType == null) return + val actualType = resolvedType + + val (actualTypeForComparison, expectedTypeForComparison) = getEnhancedTypesForComparison(actualType, expectedType, context) + ?: return + + if (!actualTypeForComparison.isSubtypeOf(context.session.typeContext, expectedTypeForComparison)) { + reporter.reportOn(source, factory, actualTypeForComparison, expectedTypeForComparison, context) + } +} + +private fun getEnhancedTypesForComparison( + actualType: ConeKotlinType?, + expectedType: ConeKotlinType?, + context: CheckerContext, +): Pair? { + if (actualType == null || expectedType == null) return null + if (actualType is ConeErrorType || expectedType is ConeErrorType) return null + + val substitutor = EnhancedForWarningConeSubstitutor(context.session.typeContext) + + val enhancedActualType = substitutor.substituteOrNull(actualType) + val enhancedExpectedType = substitutor.substituteOrNull(expectedType) + + // No enhancement on either side, nothing to check. + if (enhancedActualType == null && enhancedExpectedType == null) return null + + val actualTypeForComparison = enhancedActualType ?: actualType + val expectedTypeForComparison = enhancedExpectedType ?: expectedType + + val expectedTypeAsFunctionTypeIfSam = if ( + actualTypeForComparison.isSomeFunctionType(context.session) && + !expectedTypeForComparison.isSomeFunctionType(context.session) + ) { + // TODO remove after KT-62847 + val samResolver = FirSamResolver(context.session, context.scopeSession) + samResolver.getFunctionTypeForPossibleSamType(expectedTypeForComparison) ?: expectedTypeForComparison + } else { + expectedTypeForComparison + } + + return actualTypeForComparison to expectedTypeAsFunctionTypeIfSam +} diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/EnhancedTypeForWarningAttribute.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/EnhancedTypeForWarningAttribute.kt index 58b43a95f9f..4078015a5d4 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/EnhancedTypeForWarningAttribute.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/EnhancedTypeForWarningAttribute.kt @@ -5,10 +5,9 @@ package org.jetbrains.kotlin.fir.java.enhancement -import org.jetbrains.kotlin.fir.types.ConeAttributeWithConeType -import org.jetbrains.kotlin.fir.types.ConeAttributes -import org.jetbrains.kotlin.fir.types.ConeKotlinType -import org.jetbrains.kotlin.fir.types.renderForDebugging +import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap +import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor +import org.jetbrains.kotlin.fir.types.* import kotlin.reflect.KClass class EnhancedTypeForWarningAttribute( @@ -31,4 +30,37 @@ class EnhancedTypeForWarningAttribute( val ConeAttributes.enhancedTypeForWarning: EnhancedTypeForWarningAttribute? by ConeAttributes.attributeAccessor() val ConeKotlinType.enhancedTypeForWarning: ConeKotlinType? - get() = attributes.enhancedTypeForWarning?.coneType \ No newline at end of file + get() = attributes.enhancedTypeForWarning?.coneType + +/** + * Substitutor that substitutes types with their [ConeKotlinType.enhancedTypeForWarning] recursively. + */ +class EnhancedForWarningConeSubstitutor(typeContext: ConeTypeContext) : AbstractConeSubstitutor(typeContext) { + override fun substituteType(type: ConeKotlinType): ConeKotlinType? { + // The attribute is usually taken from the lower bound of flexible types. + // However, if the type has flexible mutability, we don't want to accidentally enhance the mutability to the lower bound. + if (type is ConeFlexibleType && type.hasFlexibleMutability()) { + val lowerSubstituted = substituteOrNull(type.lowerBound) + + return if (lowerSubstituted is ConeSimpleKotlinType) { + ConeFlexibleType( + lowerBound = lowerSubstituted, + upperBound = substituteOrNull(type.upperBound) as? ConeSimpleKotlinType ?: type.upperBound + ) + } else { + null + } + } + + // If the top-level type can be enhanced, this will only enhance the top-level type but not its arguments: Foo! -> Foo? + // Otherwise, it will enhance recursively until the first possible enhancement. + val enhancedTopLevel = type.enhancedTypeForWarning + + // This will also enhance type arguments if the top-level type was enhanced, otherwise it will continue enhancing recursively. + return enhancedTopLevel?.let(::substituteOrSelf) + } + + private fun ConeFlexibleType.hasFlexibleMutability(): Boolean { + return JavaToKotlinClassMap.isMutable(lowerBound.classId) && JavaToKotlinClassMap.isReadOnly(upperBound.classId) + } +} \ No newline at end of file diff --git a/compiler/testData/cli/jvm/jspecifyWarn.out b/compiler/testData/cli/jvm/jspecifyWarn.out index d86bac9de59..c9707dafe94 100644 --- a/compiler/testData/cli/jvm/jspecifyWarn.out +++ b/compiler/testData/cli/jvm/jspecifyWarn.out @@ -1 +1,7 @@ +compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: warning: Java type mismatch: inferred type is 'kotlin/String', but 'kotlin/Nothing?' was expected. + a.foo(null) + ^ +compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'kotlin/String?'. + a.bar().hashCode() + ^ OK diff --git a/compiler/testData/cli/jvm/jsr305DeprecatedWarn.out b/compiler/testData/cli/jvm/jsr305DeprecatedWarn.out index 585f9b69881..e795389f8d5 100644 --- a/compiler/testData/cli/jvm/jsr305DeprecatedWarn.out +++ b/compiler/testData/cli/jvm/jsr305DeprecatedWarn.out @@ -1,2 +1,5 @@ warning: argument -Xjsr305-annotations is deprecated. Please use -Xjsr305 instead +compiler/testData/cli/jvm/jsr305Usage.kt:2:11: warning: Java type mismatch: inferred type is 'kotlin/String', but 'kotlin/Nothing?' was expected. + a.foo(null) + ^ OK diff --git a/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.out b/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.out index d86bac9de59..f3c58e6f285 100644 --- a/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.out +++ b/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.out @@ -1 +1,7 @@ +compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: Java type mismatch: inferred type is 'kotlin/String', but 'kotlin/Nothing?' was expected. + annotated.foo(null) + ^ +compiler/testData/cli/jvm/jsr305Migration.kt:4:5: warning: only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'kotlin/String?'. + annotated.nullable().length + ^ OK diff --git a/compiler/testData/cli/jvm/jsr305MigrationIgnore.out b/compiler/testData/cli/jvm/jsr305MigrationIgnore.out index d86bac9de59..f3c58e6f285 100644 --- a/compiler/testData/cli/jvm/jsr305MigrationIgnore.out +++ b/compiler/testData/cli/jvm/jsr305MigrationIgnore.out @@ -1 +1,7 @@ +compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: Java type mismatch: inferred type is 'kotlin/String', but 'kotlin/Nothing?' was expected. + annotated.foo(null) + ^ +compiler/testData/cli/jvm/jsr305Migration.kt:4:5: warning: only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'kotlin/String?'. + annotated.nullable().length + ^ OK diff --git a/compiler/testData/cli/jvm/jsr305MigrationWarn.out b/compiler/testData/cli/jvm/jsr305MigrationWarn.out index d86bac9de59..0f40d4ac8de 100644 --- a/compiler/testData/cli/jvm/jsr305MigrationWarn.out +++ b/compiler/testData/cli/jvm/jsr305MigrationWarn.out @@ -1 +1,10 @@ +compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: Java type mismatch: inferred type is 'kotlin/String', but 'kotlin/Nothing?' was expected. + annotated.foo(null) + ^ +compiler/testData/cli/jvm/jsr305Migration.kt:3:19: warning: Java type mismatch: inferred type is 'kotlin/String', but 'kotlin/Nothing?' was expected. + annotated.bar(null) + ^ +compiler/testData/cli/jvm/jsr305Migration.kt:4:5: warning: only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'kotlin/String?'. + annotated.nullable().length + ^ OK diff --git a/compiler/testData/cli/jvm/jsr305NoFlag.out b/compiler/testData/cli/jvm/jsr305NoFlag.out index d86bac9de59..707ae707a29 100644 --- a/compiler/testData/cli/jvm/jsr305NoFlag.out +++ b/compiler/testData/cli/jvm/jsr305NoFlag.out @@ -1 +1,4 @@ +compiler/testData/cli/jvm/jsr305Usage.kt:2:11: warning: Java type mismatch: inferred type is 'kotlin/String', but 'kotlin/Nothing?' was expected. + a.foo(null) + ^ OK diff --git a/compiler/testData/cli/jvm/jsr305Warn.out b/compiler/testData/cli/jvm/jsr305Warn.out index d86bac9de59..707ae707a29 100644 --- a/compiler/testData/cli/jvm/jsr305Warn.out +++ b/compiler/testData/cli/jvm/jsr305Warn.out @@ -1 +1,4 @@ +compiler/testData/cli/jvm/jsr305Usage.kt:2:11: warning: Java type mismatch: inferred type is 'kotlin/String', but 'kotlin/Nothing?' was expected. + a.foo(null) + ^ OK diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/basic.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/basic.fir.kt deleted file mode 100644 index aded29c5bb0..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/basic.fir.kt +++ /dev/null @@ -1,25 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// FILE: sandbox/module-info.java -import org.jspecify.annotations.NullMarked; - -@NullMarked -module sandbox { - requires java9_annotations; - exports test; -} - -// FILE: sandbox/test/Test.java -package test; - -public class Test { - public void foo(Integer x) {} -} - -// FILE: main.kt -import test.Test - -fun main(x: Test) { - x.foo(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/basic.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/basic.kt index 9d7f54ccf1c..899ecbe03f4 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/basic.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/basic.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.fir.kt deleted file mode 100644 index 72886a94ec4..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.fir.kt +++ /dev/null @@ -1,28 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// FILE: sandbox/test/module-info.java -import org.jspecify.annotations.NullMarked; - -@NullMarked -module sandbox { - requires java9_annotations; - exports test; -} - -// FILE: sandbox/test/Test.java -package test; - -import org.jspecify.annotations.NullMarked; - -@NullMarked -public class Test { - public void foo(Integer x) {} -} - -// FILE: main.kt -import test.Test - -fun main(x: Test) { - x.foo(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt index d37cb33438b..9af3af94040 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.fir.kt deleted file mode 100644 index 66f20ee9650..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.fir.kt +++ /dev/null @@ -1,31 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// FILE: sandbox/module-info.java -import org.jspecify.annotations.NullMarked; - -@NullMarked -module sandbox { - requires java9_annotations; - exports test; -} - -// FILE: sandbox/test/package-info.java -@NullMarked -package test; - -import org.jspecify.annotations.NullMarked; - -// FILE: sandbox/test/Test.java -package test; - -public class Test { - public void foo(Integer x) {} -} - -// FILE: main.kt -import test.Test - -fun main(x: Test) { - x.foo(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt index 3b2f95d3adc..bdfcac6f647 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.fir.kt deleted file mode 100644 index 556a06a959a..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.fir.kt +++ /dev/null @@ -1,30 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// MODULE: module1 -// FILE: module1/module-info.java -module module1 { -} - -// MODULE: module2(module1) -// FILE: module2/module-info.java -import org.jspecify.annotations.NullMarked; - -@NullMarked -module module2 { - requires java9_annotations; - requires module1; - exports test2; -} - -// FILE: module2/test2/Test.java -package test2; - -public class Test { - public void foo(Integer x) {} -} - -// FILE: main.kt -fun main(y: test2.Test) { - y.foo(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.kt index fec0e8cfe49..774839f9713 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dependentModulesNullMarked.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dotNamedModule.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dotNamedModule.fir.kt deleted file mode 100644 index d968d0a5e27..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dotNamedModule.fir.kt +++ /dev/null @@ -1,25 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// FILE: my.sand.box/module-info.java -import org.jspecify.annotations.NullMarked; - -@NullMarked -open module my.sand.box { - requires java9_annotations; - exports my.test; -} - -// FILE: my.sand.box/my/test/Test.java -package my.test; - -public class Test { - public void foo(Integer x) {} -} - -// FILE: main.kt -import my.test.Test - -fun main(x: Test) { - x.foo(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dotNamedModule.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dotNamedModule.kt index ca847481396..a89491abb60 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dotNamedModule.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/dotNamedModule.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.fir.kt deleted file mode 100644 index 08c14e1d661..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.fir.kt +++ /dev/null @@ -1,45 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// MODULE: module1 -// FILE: module1/module-info.java -import org.jspecify.annotations.NullMarked; - -@NullMarked -module module1 { - requires java9_annotations; - exports test1; -} - -// FILE: module1/test1/Test1.java -package test1; - -public class Test1 { - public void foo(Integer x) {} -} - -// MODULE: module2(module1) -// FILE: module2/module-info.java -module module2 { - requires module1; - exports test2; -} - -// FILE: module2/test2/Test2.java -package test2; - -import test1.Test1; - -public class Test2 extends Test1 { - public void foo2(Integer x) {} -} - -// FILE: main.kt -import test1.Test1 -import test2.Test2 - -fun main(x: Test1, y: Test2) { - x.foo(null) - y.foo(null) - y.foo2(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.kt index 92e68b499a7..4825001f320 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/inheritanceAcrossModules.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/nestedClasses.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/nestedClasses.fir.kt index 071bf950942..0f274977ac2 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/nestedClasses.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/nestedClasses.fir.kt @@ -35,9 +35,9 @@ public class Test { import test.Test fun main(x: Test) { - x.Test3().foo(null) - x.Test3().Test5().foo(null) + x.Test3().foo(null) + x.Test3().Test5().foo(null) - Test.Test2().foo(null) - Test.Test2().Test5().foo(null) + Test.Test2().foo(null) + Test.Test2().Test5().foo(null) } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.fir.kt deleted file mode 100644 index 95d6b052d02..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.fir.kt +++ /dev/null @@ -1,39 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// MODULE: module1 -// FILE: module1/module-info.java -import org.jspecify.annotations.NullMarked; - -@NullMarked -module module1 { - requires java9_annotations; - exports test1; -} - -// FILE: module1/test1/Test.java -package test1; - -public class Test { - public void foo(Integer x) {} -} - -// MODULE: module2(module1) -// FILE: module2/module-info.java -module module2 { - requires module1; - exports test2; -} - -// FILE: module2/test2/Test.java -package test2; - -public class Test { - public void foo(Integer x) {} -} - -// FILE: main.kt -fun main(x: test1.Test, y: test2.Test) { - x.foo(null) - y.foo(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.kt index c8651f3a0c4..01269998aa8 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecify/moduleAnnotations/warn/severalModulesDifferentPackages.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/basic.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/basic.fir.kt deleted file mode 100644 index 140f5cd7446..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/basic.fir.kt +++ /dev/null @@ -1,25 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// FILE: sandbox/module-info.java -import org.jspecify.nullness.NullMarked; - -@NullMarked -module sandbox { - requires java9_annotations; - exports test; -} - -// FILE: sandbox/test/Test.java -package test; - -public class Test { - public void foo(Integer x) {} -} - -// FILE: main.kt -import test.Test - -fun main(x: Test) { - x.foo(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/basic.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/basic.kt index 3064e8cf940..0ffc53c6566 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/basic.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/basic.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithClassDefaultAnnotation.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithClassDefaultAnnotation.fir.kt deleted file mode 100644 index f04a05cbad9..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithClassDefaultAnnotation.fir.kt +++ /dev/null @@ -1,28 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// FILE: sandbox/test/module-info.java -import org.jspecify.nullness.NullMarked; - -@NullMarked -module sandbox { - requires java9_annotations; - exports test; -} - -// FILE: sandbox/test/Test.java -package test; - -import org.jspecify.nullness.NullMarked; - -@NullMarked -public class Test { - public void foo(Integer x) {} -} - -// FILE: main.kt -import test.Test - -fun main(x: Test) { - x.foo(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt index 927b4c03a21..2f1648d3023 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithClassDefaultAnnotation.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.fir.kt deleted file mode 100644 index a8c6dea1146..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.fir.kt +++ /dev/null @@ -1,31 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// FILE: sandbox/module-info.java -import org.jspecify.nullness.NullMarked; - -@NullMarked -module sandbox { - requires java9_annotations; - exports test; -} - -// FILE: sandbox/test/package-info.java -@NullMarked -package test; - -import org.jspecify.nullness.NullMarked; - -// FILE: sandbox/test/Test.java -package test; - -public class Test { - public void foo(Integer x) {} -} - -// FILE: main.kt -import test.Test - -fun main(x: Test) { - x.foo(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt index 918d2e91a41..dde29a5fc18 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/composeWithPackageDefaultAnnotation.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dependentModulesNullMarked.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dependentModulesNullMarked.fir.kt deleted file mode 100644 index 5a18583c504..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dependentModulesNullMarked.fir.kt +++ /dev/null @@ -1,30 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// MODULE: module1 -// FILE: module1/module-info.java -module module1 { -} - -// MODULE: module2(module1) -// FILE: module2/module-info.java -import org.jspecify.nullness.NullMarked; - -@NullMarked -module module2 { - requires java9_annotations; - requires module1; - exports test2; -} - -// FILE: module2/test2/Test.java -package test2; - -public class Test { - public void foo(Integer x) {} -} - -// FILE: main.kt -fun main(y: test2.Test) { - y.foo(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dependentModulesNullMarked.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dependentModulesNullMarked.kt index aa959d1c5aa..998b9197ccf 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dependentModulesNullMarked.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dependentModulesNullMarked.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dotNamedModule.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dotNamedModule.fir.kt deleted file mode 100644 index a6833e397c4..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dotNamedModule.fir.kt +++ /dev/null @@ -1,25 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// FILE: my.sand.box/module-info.java -import org.jspecify.nullness.NullMarked; - -@NullMarked -open module my.sand.box { - requires java9_annotations; - exports my.test; -} - -// FILE: my.sand.box/my/test/Test.java -package my.test; - -public class Test { - public void foo(Integer x) {} -} - -// FILE: main.kt -import my.test.Test - -fun main(x: Test) { - x.foo(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dotNamedModule.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dotNamedModule.kt index da2694b8fd5..2c702f84654 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dotNamedModule.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/dotNamedModule.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/inheritanceAcrossModules.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/inheritanceAcrossModules.fir.kt deleted file mode 100644 index b3a6eb69c54..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/inheritanceAcrossModules.fir.kt +++ /dev/null @@ -1,45 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// MODULE: module1 -// FILE: module1/module-info.java -import org.jspecify.nullness.NullMarked; - -@NullMarked -module module1 { - requires java9_annotations; - exports test1; -} - -// FILE: module1/test1/Test1.java -package test1; - -public class Test1 { - public void foo(Integer x) {} -} - -// MODULE: module2(module1) -// FILE: module2/module-info.java -module module2 { - requires module1; - exports test2; -} - -// FILE: module2/test2/Test2.java -package test2; - -import test1.Test1; - -public class Test2 extends Test1 { - public void foo2(Integer x) {} -} - -// FILE: main.kt -import test1.Test1 -import test2.Test2 - -fun main(x: Test1, y: Test2) { - x.foo(null) - y.foo(null) - y.foo2(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/inheritanceAcrossModules.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/inheritanceAcrossModules.kt index 1611806de25..58fa5b33209 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/inheritanceAcrossModules.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/inheritanceAcrossModules.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/nestedClasses.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/nestedClasses.fir.kt index 1e674e3e15a..4ccbafd1cf2 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/nestedClasses.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/nestedClasses.fir.kt @@ -35,9 +35,9 @@ public class Test { import test.Test fun main(x: Test) { - x.Test3().foo(null) - x.Test3().Test5().foo(null) + x.Test3().foo(null) + x.Test3().Test5().foo(null) - Test.Test2().foo(null) - Test.Test2().Test5().foo(null) + Test.Test2().foo(null) + Test.Test2().Test5().foo(null) } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/severalModulesDifferentPackages.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/severalModulesDifferentPackages.fir.kt deleted file mode 100644 index 5e99d57f9fe..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/severalModulesDifferentPackages.fir.kt +++ /dev/null @@ -1,39 +0,0 @@ -// JSPECIFY_STATE: warn -// ALLOW_KOTLIN_PACKAGE - -// MODULE: module1 -// FILE: module1/module-info.java -import org.jspecify.nullness.NullMarked; - -@NullMarked -module module1 { - requires java9_annotations; - exports test1; -} - -// FILE: module1/test1/Test.java -package test1; - -public class Test { - public void foo(Integer x) {} -} - -// MODULE: module2(module1) -// FILE: module2/module-info.java -module module2 { - requires module1; - exports test2; -} - -// FILE: module2/test2/Test.java -package test2; - -public class Test { - public void foo(Integer x) {} -} - -// FILE: main.kt -fun main(x: test1.Test, y: test2.Test) { - x.foo(null) - y.foo(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/severalModulesDifferentPackages.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/severalModulesDifferentPackages.kt index b344c490418..70974fc95c8 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/severalModulesDifferentPackages.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java11Tests/jspecifyOld/moduleAnnotations/warn/severalModulesDifferentPackages.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // ALLOW_KOTLIN_PACKAGE diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/default.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/default.fir.kt index 3b7be585510..757cc1d5d00 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/default.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/default.fir.kt @@ -13,17 +13,21 @@ public class Test {} // FILE: main.kt fun main(a1: NullnessUnspecifiedTypeParameter, a2: NullnessUnspecifiedTypeParameter, x: Test): Unit { - a1.foo(null) + // jspecify_nullness_mismatch + a1.foo(null) a1.foo(1) a2.foo(null) a2.foo(1) - a1.bar(null, null) - a1.bar(x, null) + // jspecify_nullness_mismatch, jspecify_nullness_mismatch + a1.bar(null, null) + // jspecify_nullness_mismatch + a1.bar(x, null) a1.bar(x, 1) - a2.bar(null, null) + // jspecify_nullness_mismatch + a2.bar(null, null) a2.bar(x, null) a2.bar(x, 1) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.fir.kt deleted file mode 100644 index 1d6a978e28e..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.fir.kt +++ /dev/null @@ -1,80 +0,0 @@ -// JSPECIFY_STATE: warn -// MUTE_FOR_PSI_CLASS_FILES_READING - -// FILE: AnnotatedBoundsOfWildcard.java -import org.jspecify.annotations.*; - -@NullMarked -public class AnnotatedBoundsOfWildcard { - public void superAsIs(Test a) {} - public void superNotNull(Test a) {} - public void superNullable(Test a) {} - - public void extendsAsIs(Test a) {} - public void extendsNotNull(Test a) {} - public void extendsNullable(Test a) {} - - public void noBounds(Test a) {} -} - -// FILE: Base.java -public class Base {} - -// FILE: Derived.java -public class Derived extends Base {} - -// FILE: Test.java -import org.jspecify.annotations.*; - -@NullMarked -public class Test { } - -// FILE: main.kt -fun main( - aNotNullNotNullNotNull: Test, - aNotNullNotNullNull: Test, - aNotNullNullNotNull: Test, - aNotNullNullNull: Test, - - aAnyNotNullNotNullNotNull: Test, - aAnyNotNullNotNullNull: Test, - aAnyNotNullNullNotNull: Test, - aAnyNotNullNullNull: Test, - - b: AnnotatedBoundsOfWildcard -): Unit { - b.superAsIs(aAnyNotNullNotNullNotNull) - b.superAsIs(aAnyNotNullNotNullNull) - b.superAsIs(aAnyNotNullNullNotNull) - b.superAsIs(aAnyNotNullNullNull) - - b.superNotNull(aAnyNotNullNotNullNotNull) - b.superNotNull(aAnyNotNullNotNullNull) - b.superNotNull(aAnyNotNullNullNotNull) - b.superNotNull(aAnyNotNullNullNull) - - b.superNullable(aAnyNotNullNotNullNotNull) - b.superNullable(aAnyNotNullNotNullNull) - b.superNullable(aAnyNotNullNullNotNull) - b.superNullable(aAnyNotNullNullNull) - - b.extendsAsIs(aNotNullNotNullNotNull) - b.extendsAsIs(aNotNullNotNullNull) - b.extendsAsIs(aNotNullNullNotNull) - b.extendsAsIs(aNotNullNullNull) - - b.extendsNotNull(aNotNullNotNullNotNull) - b.extendsNotNull(aNotNullNotNullNull) - b.extendsNotNull(aNotNullNullNotNull) - b.extendsNotNull(aNotNullNullNull) - - b.extendsNullable(aNotNullNotNullNotNull) - b.extendsNullable(aNotNullNotNullNull) - b.extendsNullable(aNotNullNullNotNull) - b.extendsNullable(aNotNullNullNull) - - b.noBounds(aNotNullNotNullNotNull) - b.noBounds(aNotNullNotNullNull) - b.noBounds(aNotNullNullNotNull) - b.noBounds(aNotNullNullNull) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.kt index 5b6c0d331df..64eff20b232 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/AnnotatedBoundsOfWildcard.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // MUTE_FOR_PSI_CLASS_FILES_READING diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.fir.kt deleted file mode 100644 index 82dbe42e587..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.fir.kt +++ /dev/null @@ -1,45 +0,0 @@ -// JSPECIFY_STATE: warn - -// FILE: Defaults.java -import org.jspecify.annotations.*; - -@NullMarked -public class Defaults { - public Foo defaultField = null; - @Nullable public Foo field = null; - - public Foo everythingNotNullable(Foo x) { return null; } - - public @Nullable Foo everythingNullable(@Nullable Foo x) { return null; } - - public @NullnessUnspecified Foo everythingUnknown(@NullnessUnspecified Foo x) { return null; } - - public @Nullable Foo mixed(Foo x) { return null; } - - public Foo explicitlyNullnessUnspecified(@NullnessUnspecified Foo x) { return null; } -} - -// FILE: Foo.java -public class Foo { - public Object foo() { return null; } -} - -// FILE: main.kt -fun main(a: Defaults, x: Foo): Unit { - a.everythingNotNullable(null).foo() - a.everythingNotNullable(x).foo() - - a.everythingNullable(null).foo() - - a.everythingUnknown(null).foo() - - a.mixed(null).foo() - a.mixed(x).foo() - - a.explicitlyNullnessUnspecified(x).foo() - a.explicitlyNullnessUnspecified(null).foo() - - a.defaultField.foo() - - a.field.foo() -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.kt index 7fa6a797d3a..f89ea978428 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Defaults.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // FILE: Defaults.java diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/IgnoreAnnotations.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/IgnoreAnnotations.fir.kt deleted file mode 100644 index bb13d541c7f..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/IgnoreAnnotations.fir.kt +++ /dev/null @@ -1,43 +0,0 @@ -// JSPECIFY_STATE: warn - -// FILE: IgnoreAnnotations.java -import org.jspecify.annotations.*; - -@NullMarked -public class IgnoreAnnotations { - @Nullable public Derived field = null; - - @Nullable - public Derived foo(Derived x, @NullnessUnspecified Base y) { - return null; - } - - public Derived everythingNotNullable(Derived x) { return null; } - - public @Nullable Derived everythingNullable(@Nullable Derived x) { return null; } - - public @NullnessUnspecified Derived everythingUnknown(@NullnessUnspecified Derived x) { return null; } -} - -// FILE: Base.java -public class Base { - void foo() {} -} - -// FILE: Derived.java -public class Derived extends Base { } - -// FILE: main.kt -fun main(a: IgnoreAnnotations, x: Derived): Unit { - a.foo(x, null).foo() - a.foo(null, x).foo() - - a.field.foo() - - a.everythingNotNullable(null).foo() - a.everythingNotNullable(x).foo() - - a.everythingNullable(null).foo() - - a.everythingUnknown(null).foo() -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/IgnoreAnnotations.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/IgnoreAnnotations.kt index d21b4826fab..3fc334a164f 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/IgnoreAnnotations.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/IgnoreAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // FILE: IgnoreAnnotations.java diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NullnessUnspecifiedTypeParameter.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NullnessUnspecifiedTypeParameter.fir.kt index 6896a891af6..dc0f4ab799b 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NullnessUnspecifiedTypeParameter.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/NullnessUnspecifiedTypeParameter.fir.kt @@ -14,17 +14,21 @@ public class Test {} // FILE: main.kt fun main(a1: NullnessUnspecifiedTypeParameter, a2: NullnessUnspecifiedTypeParameter, x: Test): Unit { - a1.foo(null) + // jspecify_nullness_mismatch + a1.foo(null) a1.foo(1) a2.foo(null) a2.foo(1) - a1.bar(null, null) - a1.bar(x, null) + // jspecify_nullness_mismatch, jspecify_nullness_mismatch + a1.bar(null, null) + // jspecify_nullness_mismatch + a1.bar(x, null) a1.bar(x, 1) - a2.bar(null, null) + // jspecify_nullness_mismatch + a2.bar(null, null) a2.bar(x, null) a2.bar(x, 1) } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Simple.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Simple.fir.kt deleted file mode 100644 index 6a9d1d6f2e8..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Simple.fir.kt +++ /dev/null @@ -1,36 +0,0 @@ -// JSPECIFY_STATE: warn - -// FILE: Simple.java -import org.jspecify.annotations.*; - -@NullMarked -public class Simple { - @Nullable public Derived field = null; - - @Nullable - public Derived foo(Derived x, @NullnessUnspecified Base y) { - return null; - } - - public Derived bar() { - return null; - } -} - -// FILE: Base.java -public class Base {} - -// FILE: Derived.java -public class Derived extends Base { - void foo() {} -} - -// FILE: main.kt -fun main(a: Simple, x: Derived): Unit { - a.foo(x, null).foo() - a.foo(null, x).foo() - - a.bar().foo() - - a.field.foo() -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Simple.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Simple.kt index accbeabfc98..951b8f6ef9a 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Simple.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/Simple.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // FILE: Simple.java diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeArgumentsFromParameterBounds.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeArgumentsFromParameterBounds.fir.kt deleted file mode 100644 index ace2a6d2c69..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeArgumentsFromParameterBounds.fir.kt +++ /dev/null @@ -1,45 +0,0 @@ -// JSPECIFY_STATE: warn -// MUTE_FOR_PSI_CLASS_FILES_READING - -// FILE: TypeArgumentsFromParameterBounds.java -import org.jspecify.annotations.*; - -@NullMarked -public class TypeArgumentsFromParameterBounds {} - -// FILE: A.java -import org.jspecify.annotations.*; - -@NullMarked -public class A { - public void bar(TypeArgumentsFromParameterBounds a) {} -} - -// FILE: B.java -import org.jspecify.annotations.*; - -public class B { - public void bar(TypeArgumentsFromParameterBounds a) {} -} - -// FILE: Test.java -public class Test {} - -// FILE: main.kt -fun main( - aNotNullNotNullNotNull: TypeArgumentsFromParameterBounds, - aNotNullNotNullNull: TypeArgumentsFromParameterBounds, - aNotNullNullNotNull: TypeArgumentsFromParameterBounds, - aNotNullNullNull: TypeArgumentsFromParameterBounds, - a: A, b: B -): Unit { - a.bar(aNotNullNotNullNotNull) - a.bar(aNotNullNotNullNull) - a.bar(aNotNullNullNotNull) - a.bar(aNotNullNullNull) - - b.bar(aNotNullNotNullNotNull) - b.bar(aNotNullNotNullNull) - b.bar(aNotNullNullNotNull) - b.bar(aNotNullNullNull) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeArgumentsFromParameterBounds.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeArgumentsFromParameterBounds.kt index 9d1f82a49fa..20baeeabc29 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeArgumentsFromParameterBounds.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeArgumentsFromParameterBounds.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // MUTE_FOR_PSI_CLASS_FILES_READING diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeParameterBounds.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeParameterBounds.fir.kt index d03cbefec32..8b98f8360f7 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeParameterBounds.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeParameterBounds.fir.kt @@ -33,7 +33,8 @@ fun main(a1: A, a2: A, b1: B, b2: B, x: T): U b1.bar(null) b1.bar(x) - b2.foo(null) + // jspecify_nullness_mismatch + b2.foo(null) b2.bar(null) b2.bar(x) } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/UnannotatedWildcard.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/UnannotatedWildcard.fir.kt new file mode 100644 index 00000000000..9ca60e314f0 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/UnannotatedWildcard.fir.kt @@ -0,0 +1,17 @@ +// JSPECIFY_STATE: warn +// FILE: J1.java +import org.jspecify.annotations.*; + +@NullMarked +public interface J1 { + T foo(); +} + +// FILE: J2.java +public interface J2 { + J1 bar(); +} + +// FILE: main.kt +// jspecify_nullness_mismatch +fun baz(j2: J2): Any = j2.bar().foo() // Any..Any? diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/UnannotatedWildcard.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/UnannotatedWildcard.kt index 749756a2fd2..48d0471ee11 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/UnannotatedWildcard.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/UnannotatedWildcard.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // JSPECIFY_STATE: warn // FILE: J1.java import org.jspecify.annotations.*; diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.fir.kt deleted file mode 100644 index d591f65d8d5..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.fir.kt +++ /dev/null @@ -1,15 +0,0 @@ -// JSPECIFY_STATE: warn - -// FILE: Foo.java -import org.jspecify.annotations.Nullable; - -public class Foo { - public static void gauge(@Nullable T stateObject) {} -} - -// FILE: main.kt -fun test(metric: T) { - if (metric is String) { - Foo.gauge(metric) - } -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt index 42a9c0e6832..78b153bcfe9 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/kt47899.kt @@ -1,3 +1,5 @@ +// FIR_IDENTICAL +// DIAGNOSTICS: -DEBUG_INFO_SMARTCAST // JSPECIFY_STATE: warn // FILE: Foo.java @@ -10,6 +12,6 @@ public class Foo { // FILE: main.kt fun test(metric: T) { if (metric is String) { - Foo.gauge(metric) + Foo.gauge(metric) } } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/default.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/default.fir.kt index 530b7425695..fc030585b3a 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/default.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/default.fir.kt @@ -15,7 +15,7 @@ public class Test {} // jspecify_nullness_mismatch fun main(a1: NullnessUnspecifiedTypeParameter, a2: NullnessUnspecifiedTypeParameter, x: Test): Unit { // jspecify_nullness_mismatch - a1.foo(null) + a1.foo(null) a1.foo(1) // jspecify_nullness_mismatch @@ -23,14 +23,14 @@ fun main(a1: NullnessUnspecifiedTypeParameter, a2: NullnessUnspecifiedTypeP a2.foo(1) // jspecify_nullness_mismatch, jspecify_nullness_mismatch - a1.bar(null, null) + a1.bar(null, null) // jspecify_nullness_mismatch - a1.bar(x, null) + a1.bar(x, null) a1.bar(x, 1) // jspecify_nullness_mismatch, jspecify_nullness_mismatch - a2.bar(null, null) + a2.bar(null, null) // jspecify_nullness_mismatch a2.bar(x, null) a2.bar(x, 1) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/AnnotatedBoundsOfWildcard.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/AnnotatedBoundsOfWildcard.fir.kt deleted file mode 100644 index 6cccaeaaa27..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/AnnotatedBoundsOfWildcard.fir.kt +++ /dev/null @@ -1,89 +0,0 @@ -// JSPECIFY_STATE: warn -// MUTE_FOR_PSI_CLASS_FILES_READING - -// FILE: AnnotatedBoundsOfWildcard.java -import org.jspecify.nullness.*; - -@NullMarked -public class AnnotatedBoundsOfWildcard { - public void superAsIs(Test a) {} - public void superNotNull(Test a) {} - public void superNullable(Test a) {} - - public void extendsAsIs(Test a) {} - public void extendsNotNull(Test a) {} - public void extendsNullable(Test a) {} - - public void noBounds(Test a) {} -} - -// FILE: Base.java -public class Base {} - -// FILE: Derived.java -public class Derived extends Base {} - -// FILE: Test.java -import org.jspecify.nullness.*; - -@NullMarked -public class Test { } - -// FILE: main.kt -fun main( - aNotNullNotNullNotNull: Test, - aNotNullNotNullNull: Test, - aNotNullNullNotNull: Test, - aNotNullNullNull: Test, - - aAnyNotNullNotNullNotNull: Test, - aAnyNotNullNotNullNull: Test, - aAnyNotNullNullNotNull: Test, - aAnyNotNullNullNull: Test, - - b: AnnotatedBoundsOfWildcard -): Unit { - // jspecify_nullness_mismatch - b.superAsIs(aAnyNotNullNotNullNotNull) - // jspecify_nullness_mismatch - b.superAsIs(aAnyNotNullNotNullNull) - b.superAsIs(aAnyNotNullNullNotNull) - b.superAsIs(aAnyNotNullNullNull) - - b.superNotNull(aAnyNotNullNotNullNotNull) - b.superNotNull(aAnyNotNullNotNullNull) - b.superNotNull(aAnyNotNullNullNotNull) - b.superNotNull(aAnyNotNullNullNull) - - // jspecify_nullness_mismatch - b.superNullable(aAnyNotNullNotNullNotNull) - // jspecify_nullness_mismatch - b.superNullable(aAnyNotNullNotNullNull) - // jspecify_nullness_mismatch - b.superNullable(aAnyNotNullNullNotNull) - // jspecify_nullness_mismatch - b.superNullable(aAnyNotNullNullNull) - - b.extendsAsIs(aNotNullNotNullNotNull) - b.extendsAsIs(aNotNullNotNullNull) - b.extendsAsIs(aNotNullNullNotNull) - b.extendsAsIs(aNotNullNullNull) - - b.extendsNotNull(aNotNullNotNullNotNull) - // jspecify_nullness_mismatch - b.extendsNotNull(aNotNullNotNullNull) - // jspecify_nullness_mismatch - b.extendsNotNull(aNotNullNullNotNull) - // jspecify_nullness_mismatch - b.extendsNotNull(aNotNullNullNull) - - b.extendsNullable(aNotNullNotNullNotNull) - b.extendsNullable(aNotNullNotNullNull) - b.extendsNullable(aNotNullNullNotNull) - b.extendsNullable(aNotNullNullNull) - - b.noBounds(aNotNullNotNullNotNull) - b.noBounds(aNotNullNotNullNull) - b.noBounds(aNotNullNullNotNull) - b.noBounds(aNotNullNullNull) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/AnnotatedBoundsOfWildcard.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/AnnotatedBoundsOfWildcard.kt index 7c214c08363..697eacac7c3 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/AnnotatedBoundsOfWildcard.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/AnnotatedBoundsOfWildcard.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // MUTE_FOR_PSI_CLASS_FILES_READING diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Defaults.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Defaults.fir.kt deleted file mode 100644 index 048ce9e372a..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Defaults.fir.kt +++ /dev/null @@ -1,50 +0,0 @@ -// JSPECIFY_STATE: warn - -// FILE: Defaults.java -import org.jspecify.nullness.*; - -@NullMarked -public class Defaults { - public Foo defaultField = null; - @Nullable public Foo field = null; - - public Foo everythingNotNullable(Foo x) { return null; } - - public @Nullable Foo everythingNullable(@Nullable Foo x) { return null; } - - public @NullnessUnspecified Foo everythingUnknown(@NullnessUnspecified Foo x) { return null; } - - public @Nullable Foo mixed(Foo x) { return null; } - - public Foo explicitlyNullnessUnspecified(@NullnessUnspecified Foo x) { return null; } -} - -// FILE: Foo.java -public class Foo { - public Object foo() { return null; } -} - -// FILE: main.kt -fun main(a: Defaults, x: Foo): Unit { - // jspecify_nullness_mismatch - a.everythingNotNullable(null).foo() - a.everythingNotNullable(x).foo() - - // jspecify_nullness_mismatch - a.everythingNullable(null).foo() - - a.everythingUnknown(null).foo() - - // jspecify_nullness_mismatch, jspecify_nullness_mismatch - a.mixed(null).foo() - // jspecify_nullness_mismatch - a.mixed(x).foo() - - a.explicitlyNullnessUnspecified(x).foo() - a.explicitlyNullnessUnspecified(null).foo() - - a.defaultField.foo() - - // jspecify_nullness_mismatch - a.field.foo() -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Defaults.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Defaults.kt index e58ffb39fed..52b48106d59 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Defaults.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Defaults.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // FILE: Defaults.java diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/IgnoreAnnotations.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/IgnoreAnnotations.fir.kt deleted file mode 100644 index a6a9dc22713..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/IgnoreAnnotations.fir.kt +++ /dev/null @@ -1,48 +0,0 @@ -// JSPECIFY_STATE: warn - -// FILE: IgnoreAnnotations.java -import org.jspecify.nullness.*; - -@NullMarked -public class IgnoreAnnotations { - @Nullable public Derived field = null; - - @Nullable - public Derived foo(Derived x, @NullnessUnspecified Base y) { - return null; - } - - public Derived everythingNotNullable(Derived x) { return null; } - - public @Nullable Derived everythingNullable(@Nullable Derived x) { return null; } - - public @NullnessUnspecified Derived everythingUnknown(@NullnessUnspecified Derived x) { return null; } -} - -// FILE: Base.java -public class Base { - void foo() {} -} - -// FILE: Derived.java -public class Derived extends Base { } - -// FILE: main.kt -fun main(a: IgnoreAnnotations, x: Derived): Unit { - // jspecify_nullness_mismatch - a.foo(x, null).foo() - // jspecify_nullness_mismatch, jspecify_nullness_mismatch - a.foo(null, x).foo() - - // jspecify_nullness_mismatch - a.field.foo() - - // jspecify_nullness_mismatch - a.everythingNotNullable(null).foo() - a.everythingNotNullable(x).foo() - - // jspecify_nullness_mismatch - a.everythingNullable(null).foo() - - a.everythingUnknown(null).foo() -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/IgnoreAnnotations.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/IgnoreAnnotations.kt index 1b4442ffe0b..ce40656220c 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/IgnoreAnnotations.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/IgnoreAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // FILE: IgnoreAnnotations.java diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/NullnessUnspecifiedTypeParameter.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/NullnessUnspecifiedTypeParameter.fir.kt index 503a57efe22..04c42247af6 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/NullnessUnspecifiedTypeParameter.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/NullnessUnspecifiedTypeParameter.fir.kt @@ -16,7 +16,7 @@ public class Test {} // jspecify_nullness_mismatch fun main(a1: NullnessUnspecifiedTypeParameter, a2: NullnessUnspecifiedTypeParameter, x: Test): Unit { // jspecify_nullness_mismatch - a1.foo(null) + a1.foo(null) a1.foo(1) // jspecify_nullness_mismatch @@ -24,13 +24,13 @@ fun main(a1: NullnessUnspecifiedTypeParameter, a2: NullnessUnspecifiedTypeP a2.foo(1) // jspecify_nullness_mismatch, jspecify_nullness_mismatch - a1.bar(null, null) + a1.bar(null, null) // jspecify_nullness_mismatch - a1.bar(x, null) + a1.bar(x, null) a1.bar(x, 1) // jspecify_nullness_mismatch, jspecify_nullness_mismatch - a2.bar(null, null) + a2.bar(null, null) // jspecify_nullness_mismatch a2.bar(x, null) a2.bar(x, 1) diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Simple.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Simple.fir.kt deleted file mode 100644 index c1b530787af..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Simple.fir.kt +++ /dev/null @@ -1,39 +0,0 @@ -// JSPECIFY_STATE: warn - -// FILE: Simple.java -import org.jspecify.nullness.*; - -@NullMarked -public class Simple { - @Nullable public Derived field = null; - - @Nullable - public Derived foo(Derived x, @NullnessUnspecified Base y) { - return null; - } - - public Derived bar() { - return null; - } -} - -// FILE: Base.java -public class Base {} - -// FILE: Derived.java -public class Derived extends Base { - void foo() {} -} - -// FILE: main.kt -fun main(a: Simple, x: Derived): Unit { - // jspecify_nullness_mismatch - a.foo(x, null).foo() - // jspecify_nullness_mismatch, jspecify_nullness_mismatch - a.foo(null, x).foo() - - a.bar().foo() - - // jspecify_nullness_mismatch - a.field.foo() -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Simple.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Simple.kt index 5a73770c3d6..5f6967571de 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Simple.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/Simple.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // FILE: Simple.java diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/TypeArgumentsFromParameterBounds.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/TypeArgumentsFromParameterBounds.fir.kt deleted file mode 100644 index a91a719fc55..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/TypeArgumentsFromParameterBounds.fir.kt +++ /dev/null @@ -1,48 +0,0 @@ -// JSPECIFY_STATE: warn -// MUTE_FOR_PSI_CLASS_FILES_READING - -// FILE: TypeArgumentsFromParameterBounds.java -import org.jspecify.nullness.*; - -@NullMarked -public class TypeArgumentsFromParameterBounds {} - -// FILE: A.java -import org.jspecify.nullness.*; - -@NullMarked -public class A { - public void bar(TypeArgumentsFromParameterBounds a) {} -} - -// FILE: B.java -import org.jspecify.nullness.*; - -public class B { - public void bar(TypeArgumentsFromParameterBounds a) {} -} - -// FILE: Test.java -public class Test {} - -// FILE: main.kt -fun main( - aNotNullNotNullNotNull: TypeArgumentsFromParameterBounds, - aNotNullNotNullNull: TypeArgumentsFromParameterBounds, - aNotNullNullNotNull: TypeArgumentsFromParameterBounds, - aNotNullNullNull: TypeArgumentsFromParameterBounds, - a: A, b: B -): Unit { - a.bar(aNotNullNotNullNotNull) - // jspecify_nullness_mismatch - a.bar(aNotNullNotNullNull) - // jspecify_nullness_mismatch - a.bar(aNotNullNullNotNull) - // jspecify_nullness_mismatch - a.bar(aNotNullNullNull) - - b.bar(aNotNullNotNullNotNull) - b.bar(aNotNullNotNullNull) - b.bar(aNotNullNullNotNull) - b.bar(aNotNullNullNull) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/TypeArgumentsFromParameterBounds.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/TypeArgumentsFromParameterBounds.kt index 662f411c049..18fecabfc4e 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/TypeArgumentsFromParameterBounds.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/TypeArgumentsFromParameterBounds.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSPECIFY_STATE: warn // MUTE_FOR_PSI_CLASS_FILES_READING diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/TypeParameterBounds.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/TypeParameterBounds.fir.kt index ba8e8581c16..53164eda7d9 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/TypeParameterBounds.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/TypeParameterBounds.fir.kt @@ -39,7 +39,7 @@ fun main(a1: A, a2: A, b1: B, b2: B, x: T): U b1.bar(x) // jspecify_nullness_mismatch - b2.foo(null) + b2.foo(null) // jspecify_nullness_mismatch b2.bar(null) b2.bar(x) diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/UnannotatedWildcard.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/UnannotatedWildcard.fir.kt new file mode 100644 index 00000000000..9c5f706ce9f --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/UnannotatedWildcard.fir.kt @@ -0,0 +1,16 @@ +// JSPECIFY_STATE: warn +// FILE: J1.java +import org.jspecify.nullness.*; + +@NullMarked +public interface J1 { + T foo(); +} + +// FILE: J2.java +public interface J2 { + J1 bar(); +} + +// FILE: main.kt +fun baz(j2: J2): Any = j2.bar().foo() // Any..Any? diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/UnannotatedWildcard.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/UnannotatedWildcard.kt index 6344ec52ed3..e41b1397c21 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/UnannotatedWildcard.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecifyOld/warnMode/UnannotatedWildcard.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // JSPECIFY_STATE: warn // FILE: J1.java import org.jspecify.nullness.*; diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/androidRecently.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/androidRecently.fir.kt index 5aab99e6885..14b1e5390fc 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/androidRecently.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/androidRecently.fir.kt @@ -26,21 +26,21 @@ public class A { // FILE: main.kt fun main(a: A, a1: A) { a.foo("", null)?.length - a.foo("", null).length - a.foo(null, "").length + a.foo("", null).length + a.foo(null, "").length a.bar().length a.bar()!!.length a.field?.length - a.field.length + a.field.length - a.baz("").length + a.baz("").length a.baz("")?.length - a.baz(null).length + a.baz(null).length a1.baz("")!!.length - a1.baz(null)!!.length + a1.baz(null)!!.length a.baz2("").length a.baz2("")?.length diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.fir.kt index 2c29c0c3da9..4b5d55907f2 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.fir.kt @@ -18,7 +18,7 @@ public class ClassWithExternalAnnotatedMembers { // FILE: usage.kt fun test() { val i: Int? = null - ClassWithExternalAnnotatedMembers(i) + ClassWithExternalAnnotatedMembers(i) val s: String? = null ClassWithExternalAnnotatedMembers(s) diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.fir.kt index db20cb23d2f..f612efa4a3b 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.fir.kt @@ -14,7 +14,7 @@ public class ClassWithExternalAnnotatedMembers { // FILE: usage.kt fun test() { val i: Int? = null - ClassWithExternalAnnotatedMembers(i) + ClassWithExternalAnnotatedMembers(i) val s: String? = null ClassWithExternalAnnotatedMembers(s) @@ -22,7 +22,7 @@ fun test() { val b: Boolean? = null ClassWithExternalAnnotatedMembers(b) - ClassWithExternalAnnotatedMembers(null) + ClassWithExternalAnnotatedMembers(null) } // FILE: annotations.xml diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.fir.kt index 675345d4054..73586090c82 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.fir.kt @@ -16,12 +16,12 @@ fun test() { instance.method(i) val s: String? = null - instance.method(s) + instance.method(s) val b: Boolean? = null instance.method(b) - instance.method(null) + instance.method(null) } // FILE: annotations.xml diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.fir.kt index ac5f9cc2816..4d86849428a 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.fir.kt @@ -19,7 +19,7 @@ fun test() { instance.method(i) val s: String? = null - instance.method(s) + instance.method(s) val b: Boolean? = null instance.method(b) diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/expressionBodiedFunction.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/expressionBodiedFunction.kt new file mode 100644 index 00000000000..28280e9955f --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/expressionBodiedFunction.kt @@ -0,0 +1,15 @@ +// FIR_IDENTICAL +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// JSR305_GLOBAL_REPORT: warn + +// FILE: A.java +public class A { + public static @MyNullable String bar() { + return null; + } +} + +// FILE: main.kt +fun foo1(): String = A.bar() +fun foo2(): String? = A.bar() +fun foo3() = A.bar() diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.fir.kt index 1859cef38fa..eaf11c82f16 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.fir.kt @@ -10,40 +10,40 @@ public class J { } // FILE: k.kt -fun test() { - var platformNN = J.staticNN - var platformN = J.staticN - var platformJ = J.staticJ +var platformNN = J.staticNN +var platformN = J.staticN +var platformJ = J.staticJ +fun test() { +platformNN - +platformN + +platformN +platformJ ++platformNN - ++platformN + ++platformN ++platformJ platformNN++ - platformN++ + platformN++ platformJ++ 1 + platformNN - 1 + platformN + 1 + platformN 1 + platformJ platformNN + 1 - platformN + 1 + platformN + 1 platformJ + 1 1 plus platformNN - 1 plus platformN + 1 plus platformN 1 plus platformJ platformNN plus 1 - platformN plus 1 + platformN plus 1 platformJ plus 1 platformNN += 1 - platformN += 1 + platformN += 1 platformJ += 1 } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.kt index f9a999be37f..cb089c18cc7 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.kt @@ -10,11 +10,11 @@ public class J { } // FILE: k.kt -fun test() { - var platformNN = J.staticNN - var platformN = J.staticN - var platformJ = J.staticJ +var platformNN = J.staticNN +var platformN = J.staticN +var platformJ = J.staticJ +fun test() { +platformNN +platformN +platformJ diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.txt index 75d9fc8d51d..a843fed4bf6 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.txt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/arithmetic.txt @@ -1,5 +1,8 @@ package +public var platformJ: kotlin.Int! +public var platformN: kotlin.Int! +public var platformNN: kotlin.Int! public fun test(): kotlin.Unit public open class J { diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.fir.kt deleted file mode 100644 index f506b6731ef..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.fir.kt +++ /dev/null @@ -1,25 +0,0 @@ -// JSR305_GLOBAL_REPORT: warn - -// FILE: J.java -public class J { - @MyNonnull - public static Integer[] staticNN; - @MyNullable - public static Integer[] staticN; - public static Integer[] staticJ; -} - -// FILE: k.kt -fun test() { - val platformNN = J.staticNN - val platformN = J.staticN - val platformJ = J.staticJ - - platformNN[0] - platformN[0] - platformJ[0] - - platformNN[0] = 1 - platformN[0] = 1 - platformJ[0] = 1 -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.kt index 916c22e9a71..16749d7f4b0 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/array.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSR305_GLOBAL_REPORT: warn // FILE: J.java diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.fir.kt deleted file mode 100644 index 387d548304f..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.fir.kt +++ /dev/null @@ -1,24 +0,0 @@ -// JSR305_GLOBAL_REPORT: warn - -// FILE: J.java -public class J { - @MyNonnull - public static J staticNN; - @MyNullable - public static J staticN; - public static J staticJ; -} - -// FILE: k.kt -var v: J = J() -var n: J? = J() - -fun test() { - v = J.staticNN - v = J.staticN - v = J.staticJ - - n = J.staticNN - n = J.staticN - n = J.staticJ -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.kt index 637c7d11b02..f971e4f7644 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/assignToVar.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSR305_GLOBAL_REPORT: warn // FILE: J.java diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/conditions.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/conditions.fir.kt index 4d13b2b227b..7f07abbbe1f 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/conditions.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/conditions.fir.kt @@ -17,26 +17,26 @@ fun test() { val platformJ = J.staticJ if (platformNN) {} - if (platformN) {} + if (platformN) {} if (platformJ) {} while (platformNN) {} - while (platformN) {} + while (platformN) {} while (platformJ) {} do {} while (platformNN) - do {} while (platformN) + do {} while (platformN) do {} while (platformJ) platformNN && false - platformN && false + platformN && false platformJ && false platformNN || false - platformN || false + platformN || false platformJ || false !platformNN - !platformN + !platformN !platformJ } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.fir.kt deleted file mode 100644 index 6d4fae5a67b..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.fir.kt +++ /dev/null @@ -1,29 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -// JSR305_GLOBAL_REPORT: warn - -// FILE: J.java -public class J { - @MyNonnull - public static J staticNN; - @MyNullable - public static J staticN; -} - -// FILE: k.kt -fun test() { - val n = J.staticN - foo(n) - J.staticNN = n - if (n != null) { - foo(n) - J.staticNN = n - } - - val x: J? = null - J.staticNN = x - if (x != null) { - J.staticNN = x - } -} - -fun foo(j: J) {} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt index e0c7fb49245..af7a8199cea 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/dataFlowInfo.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER // JSR305_GLOBAL_REPORT: warn diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.fir.kt deleted file mode 100644 index 7fd62ba0c5a..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.fir.kt +++ /dev/null @@ -1,22 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -// JSR305_GLOBAL_REPORT: warn - -// FILE: J.java -public class J { - @MyNonnull - public static J staticNN; - @MyNullable - public static J staticN; - public static J staticJ; -} - -// FILE: k.kt -fun test() { - val platformNN = J.staticNN - val platformN = J.staticN - val platformJ = J.staticJ - - fun foo(p: J = platformNN, p1: J = platformN, p2: J = platformJ) {} - - fun foo1(p: J? = platformNN, p1: J? = platformN, p2: J? = platformJ) {} -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.kt index b2a5ad9e675..a932b7c7a65 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/defaultParameters.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER // JSR305_GLOBAL_REPORT: warn diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.fir.kt deleted file mode 100644 index d02f5ceee7c..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.fir.kt +++ /dev/null @@ -1,21 +0,0 @@ -// JSR305_GLOBAL_REPORT: warn - -// FILE: J.java -public class J { - - public interface DP { - String getValue(Object a, Object b); - String setValue(Object a, Object b, Object c); - } - - @MyNonnull - public static DP staticNN; - @MyNullable - public static DP staticN; - public static DP staticJ; -} - -// FILE: k.kt -var A by J.staticNN -var B by J.staticN -var C by J.staticJ diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.kt index 9c9b22490a6..c60c6e0e585 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/delegatedProperties.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSR305_GLOBAL_REPORT: warn // FILE: J.java diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceExtension.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceExtension.fir.kt index 6e2470fc866..972d7bf1b16 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceExtension.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceExtension.fir.kt @@ -17,14 +17,14 @@ fun test() { val platformJ = J.staticJ platformNN.foo() - platformN.foo() + platformN.foo() platformJ.foo() with(platformNN) { foo() } with(platformN) { - foo() + foo() } with(platformJ) { foo() diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceMember.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceMember.fir.kt index 17be65d281b..7d77c5f20ca 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceMember.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/derefenceMember.fir.kt @@ -22,14 +22,14 @@ fun test() { val platformJ = J.staticJ platformNN.foo() - platformN.foo() + platformN.foo() platformJ.foo() with(platformNN) { foo() } with(platformN) { - foo() + foo() } with(platformJ) { foo() diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.fir.kt deleted file mode 100644 index 41e897829f1..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.fir.kt +++ /dev/null @@ -1,26 +0,0 @@ -// !CHECK_TYPE -// JSR305_GLOBAL_REPORT: warn - -// FILE: J.java -public class J { - @MyNonnull - public static J staticNN; - @MyNullable - public static J staticN; - public static J staticJ; -} - -// FILE: k.kt -fun test() { - val platformNN = J.staticNN - val platformN = J.staticN - val platformJ = J.staticJ - - checkSubtype(platformNN) - checkSubtype(platformN) - checkSubtype(platformJ) - - checkSubtype(platformNN) - checkSubtype(platformN) - checkSubtype(platformJ) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.kt index 9d83d843259..9d4b46ef923 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/expectedType.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !CHECK_TYPE // JSR305_GLOBAL_REPORT: warn diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.fir.kt deleted file mode 100644 index d031995c909..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.fir.kt +++ /dev/null @@ -1,23 +0,0 @@ -// JSR305_GLOBAL_REPORT: warn - -// FILE: J.java -import java.util.*; - -public class J { - @MyNonnull - public static List staticNN; - @MyNullable - public static List staticN; - public static List staticJ; -} - -// FILE: k.kt -fun test() { - val platformNN = J.staticNN - val platformN = J.staticN - val platformJ = J.staticJ - - for (x in platformNN) {} - for (x in platformN) {} - for (x in platformJ) {} -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.kt index f214375d99e..9a9d9016d0e 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/for.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSR305_GLOBAL_REPORT: warn // FILE: J.java diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.fir.kt index 410b565cdae..179c487a2a0 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.fir.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER +// LANGUAGE: +ContextReceivers // JSR305_GLOBAL_REPORT: warn // FILE: J.java @@ -13,13 +14,23 @@ public class J { // FILE: k.kt fun test() { foo(J.staticNN) - foo(J.staticN) + foo(J.staticN) foo(J.staticJ) bar(J.staticNN) bar(J.staticN) bar(J.staticJ) + + with(J.staticNN) { baz() } + with(J.staticN) { baz() } + with(J.staticJ) { baz() } + + with(J.staticNN) { qux() } + with(J.staticN) { qux() } + with(J.staticJ) { qux() } } fun foo(j: J) {} fun bar(j: J?) {} +context(J) fun baz() {} +context(J?) fun qux() {} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.kt index a069f2308a3..777dce27ae5 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER +// LANGUAGE: +ContextReceivers // JSR305_GLOBAL_REPORT: warn // FILE: J.java @@ -19,7 +20,17 @@ fun test() { bar(J.staticNN) bar(J.staticN) bar(J.staticJ) + + with(J.staticNN) { baz() } + with(J.staticN) { baz() } + with(J.staticJ) { baz() } + + with(J.staticNN) { qux() } + with(J.staticN) { qux() } + with(J.staticJ) { qux() } } fun foo(j: J) {} fun bar(j: J?) {} +context(J) fun baz() {} +context(J?) fun qux() {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.txt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.txt index 5eb01e5c6a9..e4efe37bfee 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.txt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/functionArguments.txt @@ -1,7 +1,9 @@ package public fun bar(/*0*/ j: J?): kotlin.Unit +context(J) public fun baz(): kotlin.Unit public fun foo(/*0*/ j: J): kotlin.Unit +context(J?) public fun qux(): kotlin.Unit public fun test(): kotlin.Unit public open class J { diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.fir.kt deleted file mode 100644 index d053d428cb3..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.fir.kt +++ /dev/null @@ -1,21 +0,0 @@ -// JSR305_GLOBAL_REPORT: warn - -// FILE: J.java -public class J { - public interface Invoke { - void invoke(); - } - - @MyNonnull - public static Invoke staticNN; - @MyNullable - public static Invoke staticN; - public static Invoke staticJ; -} - -// FILE: k.kt -fun test() { - J.staticNN() - J.staticN() - J.staticJ() -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.kt index fae92d9ccc8..4f9552a0f2b 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/invoke.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSR305_GLOBAL_REPORT: warn // FILE: J.java diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.fir.kt deleted file mode 100644 index 93b8678ff4e..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.fir.kt +++ /dev/null @@ -1,21 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -// JSR305_GLOBAL_REPORT: warn - -// KT-6829 False warning on map to @Nullable - -// FILE: J.java -public class J { - - @MyNullable - public String method() { return ""; } -} - -// FILE: k.kt -fun foo(collection: Collection) { - val mapped = collection.map { it.method() } - mapped[0].length -} - -public fun Iterable.map(transform: (T) -> R): List { - null!! -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.kt index c43870db728..6c13b4bf3b3 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/kt6829.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER // JSR305_GLOBAL_REPORT: warn diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/multiDeclaration.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/multiDeclaration.fir.kt index 7bfe6d6ea3f..94709506af2 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/multiDeclaration.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/multiDeclaration.fir.kt @@ -22,6 +22,6 @@ fun test() { val platformJ = J.staticJ val (a1, b1) = platformNN - val (a2, b2) = platformN + val (a2, b2) = platformN val (a3, b3) = platformJ } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.fir.kt deleted file mode 100644 index f143fc60b2b..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.fir.kt +++ /dev/null @@ -1,88 +0,0 @@ -// JSR305_GLOBAL_REPORT: warn - -// FILE: J.java - -public class J { - @MyNonnull - public static J staticNN; - @MyNullable - public static J staticN; - public static J staticJ; - - public static void staticSet(@MyNonnull J nn, @MyNullable J n, J j) {} - - public J(@MyNonnull J nn, @MyNullable J n, J j) {} - public J() {} - - @MyNonnull - public J nn; - @MyNullable - public J n; - public J j; - - public void set(@MyNonnull J nn, @MyNullable J n, J j) {} -} - -// FILE: k.kt -fun test(n: J?, nn: J) { - // @NotNull platform type - val platformNN = J.staticNN - // @Nullable platform type - val platformN = J.staticN - // platform type with no annotation - val platformJ = J.staticJ - - J.staticNN = n - J.staticNN = platformN - J.staticNN = nn - J.staticNN = platformNN - J.staticNN = platformJ - - J.staticN = n - J.staticN = platformN - J.staticN = nn - J.staticN = platformNN - J.staticN = platformJ - - J.staticJ = n - J.staticJ = platformN - J.staticJ = nn - J.staticJ = platformNN - J.staticJ = platformJ - - J.staticSet(nn, nn, nn) - J.staticSet(platformNN, platformNN, platformNN) - J.staticSet(n, n, n) - J.staticSet(platformN, platformN, platformN) - J.staticSet(platformJ, platformJ, platformJ) - - J().nn = n - J().nn = platformN - J().nn = nn - J().nn = platformNN - J().nn = platformJ - - J().n = n - J().n = platformN - J().n = nn - J().n = platformNN - J().n = platformJ - - J().j = n - J().j = platformN - J().j = nn - J().j = platformNN - J().j = platformJ - - J().set(nn, nn, nn) - J().set(platformNN, platformNN, platformNN) - J().set(n, n, n) - J().set(platformN, platformN, platformN) - J().set(platformJ, platformJ, platformJ) - - J(nn, nn, nn) - J(platformNN, platformNN, platformNN) - J(n, n, n) - J(platformN, platformN, platformN) - J(platformJ, platformJ, platformJ) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.kt index 8701e20d510..7ef5520afd5 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/passToJava.kt @@ -1,3 +1,5 @@ +// FIR_IDENTICAL +// WITH_STDLIB // JSR305_GLOBAL_REPORT: warn // FILE: J.java @@ -37,18 +39,39 @@ fun test(n: J?, nn: J) { J.staticNN = nn J.staticNN = platformNN J.staticNN = platformJ + J.staticNN = null + J.staticNN = requireNotNull(J.staticNN) + J.staticNN = requireNotNull(J.staticN) + J.staticNN = requireNotNull(J.staticJ) + J.staticNN = J.staticNN as J + J.staticNN = J.staticN as J + J.staticNN = J.staticJ as J J.staticN = n J.staticN = platformN J.staticN = nn J.staticN = platformNN J.staticN = platformJ + J.staticN = null + J.staticN = requireNotNull(J.staticNN) + J.staticN = requireNotNull(J.staticN) + J.staticN = requireNotNull(J.staticJ) + J.staticN = J.staticNN as J + J.staticN = J.staticN as J + J.staticN = J.staticJ as J J.staticJ = n J.staticJ = platformN J.staticJ = nn J.staticJ = platformNN J.staticJ = platformJ + J.staticJ = null + J.staticJ = requireNotNull(J.staticNN) + J.staticJ = requireNotNull(J.staticN) + J.staticJ = requireNotNull(J.staticJ) + J.staticJ = J.staticNN as J + J.staticJ = J.staticN as J + J.staticJ = J.staticJ as J J.staticSet(nn, nn, nn) J.staticSet(platformNN, platformNN, platformNN) diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.fir.kt deleted file mode 100644 index d37b90b100d..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.fir.kt +++ /dev/null @@ -1,25 +0,0 @@ -// JSR305_GLOBAL_REPORT: warn - -// FILE: J.java -public class J { - @MyNonnull - public static int[] staticNN; - @MyNullable - public static int[] staticN; - public static int[] staticJ; -} - -// FILE: k.kt -fun test() { - val platformNN = J.staticNN - val platformN = J.staticN - val platformJ = J.staticJ - - platformNN[0] - platformN[0] - platformJ[0] - - platformNN[0] = 1 - platformN[0] = 1 - platformJ[0] = 1 -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.kt index d54a562fb51..6304a8f659d 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/primitiveArray.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSR305_GLOBAL_REPORT: warn // FILE: J.java diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.fir.kt deleted file mode 100644 index ebdc43874c4..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.fir.kt +++ /dev/null @@ -1,23 +0,0 @@ -// JSR305_GLOBAL_REPORT: warn - -// FILE: J.java -public class J { - @MyNonnull - public static Exception staticNN; - @MyNullable - public static Exception staticN; - public static Exception staticJ; -} - -// FILE: k.kt -fun test() { - throw J.staticNN -} - -fun test1() { - throw J.staticN -} - -fun test2() { - throw J.staticJ -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.kt index d67bd4792d3..76aba62b30c 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/fromPlatformTypes/throw.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JSR305_GLOBAL_REPORT: warn // FILE: J.java diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/nullabilityGenerics.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/nullabilityGenerics.fir.kt deleted file mode 100644 index 4d3ce1a127e..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/nullabilityGenerics.fir.kt +++ /dev/null @@ -1,40 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// JSR305_GLOBAL_REPORT: warn - -// FILE: A.java -public class A { - public void foo(@MyNonnull T t) { - } - - public @MyNullable String bar() { - return null; - } - - public @MyNullable T bam() { - return null; - } - - @MyNullable - public X baz() { - return null; - } - -} -// FILE: main.kt -class X(t: T?) { - - init { - val a = A() - a.foo(t) - - val x: T = a.bam() - val y: T = a.baz() - } -} - -fun test() { - val a = A() - a.foo(null) - - val b: String = a.bar() -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/nullabilityGenerics.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/nullabilityGenerics.kt index cd6104bfed8..c81a338a5f7 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/nullabilityGenerics.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/nullabilityGenerics.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER // JSR305_GLOBAL_REPORT: warn diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/nullabilityNicknames.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/nullabilityNicknames.fir.kt index 033472eb014..f12127ed57d 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/nullabilityNicknames.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/nullabilityNicknames.fir.kt @@ -77,15 +77,15 @@ public class A { // FILE: main.kt fun main(a: A) { a.foo("", null)?.length - a.foo("", null).length - a.foo(null, "").length + a.foo("", null).length + a.foo(null, "").length - a.baz("", null).length - a.baz(null, "").length + a.baz("", null).length + a.baz(null, "").length a.bar().length a.bar()!!.length a.field?.length - a.field.length + a.field.length } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.fir.kt deleted file mode 100644 index 8333fdb8429..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.fir.kt +++ /dev/null @@ -1,57 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// JSR305_GLOBAL_REPORT: warn - -// FILE: FieldsAreNullable.java -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import javax.annotation.Nonnull; -import javax.annotation.CheckForNull; -import javax.annotation.meta.TypeQualifierDefault; - -@Retention(RetentionPolicy.RUNTIME) -@Documented -@CheckForNull -@TypeQualifierDefault({ElementType.FIELD}) -public @interface FieldsAreNullable { -} - -// FILE: A.java -import javax.annotation.*; - -@FieldsAreNullable -public class A { - public String field = null; - @Nonnull - public String nonNullField = ""; - - public String foo(String q, @Nonnull String x, @CheckForNull CharSequence y) { - return ""; - } - - @Nonnull - public String bar() { - return ""; - } -} - -// FILE: main.kt -fun main(a: A) { - // foo is platform - a.foo("", "", null)?.length - a.foo("", "", null).length - a.foo(null, null, "").length - - a.bar().length - a.bar()!!.length - - a.field?.length - a.field.length - a.field = null - - a.nonNullField?.length - a.nonNullField.length - a.nonNullField = null -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt index 07d898d2dde..0a2efcc0d9c 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/fieldsAreNullable.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER // JSR305_GLOBAL_REPORT: warn diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.fir.kt index 477a87b5154..afdbdfeabd8 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/nullabilityFromOverridden.fir.kt @@ -126,25 +126,25 @@ public class C extends A implements AInt { // FILE: main.kt fun main(a: A, b: B, c: C) { - a.foo1(null).length - a.foo2(null).length - a.foo3(null).length + a.foo1(null).length + a.foo2(null).length + a.foo3(null).length a.bar1(null).length a.bar2(null).length a.baz(null).length - b.foo1(null).length + b.foo1(null).length b.foo1(null)?.length b.foo2(null).length - b.foo3(null).length + b.foo3(null).length b.bar1(null).length b.bar2(null).length - b.baz(null).length + b.baz(null).length b.baz(null)?.length - c.foo1(null).length + c.foo1(null).length c.foo2(null).length - c.foo3(null).length + c.foo3(null).length c.bar1(null).length c.bar1(null)?.length c.bar2(null).length diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.fir.kt index b0fd01e7701..121185203ee 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/overridingDefaultQualifier.fir.kt @@ -128,9 +128,9 @@ public class A { fun main(a: A, b: A.B, c: A.C) { a.foo("", null)?.length a.foo("", null).length - a.foo(null, "").length + a.foo(null, "").length - a.foobar(null, "").length + a.foobar(null, "").length a.foobar("", null)?.length a.bar().length @@ -145,17 +145,17 @@ fun main(a: A, b: A.B, c: A.C) { // b b.foo("", null)?.length - b.foo("", null).length - b.foo(null, "").length + b.foo("", null).length + b.foo(null, "").length - b.foobar(null, "").length + b.foobar(null, "").length b.foobar("", null)?.length - b.bar().length + b.bar().length b.bar()!!.length b.field?.length - b.field.length + b.field.length b.baz().get(0) b.baz()!!.get(0).get(0) @@ -164,16 +164,16 @@ fun main(a: A, b: A.B, c: A.C) { // c c.foo("", null)?.length c.foo("", null).length - c.foo(null, "").length + c.foo(null, "").length - c.foobar(null, "").length + c.foobar(null, "").length c.foobar("", null)?.length c.bar().length c.bar()!!.length c.field?.length - c.field.length + c.field.length c.baz().get(0) c.baz()!!.get(0).get(0) diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.fir.kt deleted file mode 100644 index 0ebff68f8f0..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.fir.kt +++ /dev/null @@ -1,33 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// JSR305_GLOBAL_REPORT: warn - -// FILE: A.java -import javax.annotation.*; - -@ParametersAreNonnullByDefault -public class A { - @Nullable public String field = null; - - public String foo(String q, @Nonnull String x, @CheckForNull CharSequence y) { - return ""; - } - - @Nonnull - public String bar() { - return ""; - } -} - -// FILE: main.kt -fun main(a: A) { - // foo is platform - a.foo("", "", null)?.length - a.foo("", "", null).length - a.foo(null, null, "").length - - a.bar().length - a.bar()!!.length - - a.field?.length - a.field.length -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt index 00aa8b0446c..3437e93b0f6 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefault.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER // JSR305_GLOBAL_REPORT: warn diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.fir.kt deleted file mode 100644 index 945094b559b..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.fir.kt +++ /dev/null @@ -1,68 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// JSR305_GLOBAL_REPORT: warn - -// FILE: test/package-info.java -@javax.annotation.ParametersAreNonnullByDefault() -package test; - -// FILE: test/A.java -package test; - -import javax.annotation.*; - -public class A { - @Nullable public String field = null; - - public String foo(String q, @Nonnull String x, @CheckForNull CharSequence y) { - return ""; - } - - @Nonnull - public String bar() { - return ""; - } -} - -// FILE: test2/A2.java -package test2; - -import javax.annotation.*; - -public class A2 { - @Nullable public String field = null; - - public String foo(String q, @Nonnull String x, @CheckForNull CharSequence y) { - return ""; - } - - @Nonnull - public String bar() { - return ""; - } -} - -// FILE: main.kt -import test.A -import test2.A2 - -fun main(a: A, a2: A2) { - a.foo("", "", null)?.length - a.foo("", "", null).length - a.foo(null, null, "").length - - a.bar().length - a.bar()!!.length - - a.field?.length - a.field.length - - a2.foo("", "", null)?.length - a2.foo("", "", null).length - a2.foo(null, null, "").length - - a2.bar().length - a2.bar()!!.length - - a2.field?.length - a2.field.length -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt index 8441f0547aa..b28b5d6b536 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/parametersAreNonnullByDefaultPackage.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER // JSR305_GLOBAL_REPORT: warn diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullable.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullable.fir.kt index 262a9a4af89..7738f6fc4db 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullable.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullable.fir.kt @@ -65,7 +65,7 @@ public class A { fun main(a: A) { a.foo("", null)?.length a.foo("", null).length - a.foo(null, "").length + a.foo(null, "").length a.bar().length a.bar()!!.length @@ -73,7 +73,7 @@ fun main(a: A) { a.field?.length a.field.length - a.baz().get(0) + a.baz().get(0) a.baz()!!.get(0).get(0) a.baz()!!.get(0)?.get(0) } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullablePackage.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullablePackage.fir.kt index 5d02aca963d..00433082151 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullablePackage.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/typeQualifierDefault/springNullablePackage.fir.kt @@ -70,7 +70,7 @@ public class A { fun main(a: test.A) { a.foo("", null)?.length a.foo("", null).length - a.foo(null, "").length + a.foo(null, "").length a.bar().length a.bar()!!.length @@ -78,7 +78,7 @@ fun main(a: test.A) { a.field?.length a.field.length - a.baz().get(0) + a.baz().get(0) a.baz()!!.get(0).get(0) a.baz()!!.get(0)?.get(0) } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/customMigration.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/customMigration.fir.kt deleted file mode 100644 index 7531e7fde42..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/customMigration.fir.kt +++ /dev/null @@ -1,82 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// JSR305_GLOBAL_REPORT: ignore - -// FILE: MyErrorNonnull.java -import javax.annotation.*; -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -import javax.annotation.meta.TypeQualifierNickname; -import javax.annotation.meta.When; - -import kotlin.annotations.jvm.*; - -@Documented -@TypeQualifierNickname -@Nonnull(when = When.ALWAYS) -@Retention(RetentionPolicy.RUNTIME) -@UnderMigration(status = MigrationStatus.STRICT) -public @interface MyErrorNonnull { -} - -// FILE: MyWarnNonnull.java -import javax.annotation.*; -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -import javax.annotation.meta.TypeQualifierNickname; -import javax.annotation.meta.When; - -import kotlin.annotations.jvm.*; - -@Documented -@TypeQualifierNickname -@Nonnull(when = When.ALWAYS) -@Retention(RetentionPolicy.RUNTIME) -@UnderMigration(status = MigrationStatus.WARN) -public @interface MyWarnNonnull { -} - -// FILE: MyIgnoreNonnull.java -import javax.annotation.*; -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -import javax.annotation.meta.TypeQualifierNickname; -import javax.annotation.meta.When; - -import kotlin.annotations.jvm.*; - -@Documented -@TypeQualifierNickname -@Nonnull(when = When.ALWAYS) -@Retention(RetentionPolicy.RUNTIME) -@UnderMigration(status = MigrationStatus.IGNORE) -public @interface MyIgnoreNonnull { -} - -// FILE: A.java -public class A { - public void foo(@MyErrorNonnull String bar) {} - public void foo2(@MyWarnNonnull String bar) {} - public void foo3(@MyIgnoreNonnull String bar) {} - public void foo4(@MyMigrationNonnull String bar) {} -} - -// FILE: main.kt -fun main(a: A) { - a.foo("") - a.foo(null) - - a.foo2("") - a.foo2(null) - - a.foo3("") - a.foo3(null) - - a.foo4("") - a.foo4(null) -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/customMigration.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/customMigration.kt index b7416335ba0..ad962c1fd58 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/customMigration.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/customMigration.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER // JSR305_GLOBAL_REPORT: ignore diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/globalIgnore.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/globalIgnore.fir.kt index d9ab359fb69..c48e2e91d4e 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/globalIgnore.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/globalIgnore.fir.kt @@ -45,7 +45,7 @@ fun main(a: A) { a.foo2("", null)?.length a.foo2("", null).length - a.foo2(null, "").length + a.foo2(null, "").length a.bar2().length a.bar2()!!.length diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.fir.kt index bf6cc8813de..227bac7591a 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/globalWarningMigrationIgnore.fir.kt @@ -45,7 +45,7 @@ fun main(a: A) { a.foo2("", null)?.length a.foo2("", null).length - a.foo2(null, "").length + a.foo2(null, "").length a.bar2().length a.bar2()!!.length diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationError.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationError.fir.kt deleted file mode 100644 index fd5065dc58a..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationError.fir.kt +++ /dev/null @@ -1,76 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// JSR305_GLOBAL_REPORT: warn -// JSR305_MIGRATION_REPORT: strict -// JSR305_SPECIAL_REPORT: MyNonnull:ignore, MySuperNull:strict - -// FILE: MySuperNull.java -import javax.annotation.*; -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -import javax.annotation.meta.TypeQualifierNickname; -import javax.annotation.meta.When; - -@Documented -@TypeQualifierNickname -@Nonnull(when = When.MAYBE) -@Retention(RetentionPolicy.RUNTIME) -public @interface MySuperNull { -} - -// FILE: A.java -import javax.annotation.*; - -public class A { - @MyMigrationNullable public String field = null; - - @MyMigrationNullable - public String foo(@MyMigrationNonnull String x, CharSequence y) { - return ""; - } - - @MyMigrationNonnull - public String bar() { - return ""; - } - - @MyNullable public String field2 = null; - @MyNullable - public String foo2(@MyNonnull String x, CharSequence y) { - return ""; - } - - @MyNonnull - public String bar2() { - return ""; - } - - @MySuperNull public String field3 = null; -} - -// FILE: main.kt -fun main(a: A) { - a.foo("", null)?.length - a.foo("", null).length - a.foo(null, "").length - - a.bar().length - a.bar()!!.length - - a.field?.length - a.field.length - - a.foo2("", null)?.length - a.foo2("", null).length - a.foo2(null, "").length - - a.bar2().length - a.bar2()!!.length - - a.field2?.length - a.field2.length - - a.field3?.length - a.field3.length -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationError.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationError.kt index 71f165528ec..d6756252feb 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationError.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationError.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER // JSR305_GLOBAL_REPORT: warn // JSR305_MIGRATION_REPORT: strict diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationIgnore.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationIgnore.fir.kt deleted file mode 100644 index b46e19b8323..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationIgnore.fir.kt +++ /dev/null @@ -1,55 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// JSR305_GLOBAL_REPORT: strict -// JSR305_MIGRATION_REPORT: ignore -// JSR305_SPECIAL_REPORT: MyNullable:warn, MyMigrationNonnull:strict - -// FILE: A.java -import javax.annotation.*; - -public class A { - @MyMigrationNullable public String field = null; - - @MyMigrationNullable - public String foo(@MyMigrationNonnull String x, CharSequence y) { - return ""; - } - - @MyMigrationNonnull - public String bar() { - return ""; - } - - @MyNullable public String field2 = null; - @MyNullable - public String foo2(@MyNonnull String x, CharSequence y) { - return ""; - } - - @MyNonnull - public String bar2() { - return ""; - } -} - -// FILE: main.kt -fun main(a: A) { - a.foo("", null)?.length - a.foo("", null).length - a.foo(null, "").length - - a.bar().length - a.bar()!!.length - - a.field?.length - a.field.length - - a.foo2("", null)?.length - a.foo2("", null).length - a.foo2(null, "").length - - a.bar2().length - a.bar2()!!.length - - a.field2?.length - a.field2.length -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationIgnore.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationIgnore.kt index ac7a9c5759e..f8fe51ac0bd 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationIgnore.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationIgnore.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER // JSR305_GLOBAL_REPORT: strict // JSR305_MIGRATION_REPORT: ignore diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationWarning.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationWarning.fir.kt index 08faaa927eb..94d01f1c05c 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationWarning.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/migrationWarning.fir.kt @@ -35,7 +35,7 @@ public class A { fun main(a: A) { a.foo("", null)?.length a.foo("", null).length - a.foo(null, "").length + a.foo(null, "").length a.bar().length a.bar()!!.length diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/overrideConflicts.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/overrideConflicts.fir.kt deleted file mode 100644 index b7d75134700..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/overrideConflicts.fir.kt +++ /dev/null @@ -1,85 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// JSR305_GLOBAL_REPORT: warn -// JSR305_MIGRATION_REPORT: strict - -// FILE: A.java -import javax.annotation.Nullable; -import javax.annotation.Nonnull; - -public class A { - @MyNullable - public String foo() { return ""; } - - @MyMigrationNullable - public String foo2() { return ""; } - - @Nullable - public String foo3() { return ""; } - - public String foo4() { return ""; } - - public void bar(@MyNonnull String baz) { } - - public void bar2(@MyMigrationNonnull String baz) { } - - public void bar3(@Nonnull String baz) {} - - public void bar4(String baz) {} -} - -// FILE: B.java -public class B extends A { - @MyMigrationNullable - public String foo() { return ""; } - - @MyNullable - public String foo2() { return ""; } - - @MyNullable - public String foo3() { return ""; } - - @MyNullable - public String foo4() { return ""; } - - public void bar(@MyMigrationNonnull String baz) { } - - public void bar2(@MyNonnull String baz) { } - - public void bar3(@MyNonnull String baz) {} - - public void bar4(@MyNonnull String baz) {} -} - -// FILE: C.java -public class C extends A { - @MyMigrationNullable - public String foo4() { return ""; } - - public void bar4(@MyMigrationNonnull String baz) {} -} - -// FILE: main.kt -fun main(b: B, c: C) { - b.foo().length - b.foo()?.length - b.foo2().length - b.foo2()?.length - b.foo3().length - b.foo3()?.length - b.foo4().length - b.foo4()?.length - - b.bar(null) - b.bar("") - b.bar2(null) - b.bar2("") - b.bar3(null) - b.bar3("") - b.bar4(null) - b.bar4("") - - c.foo4().length - c.foo4()?.length - c.bar4(null) - c.bar4("") -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/overrideConflicts.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/overrideConflicts.kt index e1f6c124fdb..f6d0e0b259a 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/overrideConflicts.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/overrideConflicts.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER // JSR305_GLOBAL_REPORT: warn // JSR305_MIGRATION_REPORT: strict diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/stateRefinement.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/stateRefinement.fir.kt index 98b1d57d269..371afcd13dd 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/stateRefinement.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305NullabilityWarnings/migration/stateRefinement.fir.kt @@ -34,14 +34,14 @@ public class A { // FILE: main.kt fun main(a: A) { a.foo("", null)?.length - a.foo("", null).length - a.foo(null, "").length + a.foo("", null).length + a.foo(null, "").length a.bar().length a.bar()!!.length a.field?.length - a.field.length + a.field.length a.foo2("", null)?.length a.foo2("", null).length diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/multiple.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/multiple.fir.kt index c8973214321..146886d22f1 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/multiple.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/multiple.fir.kt @@ -102,21 +102,21 @@ fun main1(a: A1, a1: A1) { fun main2(a: A2, a1: A2) { a.foo("", null)?.length - a.foo("", null).length - a.foo(null, "").length + a.foo("", null).length + a.foo(null, "").length a.bar().length a.bar()!!.length a.field?.length - a.field.length + a.field.length - a.baz("").length + a.baz("").length a.baz("")?.length - a.baz(null).length + a.baz(null).length a1.baz("")!!.length - a1.baz(null)!!.length + a1.baz(null)!!.length } fun main3(a: A3, a1: A3) { diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Default.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Default.fir.kt index 7c97f692a78..9abb5ae91ed 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Default.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Default.fir.kt @@ -23,19 +23,20 @@ public class A { fun main(a: A, a1: A) { a.foo("", null)?.length - a.foo("", null).length - a.foo(null, "").length + a.foo("", null).length + a.foo(null, "").length + a.foo("", null)!!.length a.bar().length a.bar()!!.length a.field?.length - a.field.length + a.field.length - a.baz("").length + a.baz("").length a.baz("")?.length - a.baz(null).length + a.baz(null).length a1.baz("")!!.length - a1.baz(null)!!.length + a1.baz(null)!!.length } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Default.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Default.kt index 8e3ffb12fc5..8ae5fcd845d 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Default.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Default.kt @@ -25,6 +25,7 @@ fun main(a: A, a1: A) { a.foo("", null)?.length a.foo("", null).length a.foo(null, "").length + a.foo("", null)!!.length a.bar().length a.bar()!!.length diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Warnings.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Warnings.fir.kt index 91bbfbd9f8d..ad90c31b0a5 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Warnings.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Warnings.fir.kt @@ -25,19 +25,19 @@ public class A { fun main(a: A, a1: A) { a.foo("", null)?.length - a.foo("", null).length - a.foo(null, "").length + a.foo("", null).length + a.foo(null, "").length a.bar().length a.bar()!!.length a.field?.length - a.field.length + a.field.length - a.baz("").length + a.baz("").length a.baz("")?.length - a.baz(null).length + a.baz(null).length a1.baz("")!!.length - a1.baz(null)!!.length + a1.baz(null)!!.length } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.fir.kt deleted file mode 100644 index 17da142bc26..00000000000 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.fir.kt +++ /dev/null @@ -1,64 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -// JSR305_GLOBAL_REPORT: warn - -// FILE: NonNullApi.java -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import javax.annotation.meta.TypeQualifierDefault; - -@Retention(RetentionPolicy.RUNTIME) -@Documented -@MyNonnull -@TypeQualifierDefault({ ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD }) -public @interface NonNullApi { -} - -// FILE: MigrationNonNullApi.java -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import javax.annotation.meta.TypeQualifierDefault; - -import kotlin.annotations.jvm.*; - -@Retention(RetentionPolicy.RUNTIME) -@Documented -@MyNonnull -@UnderMigration(status = MigrationStatus.STRICT) -@TypeQualifierDefault({ ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD }) -public @interface MigrationNonNullApi { -} - -// FILE: PolicyFromDefault.java -@NonNullApi -public class PolicyFromDefault { - public String foo(String x) { - return x; - } - - public String bar = "bar"; -} - -// FILE: PolicyFromNickname.java -@MigrationNonNullApi -public class PolicyFromNickname { - public String foo(String x) { - return x; - } - - public String bar = "bar"; -} - -// FILE: main.kt -fun main(default: PolicyFromDefault, nickname: PolicyFromNickname) { - default.foo(null).length - default.foo("hello").length - - nickname.foo(null).length - nickname.foo("hello").length -} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.kt index 8df6888aaf9..db226d416f5 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/typeQualifierDefault/defaultAndNicknameMigrationPolicy.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER // JSR305_GLOBAL_REPORT: warn diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java index 31ddf5e563a..f648761a693 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java @@ -216,6 +216,12 @@ public class ForeignAnnotationsCompiledJavaTestGenerated extends AbstractForeign runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/elvis.kt"); } + @Test + @TestMetadata("expressionBodiedFunction.kt") + public void testExpressionBodiedFunction() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/expressionBodiedFunction.kt"); + } + @Test @TestMetadata("localInference.kt") public void testLocalInference() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java index 8b41b4ee9b6..a45fb8c3ae4 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java @@ -274,6 +274,12 @@ public class ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated exte runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/elvis.kt"); } + @Test + @TestMetadata("expressionBodiedFunction.kt") + public void testExpressionBodiedFunction() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/expressionBodiedFunction.kt"); + } + @Test @TestMetadata("localInference.kt") public void testLocalInference() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java index 720071a7cb6..06cf6d515df 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java @@ -274,6 +274,12 @@ public class ForeignAnnotationsSourceJavaTestGenerated extends AbstractForeignAn runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/elvis.kt"); } + @Test + @TestMetadata("expressionBodiedFunction.kt") + public void testExpressionBodiedFunction() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305/nullabilityWarnings/expressionBodiedFunction.kt"); + } + @Test @TestMetadata("localInference.kt") public void testLocalInference() throws Exception { diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/JspecifyDiagnosticComplianceHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/JspecifyDiagnosticComplianceHandler.kt index 4f52c7bec14..2eea7332408 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/JspecifyDiagnosticComplianceHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/JspecifyDiagnosticComplianceHandler.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.codeMetaInfo.model.DiagnosticCodeMetaInfo import org.jetbrains.kotlin.codeMetaInfo.model.JspecifyMarkerCodeMetaInfo import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors +import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors import org.jetbrains.kotlin.load.java.JSPECIFY_ANNOTATIONS_PACKAGE import org.jetbrains.kotlin.load.java.ReportLevel import org.jetbrains.kotlin.load.java.getDefaultReportLevelForAnnotation @@ -52,9 +53,10 @@ internal val diagnosticsToJspecifyMarks = mapOf( ReportLevel.WARN to mapOf( ErrorsJvm.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS to "jspecify_nullness_mismatch", ErrorsJvm.UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS to "jspecify_nullness_mismatch", - ErrorsJvm.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS to "jspecify_nullness_mismatch", ErrorsJvm.RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS to "jspecify_nullness_mismatch", - // TODO: list FIR warnings (they don't exist yet) + + FirJvmErrors.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS to "jspecify_nullness_mismatch", + FirJvmErrors.RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS to "jspecify_nullness_mismatch", ), ReportLevel.STRICT to mapOf( Errors.TYPE_MISMATCH to "jspecify_nullness_mismatch",