mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
Initial implementation of platformStatic
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import java.lang.String;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
class Test {
|
||||
|
||||
public static String test1() throws NoSuchMethodException {
|
||||
Annotation[] test1s = A.class.getMethod("test1").getAnnotations();
|
||||
for (Annotation test : test1s) {
|
||||
String name = test.toString();
|
||||
if (name.contains("testAnnotation")) {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
return "fail";
|
||||
}
|
||||
|
||||
public static String test2() throws NoSuchMethodException {
|
||||
Annotation[] test2s = B.class.getMethod("test1").getAnnotations();
|
||||
for (Annotation test : test2s) {
|
||||
String name = test.toString();
|
||||
if (name.contains("testAnnotation")) {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
return "fail";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import java.lang.annotation.Retention
|
||||
import java.lang.annotation.RetentionPolicy
|
||||
|
||||
Retention(RetentionPolicy.RUNTIME)
|
||||
annotation class testAnnotation
|
||||
|
||||
class A {
|
||||
|
||||
class object {
|
||||
val b: String = "OK"
|
||||
|
||||
platformStatic testAnnotation fun test1() = b
|
||||
}
|
||||
}
|
||||
|
||||
object B {
|
||||
val b: String = "OK"
|
||||
|
||||
platformStatic testAnnotation fun test1() = b
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (Test.test1() != "OK") return "fail 1"
|
||||
|
||||
if (Test.test2() != "OK") return "fail 2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class Test {
|
||||
|
||||
public static String test1() {
|
||||
return A.test1();
|
||||
}
|
||||
|
||||
public static String test2() {
|
||||
return A.test2();
|
||||
}
|
||||
|
||||
public static String test3() {
|
||||
return A.test3("JAVA");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
class A {
|
||||
|
||||
class object {
|
||||
val b: String = "OK"
|
||||
|
||||
platformStatic fun test1() = b
|
||||
|
||||
platformStatic fun test2() = b
|
||||
|
||||
platformStatic fun String.test3() = this + b
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (Test.test1() != "OK") return "fail 1"
|
||||
|
||||
if (Test.test2() != "OK") return "fail 2"
|
||||
|
||||
if (Test.test3() != "JAVAOK") return "fail 3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class Test {
|
||||
|
||||
public static String test1() {
|
||||
return A.test1();
|
||||
}
|
||||
|
||||
public static String test2() {
|
||||
return A.test2();
|
||||
}
|
||||
|
||||
public static String test3() {
|
||||
return A.test3("JAVA");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
object A {
|
||||
|
||||
val b: String = "OK"
|
||||
|
||||
platformStatic fun test1() = b
|
||||
|
||||
platformStatic fun test2() = b
|
||||
|
||||
platformStatic fun String.test3() = this + b
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (Test.test1() != "OK") return "fail 1"
|
||||
|
||||
if (Test.test2() != "OK") return "fail 2"
|
||||
|
||||
if (Test.test3() != "JAVAOK") return "fail 3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user