Add @JvmStatic Intention: Support functions/properties in objects
Also eliminate unnecessary object instance references on Java call sites #KT-20095 Fixed
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: Abstract property 'foo' in non-abstract class 'Test'
|
||||
|
||||
object Test {
|
||||
abstract val <caret>foo: Int
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
object Test {
|
||||
const val <caret>foo = 1
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class Test {
|
||||
companion object {
|
||||
fun <caret>main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class Test {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
object Test {
|
||||
fun <caret>main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
object Test {
|
||||
@JvmName("main")
|
||||
fun <caret>test(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
object Test {
|
||||
@JvmStatic
|
||||
@JvmName("main")
|
||||
fun <caret>test(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
object Test {
|
||||
@JvmName("test")
|
||||
fun <caret>main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
object Test {
|
||||
fun <caret>test(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
object Test {
|
||||
open val <caret>foo = 1
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
interface I {
|
||||
val foo: Int
|
||||
}
|
||||
|
||||
object Test : I {
|
||||
override val <caret>foo = 1
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
val <caret>foo = 1
|
||||
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
private fun test() = object {
|
||||
val <caret>foo = 1
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class Test {
|
||||
val <caret>foo = 1
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
object Test {
|
||||
@JvmField
|
||||
val <caret>foo = 1
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
object Test {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
}
|
||||
val <caret>foo = 1
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "test/test.kt",
|
||||
"intentionClass": "org.jetbrains.kotlin.idea.intentions.AddJvmStaticIntention",
|
||||
"withRuntime": "true"
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
class J {
|
||||
void test(C.Companion companion) {
|
||||
companion.foo("x");
|
||||
C.foo("y");
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package test
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun foo(s: String) {}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
class J {
|
||||
void test(C.Companion companion) {
|
||||
companion.foo("x");
|
||||
C.Companion.foo("y");
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
fun <caret>foo(s: String) {}
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "test/test.kt",
|
||||
"intentionClass": "org.jetbrains.kotlin.idea.intentions.AddJvmStaticIntention",
|
||||
"withRuntime": "true"
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
|
||||
class J {
|
||||
void test(C.Companion companion) {
|
||||
companion.getFoo();
|
||||
companion.setFoo(1);
|
||||
|
||||
C.getFoo();
|
||||
C.setFoo(2);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package test
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
var foo: Int = 1
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
|
||||
class J {
|
||||
void test(C.Companion companion) {
|
||||
companion.getFoo();
|
||||
companion.setFoo(1);
|
||||
|
||||
C.Companion.getFoo();
|
||||
C.Companion.setFoo(2);
|
||||
}
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
var <caret>foo: Int = 1
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "test/test.kt",
|
||||
"intentionClass": "org.jetbrains.kotlin.idea.intentions.AddJvmStaticIntention",
|
||||
"withRuntime": "true"
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
class J {
|
||||
void test(C.O companion) {
|
||||
companion.foo("x");
|
||||
C.foo("y");
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package test
|
||||
|
||||
class C {
|
||||
companion object O {
|
||||
@JvmStatic
|
||||
fun foo(s: String) {}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
class J {
|
||||
void test(C.O companion) {
|
||||
companion.foo("x");
|
||||
C.O.foo("y");
|
||||
}
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
class C {
|
||||
companion object O {
|
||||
fun <caret>foo(s: String) {}
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "test/test.kt",
|
||||
"intentionClass": "org.jetbrains.kotlin.idea.intentions.AddJvmStaticIntention",
|
||||
"withRuntime": "true"
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
|
||||
class J {
|
||||
void test(C.O companion) {
|
||||
companion.getFoo();
|
||||
companion.setFoo(1);
|
||||
|
||||
C.getFoo();
|
||||
C.setFoo(2);
|
||||
}
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
package test
|
||||
|
||||
class C {
|
||||
companion object O {
|
||||
@JvmStatic
|
||||
var foo: Int = 1
|
||||
}
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
|
||||
class J {
|
||||
void test(C.O companion) {
|
||||
companion.getFoo();
|
||||
companion.setFoo(1);
|
||||
|
||||
C.O.getFoo();
|
||||
C.O.setFoo(2);
|
||||
}
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
class C {
|
||||
companion object O {
|
||||
var <caret>foo: Int = 1
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "test/test.kt",
|
||||
"intentionClass": "org.jetbrains.kotlin.idea.intentions.AddJvmStaticIntention",
|
||||
"withRuntime": "true"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
class J {
|
||||
void test(O o) {
|
||||
o.foo("x");
|
||||
O.foo("y");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package test
|
||||
|
||||
object O {
|
||||
@JvmStatic
|
||||
fun foo(s: String) {}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
class J {
|
||||
void test(O o) {
|
||||
o.foo("x");
|
||||
O.INSTANCE.foo("y");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
object O {
|
||||
fun <caret>foo(s: String) {}
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "test/test.kt",
|
||||
"intentionClass": "org.jetbrains.kotlin.idea.intentions.AddJvmStaticIntention",
|
||||
"withRuntime": "true"
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
|
||||
class J {
|
||||
void test(O o) {
|
||||
o.getFoo();
|
||||
o.setFoo(1);
|
||||
|
||||
O.getFoo();
|
||||
O.setFoo(2);
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package test
|
||||
|
||||
object O {
|
||||
@JvmStatic
|
||||
var foo: Int = 1
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
|
||||
class J {
|
||||
void test(O o) {
|
||||
o.getFoo();
|
||||
o.setFoo(1);
|
||||
|
||||
O.INSTANCE.getFoo();
|
||||
O.INSTANCE.setFoo(2);
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
object O {
|
||||
var <caret>foo: Int = 1
|
||||
}
|
||||
Reference in New Issue
Block a user