Initial implementation of platformStatic
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
open class B {
|
||||
val p = "OK"
|
||||
}
|
||||
|
||||
class BB : B()
|
||||
|
||||
trait Z<T :B > {
|
||||
fun T.getString() : String {
|
||||
return p
|
||||
}
|
||||
|
||||
fun test(s: T) : String {
|
||||
return s.extension()
|
||||
}
|
||||
|
||||
private fun T.extension(): String {
|
||||
return getString()
|
||||
}
|
||||
}
|
||||
|
||||
object Z2 : Z<BB> {
|
||||
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
return Z2.test(BB())
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
object A {
|
||||
|
||||
val b: String = "OK"
|
||||
|
||||
platformStatic fun test1() : String {
|
||||
return b
|
||||
}
|
||||
|
||||
platformStatic fun test2() : String {
|
||||
return test1()
|
||||
}
|
||||
|
||||
fun test3(): String {
|
||||
return "1".test5()
|
||||
}
|
||||
|
||||
platformStatic fun test4(): String {
|
||||
return "1".test5()
|
||||
}
|
||||
|
||||
platformStatic fun String.test5() : String {
|
||||
return this + b
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (A.(A::test1)() != "OK") return "fail 1"
|
||||
|
||||
if (A.(A::test2)() != "OK") return "fail 2"
|
||||
|
||||
if (A.(A::test3)() != "1OK") return "fail 3"
|
||||
|
||||
if (A.(A::test4)() != "1OK") return "fail 4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
object A {
|
||||
|
||||
val b: String = "OK"
|
||||
|
||||
platformStatic fun test1() : String {
|
||||
return {b}()
|
||||
}
|
||||
|
||||
platformStatic fun test2() : String {
|
||||
return {test1()}()
|
||||
}
|
||||
|
||||
fun test3(): String {
|
||||
return {"1".test5()}()
|
||||
}
|
||||
|
||||
platformStatic fun test4(): String {
|
||||
return {"1".test5()}()
|
||||
}
|
||||
|
||||
platformStatic fun String.test5() : String {
|
||||
return {this + b}()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (A.test1() != "OK") return "fail 1"
|
||||
|
||||
if (A.test2() != "OK") return "fail 2"
|
||||
|
||||
if (A.test3() != "1OK") return "fail 3"
|
||||
|
||||
if (A.test4() != "1OK") return "fail 4"
|
||||
|
||||
if (with(A) {"1".test5()} != "1OK") return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
class B(var s: Int = 0) {
|
||||
|
||||
}
|
||||
|
||||
object A {
|
||||
|
||||
fun test1(v: B) {
|
||||
v += B(1000)
|
||||
}
|
||||
|
||||
platformStatic fun B.plusAssign(b: B) {
|
||||
this.s += b.s
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
val b1 = B(11)
|
||||
|
||||
with(A) {
|
||||
b1 += B(1000)
|
||||
}
|
||||
|
||||
if (b1.s != 1011) return "fail 1"
|
||||
|
||||
val b = B(11)
|
||||
A.test1(b)
|
||||
if (b.s != 1011) return "fail 2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
object A {
|
||||
|
||||
platformStatic fun test(b: String = "OK") : String {
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
if (A.test() != "OK") return "fail 1"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
object AX {
|
||||
|
||||
platformStatic fun aStatic(): String {
|
||||
return AX.b()
|
||||
}
|
||||
|
||||
fun aNonStatic(): String {
|
||||
return AX.b()
|
||||
}
|
||||
|
||||
platformStatic fun b(): String {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
|
||||
if (AX.aStatic() != "OK") return "fail 1"
|
||||
|
||||
if (AX.aNonStatic() != "OK") return "fail 1"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
object A {
|
||||
|
||||
platformStatic inline fun test(b: String = "OK") : String {
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
if (A.test() != "OK") return "fail 1"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
object A {
|
||||
|
||||
val b: String = "OK"
|
||||
|
||||
platformStatic fun test1() : String {
|
||||
return b
|
||||
}
|
||||
|
||||
platformStatic fun test2() : String {
|
||||
return test1()
|
||||
}
|
||||
|
||||
fun test3(): String {
|
||||
return "1".test5()
|
||||
}
|
||||
|
||||
platformStatic fun test4(): String {
|
||||
return "1".test5()
|
||||
}
|
||||
|
||||
platformStatic fun String.test5() : String {
|
||||
return this + b
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (A.test1() != "OK") return "fail 1"
|
||||
|
||||
if (A.test2() != "OK") return "fail 2"
|
||||
|
||||
if (A.test3() != "1OK") return "fail 3"
|
||||
|
||||
if (A.test4() != "1OK") return "fail 4"
|
||||
|
||||
if (with(A) {"1".test5()} != "1OK") return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user