From 7d6e133c0de3c3c41dd4927b9ed44fdbda4a049a Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Fri, 22 Jul 2022 19:22:04 +0200 Subject: [PATCH] Refine warning messages for KT-36770 ^KT-36770 Fixed --- .../resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java | 9 ++++++--- compiler/testData/cli/jvm/jspecifyByLv15.out | 2 +- compiler/testData/cli/jvm/jspecifyByLv16.out | 2 +- compiler/testData/cli/jvm/jspecifyDefault.out | 2 +- compiler/testData/cli/jvm/jspecifyWarn.out | 2 +- .../testData/cli/jvm/jsr305MigrationFqNameIgnore.out | 2 +- compiler/testData/cli/jvm/jsr305MigrationIgnore.out | 2 +- compiler/testData/cli/jvm/jsr305MigrationWarn.out | 2 +- ...eterWithKotlinOverridesDefinitelyNonNullable.diag.txt | 8 ++++---- 9 files changed, 17 insertions(+), 14 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java index 07bfec76d3b..bac496fe0d5 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java @@ -108,14 +108,17 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension { NAME ); MAP.put(RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS, - "Unsafe use of a nullable receiver of type {0}. See https://youtrack.jetbrains.com/issue/KT-36770 for details", RENDER_TYPE); + "Unsafe use of a nullable receiver of type {0}", RENDER_TYPE); MAP.put(WRONG_NULLABILITY_FOR_JAVA_OVERRIDE, - "Override ''{0}'' has incorrect nullability in its signature comparing with overridden ''{1}''", COMPACT, COMPACT); + "Override ''{0}'' has incorrect nullability in its signature comparing with overridden ''{1}''" + + "This warning will become an error soon. " + + "See https://youtrack.jetbrains.com/issue/KT-36770 for details", COMPACT, COMPACT); MAP.put(WRONG_TYPE_PARAMETER_NULLABILITY_FOR_JAVA_OVERRIDE, "Type parameter ''{0}'' has nullable upper bound, so override has incorrect signature comparing with a base member with NotNull annotation. " + - "Please add a non-nullable upper bound (e.g. Any) to the type parameter. See https://kotlinlang.org/docs/generics.html#upper-bounds for more details", + "Please add a non-nullable upper bound (e.g. Any) to the type parameter. See https://kotlinlang.org/docs/generics.html#upper-bounds and https://youtrack.jetbrains.com/issue/KT-36770 for more details. " + + "This warning will become an error soon.", NAME); MAP.put(ANNOTATION_TARGETS_NON_EXISTENT_ACCESSOR, diff --git a/compiler/testData/cli/jvm/jspecifyByLv15.out b/compiler/testData/cli/jvm/jspecifyByLv15.out index 70bacbad2a4..7c2a6d77f6e 100644 --- a/compiler/testData/cli/jvm/jspecifyByLv15.out +++ b/compiler/testData/cli/jvm/jspecifyByLv15.out @@ -1,7 +1,7 @@ compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected a.foo(null) ^ -compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String?. See https://youtrack.jetbrains.com/issue/KT-36770 for details +compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String? a.bar().hashCode() ^ OK diff --git a/compiler/testData/cli/jvm/jspecifyByLv16.out b/compiler/testData/cli/jvm/jspecifyByLv16.out index 70bacbad2a4..7c2a6d77f6e 100644 --- a/compiler/testData/cli/jvm/jspecifyByLv16.out +++ b/compiler/testData/cli/jvm/jspecifyByLv16.out @@ -1,7 +1,7 @@ compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected a.foo(null) ^ -compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String?. See https://youtrack.jetbrains.com/issue/KT-36770 for details +compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String? a.bar().hashCode() ^ OK diff --git a/compiler/testData/cli/jvm/jspecifyDefault.out b/compiler/testData/cli/jvm/jspecifyDefault.out index 70bacbad2a4..7c2a6d77f6e 100644 --- a/compiler/testData/cli/jvm/jspecifyDefault.out +++ b/compiler/testData/cli/jvm/jspecifyDefault.out @@ -1,7 +1,7 @@ compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected a.foo(null) ^ -compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String?. See https://youtrack.jetbrains.com/issue/KT-36770 for details +compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String? a.bar().hashCode() ^ OK diff --git a/compiler/testData/cli/jvm/jspecifyWarn.out b/compiler/testData/cli/jvm/jspecifyWarn.out index 70bacbad2a4..7c2a6d77f6e 100644 --- a/compiler/testData/cli/jvm/jspecifyWarn.out +++ b/compiler/testData/cli/jvm/jspecifyWarn.out @@ -1,7 +1,7 @@ compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected a.foo(null) ^ -compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String?. See https://youtrack.jetbrains.com/issue/KT-36770 for details +compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String? a.bar().hashCode() ^ OK diff --git a/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.out b/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.out index d307f1c4f2b..ca098ea8832 100644 --- a/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.out +++ b/compiler/testData/cli/jvm/jsr305MigrationFqNameIgnore.out @@ -1,7 +1,7 @@ compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: type mismatch: inferred type is Nothing? but String was expected annotated.foo(null) ^ -compiler/testData/cli/jvm/jsr305Migration.kt:4:5: warning: unsafe use of a nullable receiver of type String?. See https://youtrack.jetbrains.com/issue/KT-36770 for details +compiler/testData/cli/jvm/jsr305Migration.kt:4:5: warning: unsafe use of a nullable receiver of type String? annotated.nullable().length ^ OK diff --git a/compiler/testData/cli/jvm/jsr305MigrationIgnore.out b/compiler/testData/cli/jvm/jsr305MigrationIgnore.out index d307f1c4f2b..ca098ea8832 100644 --- a/compiler/testData/cli/jvm/jsr305MigrationIgnore.out +++ b/compiler/testData/cli/jvm/jsr305MigrationIgnore.out @@ -1,7 +1,7 @@ compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: type mismatch: inferred type is Nothing? but String was expected annotated.foo(null) ^ -compiler/testData/cli/jvm/jsr305Migration.kt:4:5: warning: unsafe use of a nullable receiver of type String?. See https://youtrack.jetbrains.com/issue/KT-36770 for details +compiler/testData/cli/jvm/jsr305Migration.kt:4:5: warning: unsafe use of a nullable receiver of type String? annotated.nullable().length ^ OK diff --git a/compiler/testData/cli/jvm/jsr305MigrationWarn.out b/compiler/testData/cli/jvm/jsr305MigrationWarn.out index 4b73de24d55..2e67cc253e5 100644 --- a/compiler/testData/cli/jvm/jsr305MigrationWarn.out +++ b/compiler/testData/cli/jvm/jsr305MigrationWarn.out @@ -4,7 +4,7 @@ compiler/testData/cli/jvm/jsr305Migration.kt:2:19: warning: type mismatch: infer compiler/testData/cli/jvm/jsr305Migration.kt:3:19: warning: type mismatch: inferred type is Nothing? but String was expected annotated.bar(null) ^ -compiler/testData/cli/jvm/jsr305Migration.kt:4:5: warning: unsafe use of a nullable receiver of type String?. See https://youtrack.jetbrains.com/issue/KT-36770 for details +compiler/testData/cli/jvm/jsr305Migration.kt:4:5: warning: unsafe use of a nullable receiver of type String? annotated.nullable().length ^ OK diff --git a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinOverridesDefinitelyNonNullable.diag.txt b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinOverridesDefinitelyNonNullable.diag.txt index b87f997af6d..020a1bd596d 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinOverridesDefinitelyNonNullable.diag.txt +++ b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinOverridesDefinitelyNonNullable.diag.txt @@ -1,12 +1,12 @@ -/main.kt:23:5: warning: type parameter 'X' has nullable upper bound, so override has incorrect signature comparing with a base member with NotNull annotation. Please add a non-nullable upper bound (e.g. Any) to the type parameter. See https://kotlinlang.org/docs/generics.html#upper-bounds for more details +/main.kt:23:5: warning: type parameter 'X' has nullable upper bound, so override has incorrect signature comparing with a base member with NotNull annotation. Please add a non-nullable upper bound (e.g. Any) to the type parameter. See https://kotlinlang.org/docs/generics.html#upper-bounds and https://youtrack.jetbrains.com/issue/KT-36770 for more details. This warning will become an error soon. override fun takeV(x: X) ^ -/main.kt:24:5: warning: type parameter 'E1' has nullable upper bound, so override has incorrect signature comparing with a base member with NotNull annotation. Please add a non-nullable upper bound (e.g. Any) to the type parameter. See https://kotlinlang.org/docs/generics.html#upper-bounds for more details +/main.kt:24:5: warning: type parameter 'E1' has nullable upper bound, so override has incorrect signature comparing with a base member with NotNull annotation. Please add a non-nullable upper bound (e.g. Any) to the type parameter. See https://kotlinlang.org/docs/generics.html#upper-bounds and https://youtrack.jetbrains.com/issue/KT-36770 for more details. This warning will become an error soon. override fun takeE(e: E1) ^ -/main.kt:26:5: warning: type parameter 'X' has nullable upper bound, so override has incorrect signature comparing with a base member with NotNull annotation. Please add a non-nullable upper bound (e.g. Any) to the type parameter. See https://kotlinlang.org/docs/generics.html#upper-bounds for more details +/main.kt:26:5: warning: type parameter 'X' has nullable upper bound, so override has incorrect signature comparing with a base member with NotNull annotation. Please add a non-nullable upper bound (e.g. Any) to the type parameter. See https://kotlinlang.org/docs/generics.html#upper-bounds and https://youtrack.jetbrains.com/issue/KT-36770 for more details. This warning will become an error soon. override fun takeVList(l: List) ^ -/main.kt:27:5: warning: type parameter 'E2' has nullable upper bound, so override has incorrect signature comparing with a base member with NotNull annotation. Please add a non-nullable upper bound (e.g. Any) to the type parameter. See https://kotlinlang.org/docs/generics.html#upper-bounds for more details +/main.kt:27:5: warning: type parameter 'E2' has nullable upper bound, so override has incorrect signature comparing with a base member with NotNull annotation. Please add a non-nullable upper bound (e.g. Any) to the type parameter. See https://kotlinlang.org/docs/generics.html#upper-bounds and https://youtrack.jetbrains.com/issue/KT-36770 for more details. This warning will become an error soon. override fun takeEList(l2: List) ^