Value classes: Support @JvmName annotation on functions with inline
classes in signatures, but not on methods of inline classes.
This commit is contained in:
+1
-4
@@ -152,10 +152,7 @@ class JvmNameAnnotationChecker : DeclarationChecker {
|
||||
if (descriptor is CallableMemberDescriptor) {
|
||||
if (DescriptorUtils.isOverride(descriptor) || descriptor.isOverridable) {
|
||||
diagnosticHolder.report(ErrorsJvm.INAPPLICABLE_JVM_NAME.on(annotationEntry))
|
||||
} else if (descriptor.containingDeclaration.isInlineClassThatRequiresMangling() ||
|
||||
requiresFunctionNameManglingForParameterTypes(descriptor) ||
|
||||
requiresFunctionNameManglingForReturnType(descriptor)
|
||||
) {
|
||||
} else if (descriptor.containingDeclaration.isInlineClassThatRequiresMangling()) {
|
||||
diagnosticHolder.report(ErrorsJvm.INAPPLICABLE_JVM_NAME.on(annotationEntry))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Foo(val a: Any)
|
||||
|
||||
@JvmName("bar")
|
||||
fun bar(f: Foo) {}
|
||||
|
||||
@JvmName("baz")
|
||||
fun baz(r: Result<Int>) {}
|
||||
|
||||
@JvmName("test")
|
||||
fun returnsInlineClass() = Foo(1)
|
||||
|
||||
@JvmName("test")
|
||||
@Suppress("RESULT_CLASS_IN_RETURN_TYPE")
|
||||
fun returnsKotlinResult(a: Result<Int>): Result<Int> = a
|
||||
|
||||
class C {
|
||||
@JvmName("test")
|
||||
fun returnsInlineClass() = Foo(1)
|
||||
|
||||
@JvmName("test")
|
||||
@Suppress("RESULT_CLASS_IN_RETURN_TYPE")
|
||||
fun returnsKotlinResult(a: Result<Int>): Result<Int> = a
|
||||
}
|
||||
|
||||
@JvmName("extensionFun")
|
||||
fun Foo.extensionFun() {}
|
||||
@@ -0,0 +1,35 @@
|
||||
@kotlin.Metadata
|
||||
public final class C {
|
||||
// source: 'jvmName.kt'
|
||||
public method <init>(): void
|
||||
public final @kotlin.jvm.JvmName @org.jetbrains.annotations.NotNull method test(): java.lang.Object
|
||||
public final @kotlin.jvm.JvmName @org.jetbrains.annotations.NotNull method test(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class Foo {
|
||||
// source: 'jvmName.kt'
|
||||
private final @org.jetbrains.annotations.NotNull field a: java.lang.Object
|
||||
private synthetic method <init>(p0: java.lang.Object): void
|
||||
public synthetic final static method box-impl(p0: java.lang.Object): Foo
|
||||
public static @org.jetbrains.annotations.NotNull method constructor-impl(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
public method equals(p0: java.lang.Object): boolean
|
||||
public static method equals-impl(p0: java.lang.Object, p1: java.lang.Object): boolean
|
||||
public final static method equals-impl0(p0: java.lang.Object, p1: java.lang.Object): boolean
|
||||
public final @org.jetbrains.annotations.NotNull method getA(): java.lang.Object
|
||||
public method hashCode(): int
|
||||
public static method hashCode-impl(p0: java.lang.Object): int
|
||||
public method toString(): java.lang.String
|
||||
public static method toString-impl(p0: java.lang.Object): java.lang.String
|
||||
public synthetic final method unbox-impl(): java.lang.Object
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class JvmNameKt {
|
||||
// source: 'jvmName.kt'
|
||||
public final static @kotlin.jvm.JvmName method bar(@org.jetbrains.annotations.NotNull p0: java.lang.Object): void
|
||||
public final static @kotlin.jvm.JvmName method baz(@org.jetbrains.annotations.NotNull p0: java.lang.Object): void
|
||||
public final static @kotlin.jvm.JvmName method extensionFun(@org.jetbrains.annotations.NotNull p0: java.lang.Object): void
|
||||
public final static @kotlin.jvm.JvmName @org.jetbrains.annotations.NotNull method test(): java.lang.Object
|
||||
public final static @kotlin.jvm.JvmName @org.jetbrains.annotations.NotNull method test(@org.jetbrains.annotations.NotNull p0: java.lang.Object): java.lang.Object
|
||||
}
|
||||
+4
-4
@@ -6,7 +6,7 @@ inline class Foo(val x: Int) {
|
||||
fun simple() {}
|
||||
}
|
||||
|
||||
<!INAPPLICABLE_JVM_NAME!>@JvmName("bad")<!>
|
||||
@JvmName("bad")
|
||||
fun bar(f: Foo) {}
|
||||
|
||||
@JvmName("good")
|
||||
@@ -19,12 +19,12 @@ fun returnsInlineClass() = Foo(1)
|
||||
fun returnsKotlinResult(a: Result<Int>): <!RESULT_CLASS_IN_RETURN_TYPE!>Result<Int><!> = a
|
||||
|
||||
class C {
|
||||
<!INAPPLICABLE_JVM_NAME!>@JvmName("test")<!>
|
||||
@JvmName("test")
|
||||
fun returnsInlineClass() = Foo(1)
|
||||
|
||||
<!INAPPLICABLE_JVM_NAME!>@JvmName("test")<!>
|
||||
@JvmName("test")
|
||||
fun returnsKotlinResult(a: Result<Int>): <!RESULT_CLASS_IN_RETURN_TYPE!>Result<Int><!> = a
|
||||
}
|
||||
|
||||
<!INAPPLICABLE_JVM_NAME!>@JvmName("extensionFun")<!>
|
||||
@JvmName("extensionFun")
|
||||
fun Foo.extensionFun() {}
|
||||
|
||||
+5
@@ -982,6 +982,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassWithManyKindsOfMembers.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmName.kt")
|
||||
public void testJvmName() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/jvmName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmOverloadsOnTopLevelFunctionReturningInlineClassValue.kt")
|
||||
public void testJvmOverloadsOnTopLevelFunctionReturningInlineClassValue() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/jvmOverloadsOnTopLevelFunctionReturningInlineClassValue.kt");
|
||||
|
||||
+5
@@ -952,6 +952,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
|
||||
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassWithManyKindsOfMembers.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmName.kt")
|
||||
public void testJvmName() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/jvmName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmOverloadsOnTopLevelFunctionReturningInlineClassValue.kt")
|
||||
public void testJvmOverloadsOnTopLevelFunctionReturningInlineClassValue() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/jvmOverloadsOnTopLevelFunctionReturningInlineClassValue.kt");
|
||||
|
||||
Reference in New Issue
Block a user