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 f985ebe7a15..d27074ce707 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 @@ -53,7 +53,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension { MAP.put(ErrorsJvm.OVERLOADS_ABSTRACT, "''JvmOverloads'' annotation cannot be used on abstract methods"); MAP.put(ErrorsJvm.OVERLOADS_PRIVATE, "''JvmOverloads'' annotation has no effect on private and local declarations"); MAP.put(ErrorsJvm.INAPPLICABLE_JVM_NAME, "''JvmName'' annotation is not applicable to this declaration"); - MAP.put(ErrorsJvm.ILLEGAL_JVM_NAME, "Illegal JVM name: ''{0}''", STRING); + MAP.put(ErrorsJvm.ILLEGAL_JVM_NAME, "Illegal JVM name"); MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT, "External declaration can not be abstract"); MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_HAVE_BODY, "External declaration can not have a body"); MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_IN_TRAIT, "Members of interfaces can not be external"); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java index 62c23904e2e..50868e115de 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java @@ -44,7 +44,7 @@ public interface ErrorsJvm { DiagnosticFactory0 JVM_STATIC_NOT_IN_OBJECT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); DiagnosticFactory0 INAPPLICABLE_JVM_NAME = DiagnosticFactory0.create(ERROR); - DiagnosticFactory1 ILLEGAL_JVM_NAME = DiagnosticFactory1.create(ERROR); + DiagnosticFactory0 ILLEGAL_JVM_NAME = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE); DiagnosticFactory0 OVERLOADS_ABSTRACT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt index 70816f9364a..352faea2493 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt @@ -28,7 +28,6 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticSink import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.jvm.RuntimeAssertionsTypeChecker import org.jetbrains.kotlin.lexer.JetTokens -import org.jetbrains.kotlin.load.java.lazy.types.RawTypeTag import org.jetbrains.kotlin.load.java.lazy.types.isMarkedNotNull import org.jetbrains.kotlin.load.java.lazy.types.isMarkedNullable import org.jetbrains.kotlin.load.kotlin.JavaAnnotationCallChecker @@ -200,7 +199,7 @@ public class JvmNameAnnotationChecker : DeclarationChecker { val value = DescriptorUtils.getJvmName(descriptor) if (value == null || !Name.isValidIdentifier(value)) { - diagnosticHolder.report(ErrorsJvm.ILLEGAL_JVM_NAME.on(annotationEntry, value)) + diagnosticHolder.report(ErrorsJvm.ILLEGAL_JVM_NAME.on(annotationEntry)) } if (descriptor is CallableMemberDescriptor) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/regression/ea70880_illegalJvmName.kt b/compiler/testData/diagnostics/testsWithStdLib/regression/ea70880_illegalJvmName.kt new file mode 100644 index 00000000000..af4743d7b82 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/regression/ea70880_illegalJvmName.kt @@ -0,0 +1,8 @@ +@JvmName() +fun foo() {} + +@JvmName(42) +fun bar() {} + +@JvmName("a", "b") +fun baz() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/regression/ea70880_illegalJvmName.txt b/compiler/testData/diagnostics/testsWithStdLib/regression/ea70880_illegalJvmName.txt new file mode 100644 index 00000000000..bfe7651531b --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/regression/ea70880_illegalJvmName.txt @@ -0,0 +1,5 @@ +package + +kotlin.jvm.JvmName(name = 42) public fun bar(): kotlin.Unit +kotlin.jvm.JvmName(name = "a") public fun baz(): kotlin.Unit +kotlin.jvm.JvmName() public fun foo(): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java index 8a2d14d24cc..a67c16d0753 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java @@ -763,6 +763,12 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic doTest(fileName); } + @TestMetadata("ea70880_illegalJvmName.kt") + public void testEa70880_illegalJvmName() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/regression/ea70880_illegalJvmName.kt"); + doTest(fileName); + } + @TestMetadata("kt2082.kt") public void testKt2082() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/regression/kt2082.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java index a341070002e..bc191c82ffb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java @@ -562,8 +562,8 @@ public class DescriptorUtils { } @Nullable - public static String getJvmName(@NotNull Annotations annotations) { - AnnotationDescriptor jvmNameAnnotation = getJvmNameAnnotation(annotations); + public static String getJvmName(@NotNull Annotated annotated) { + AnnotationDescriptor jvmNameAnnotation = getJvmNameAnnotation(annotated.getAnnotations()); if (jvmNameAnnotation == null) return null; Map> arguments = jvmNameAnnotation.getAllValueArguments(); @@ -575,11 +575,6 @@ public class DescriptorUtils { return ((StringValue) name).getValue(); } - @Nullable - public static String getJvmName(@NotNull Annotated annotated) { - return getJvmName(annotated.getAnnotations()); - } - @Nullable public static AnnotationDescriptor getJvmNameAnnotation(@NotNull Annotations annotations) { AnnotationDescriptor jvmNameAnnotation = annotations.findAnnotation(JVM_NAME);