JVM IR: generate private @JvmStatic functions as in old backend
#KT-46181 Fixed
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
object TestObject {
|
||||
@JvmStatic
|
||||
external fun foo()
|
||||
}
|
||||
|
||||
class TestClassCompanion {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
external fun foo()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
@kotlin.Metadata
|
||||
public final class TestClassCompanion$Companion {
|
||||
// source: 'jvmStaticExternal.kt'
|
||||
private method <init>(): void
|
||||
public synthetic method <init>(p0: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||
public final @kotlin.jvm.JvmStatic method foo(): void
|
||||
public final inner class TestClassCompanion$Companion
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class TestClassCompanion {
|
||||
// source: 'jvmStaticExternal.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull field Companion: TestClassCompanion$Companion
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
public native final static @kotlin.jvm.JvmStatic method foo(): void
|
||||
public final inner class TestClassCompanion$Companion
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class TestObject {
|
||||
// source: 'jvmStaticExternal.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull field INSTANCE: TestObject
|
||||
static method <clinit>(): void
|
||||
private method <init>(): void
|
||||
public native final static @kotlin.jvm.JvmStatic method foo(): void
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
// For a private @JvmStatic function `f` in `A.Companion`, we generate:
|
||||
// 1) private instance method `f` in `A.Companion`, with the actual implementation;
|
||||
// 2) public static method `access$f` in `A.Companion` which calls `A.Companion.f`;
|
||||
// 3) private static method `f` in `A` which calls `A.Companion.access$f`.
|
||||
// (which is basically the same as all @JvmStatic companion functions, except that we also need an accessor here.)
|
||||
//
|
||||
// This might seem like an overkill, but there are actually some use cases, namely private static helpers for JNI (see KT-46181).
|
||||
|
||||
class A {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
private fun f(p: Int) {}
|
||||
|
||||
@JvmStatic
|
||||
private val x = ""
|
||||
|
||||
private var xx: String
|
||||
@JvmStatic get() = ""
|
||||
@JvmStatic set(value) {}
|
||||
}
|
||||
}
|
||||
|
||||
object O {
|
||||
@JvmStatic
|
||||
private fun g(q: Int) {}
|
||||
|
||||
@JvmStatic
|
||||
private val y = ""
|
||||
|
||||
private var yy: String
|
||||
@JvmStatic get() = ""
|
||||
@JvmStatic set(value) {}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
@kotlin.Metadata
|
||||
public final class A$Companion {
|
||||
// source: 'jvmStaticPrivate.kt'
|
||||
private method <init>(): void
|
||||
public synthetic method <init>(p0: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||
public synthetic final static method access$f(p0: A$Companion, p1: int): void
|
||||
public synthetic final static method access$getXx$p(p0: A$Companion): java.lang.String
|
||||
public synthetic final static method access$setXx$p(p0: A$Companion, p1: java.lang.String): void
|
||||
private final @kotlin.jvm.JvmStatic method f(p0: int): void
|
||||
private synthetic deprecated static @kotlin.jvm.JvmStatic method getX$annotations(): void
|
||||
private final @kotlin.jvm.JvmStatic method getXx(): java.lang.String
|
||||
private final @kotlin.jvm.JvmStatic method setXx(p0: java.lang.String): void
|
||||
public final inner class A$Companion
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class A {
|
||||
// source: 'jvmStaticPrivate.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull field Companion: A$Companion
|
||||
private final static field x: java.lang.String
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
private final static @kotlin.jvm.JvmStatic method f(p0: int): void
|
||||
private final static @kotlin.jvm.JvmStatic method getXx(): java.lang.String
|
||||
private final static @kotlin.jvm.JvmStatic method setXx(p0: java.lang.String): void
|
||||
public final inner class A$Companion
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class O {
|
||||
// source: 'jvmStaticPrivate.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
|
||||
private final static field y: java.lang.String
|
||||
static method <clinit>(): void
|
||||
private method <init>(): void
|
||||
private final static @kotlin.jvm.JvmStatic method g(p0: int): void
|
||||
private synthetic deprecated static @kotlin.jvm.JvmStatic method getY$annotations(): void
|
||||
private final static @kotlin.jvm.JvmStatic method getYy(): java.lang.String
|
||||
private final static @kotlin.jvm.JvmStatic method setYy(p0: java.lang.String): void
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
@kotlin.Metadata
|
||||
public final class A$Companion {
|
||||
// source: 'jvmStaticPrivate.kt'
|
||||
private method <init>(): void
|
||||
public synthetic method <init>(p0: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||
public synthetic final static method access$f(p0: A$Companion, p1: int): void
|
||||
public synthetic final static method access$getXx(p0: A$Companion): java.lang.String
|
||||
public synthetic final static method access$setXx(p0: A$Companion, p1: java.lang.String): void
|
||||
private final @kotlin.jvm.JvmStatic method f(p0: int): void
|
||||
private synthetic deprecated static @kotlin.jvm.JvmStatic method getX$annotations(): void
|
||||
private final @kotlin.jvm.JvmStatic method getXx(): java.lang.String
|
||||
private final @kotlin.jvm.JvmStatic method setXx(p0: java.lang.String): void
|
||||
public final inner class A$Companion
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class A {
|
||||
// source: 'jvmStaticPrivate.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull field Companion: A$Companion
|
||||
private final static @org.jetbrains.annotations.NotNull field x: java.lang.String
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
private final static @kotlin.jvm.JvmStatic method f(p0: int): void
|
||||
private final static @kotlin.jvm.JvmStatic method getXx(): java.lang.String
|
||||
private final static @kotlin.jvm.JvmStatic method setXx(p0: java.lang.String): void
|
||||
public final inner class A$Companion
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class O {
|
||||
// source: 'jvmStaticPrivate.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull field INSTANCE: O
|
||||
private final static @org.jetbrains.annotations.NotNull field y: java.lang.String
|
||||
static method <clinit>(): void
|
||||
private method <init>(): void
|
||||
private final static @kotlin.jvm.JvmStatic method g(p0: int): void
|
||||
private synthetic deprecated static @kotlin.jvm.JvmStatic method getY$annotations(): void
|
||||
private final static @kotlin.jvm.JvmStatic method getYy(): java.lang.String
|
||||
private final static @kotlin.jvm.JvmStatic method setYy(p0: java.lang.String): void
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class WithCompanion {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun foo(x: Int = 1) {}
|
||||
}
|
||||
}
|
||||
|
||||
object AnObject {
|
||||
@JvmStatic
|
||||
fun foo(x: Int = 1) {}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
@kotlin.Metadata
|
||||
public final class AnObject {
|
||||
// source: 'jvmStaticWithDefaultParameters.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull field INSTANCE: AnObject
|
||||
static method <clinit>(): void
|
||||
private method <init>(): void
|
||||
public synthetic static method foo$default(p0: int, p1: int, p2: java.lang.Object): void
|
||||
public final static @kotlin.jvm.JvmStatic method foo(p0: int): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class WithCompanion$Companion {
|
||||
// source: 'jvmStaticWithDefaultParameters.kt'
|
||||
private method <init>(): void
|
||||
public synthetic method <init>(p0: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||
public synthetic static method foo$default(p0: WithCompanion$Companion, p1: int, p2: int, p3: java.lang.Object): void
|
||||
public final @kotlin.jvm.JvmStatic method foo(p0: int): void
|
||||
public final inner class WithCompanion$Companion
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class WithCompanion {
|
||||
// source: 'jvmStaticWithDefaultParameters.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull field Companion: WithCompanion$Companion
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
public final static @kotlin.jvm.JvmStatic method foo(p0: int): void
|
||||
public final inner class WithCompanion$Companion
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
annotation class Annotation {
|
||||
companion object {
|
||||
@JvmStatic val TEST_FIELD = "OK"
|
||||
|
||||
var TEST_FIELD2 = ""
|
||||
@JvmStatic get
|
||||
@JvmStatic set
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
@kotlin.Metadata
|
||||
public final class Annotation$Companion {
|
||||
// source: 'kt31389.kt'
|
||||
synthetic final static field $$INSTANCE: Annotation$Companion
|
||||
private static @org.jetbrains.annotations.NotNull field TEST_FIELD2: java.lang.String
|
||||
private final static @org.jetbrains.annotations.NotNull field TEST_FIELD: java.lang.String
|
||||
static method <clinit>(): void
|
||||
private method <init>(): void
|
||||
public synthetic deprecated static @kotlin.jvm.JvmStatic method getTEST_FIELD$annotations(): void
|
||||
public final @org.jetbrains.annotations.NotNull method getTEST_FIELD(): java.lang.String
|
||||
public final @kotlin.jvm.JvmStatic @org.jetbrains.annotations.NotNull method getTEST_FIELD2(): java.lang.String
|
||||
public final @kotlin.jvm.JvmStatic method setTEST_FIELD2(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final inner class Annotation$Companion
|
||||
}
|
||||
|
||||
@java.lang.annotation.Retention(value=RUNTIME)
|
||||
@kotlin.Metadata
|
||||
public annotation class Annotation {
|
||||
// source: 'kt31389.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull field Companion: Annotation$Companion
|
||||
static method <clinit>(): void
|
||||
public static method getTEST_FIELD(): java.lang.String
|
||||
public static @kotlin.jvm.JvmStatic method getTEST_FIELD2(): java.lang.String
|
||||
public static @kotlin.jvm.JvmStatic method setTEST_FIELD2(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final inner class Annotation$Companion
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
@kotlin.Metadata
|
||||
public final class Annotation$Companion {
|
||||
// source: 'kt31389.kt'
|
||||
synthetic final static field $$INSTANCE: Annotation$Companion
|
||||
private static @org.jetbrains.annotations.NotNull field TEST_FIELD2: java.lang.String
|
||||
private final static @org.jetbrains.annotations.NotNull field TEST_FIELD: java.lang.String
|
||||
static method <clinit>(): void
|
||||
private method <init>(): void
|
||||
public synthetic deprecated static @kotlin.jvm.JvmStatic method getTEST_FIELD$annotations(): void
|
||||
public final @org.jetbrains.annotations.NotNull method getTEST_FIELD(): java.lang.String
|
||||
public final @kotlin.jvm.JvmStatic @org.jetbrains.annotations.NotNull method getTEST_FIELD2(): java.lang.String
|
||||
public final @kotlin.jvm.JvmStatic method setTEST_FIELD2(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final inner class Annotation$Companion
|
||||
}
|
||||
|
||||
@java.lang.annotation.Retention(value=RUNTIME)
|
||||
@kotlin.Metadata
|
||||
public annotation class Annotation {
|
||||
// source: 'kt31389.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull field Companion: Annotation$Companion
|
||||
static method <clinit>(): void
|
||||
public static @org.jetbrains.annotations.NotNull method getTEST_FIELD(): java.lang.String
|
||||
public static @kotlin.jvm.JvmStatic @org.jetbrains.annotations.NotNull method getTEST_FIELD2(): java.lang.String
|
||||
public static @kotlin.jvm.JvmStatic method setTEST_FIELD2(@org.jetbrains.annotations.NotNull p0: java.lang.String): void
|
||||
public final inner class Annotation$Companion
|
||||
}
|
||||
Reference in New Issue
Block a user