Migrate boxAgainstJava tests to multi-file framework
This commit is contained in:
-7
@@ -1,7 +0,0 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
String[] value() default {"d1", "d2"};
|
||||
}
|
||||
+12
@@ -1,3 +1,15 @@
|
||||
// FILE: JavaAnn.java
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
String[] value() default {"d1", "d2"};
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
@JavaAnn class MyClass1
|
||||
@JavaAnn() class MyClass2
|
||||
@JavaAnn("asd") class MyClass3
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
String[] value();
|
||||
}
|
||||
+12
@@ -1,3 +1,15 @@
|
||||
// FILE: JavaAnn.java
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
String[] value();
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
@JavaAnn class MyClass1
|
||||
@JavaAnn() class MyClass2
|
||||
@JavaAnn("asd") class MyClass3
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
String value();
|
||||
}
|
||||
@@ -1,3 +1,15 @@
|
||||
// FILE: JavaAnn.java
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
String value();
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
@JavaAnn("value") class MyClass
|
||||
|
||||
fun box(): String {
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
String value() default "default";
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn2 {
|
||||
int a() default 1;
|
||||
byte b() default 1;
|
||||
short c() default 1;
|
||||
double d() default 1;
|
||||
float e() default 1;
|
||||
long j() default 1;
|
||||
String f() default "default";
|
||||
}
|
||||
+28
@@ -1,3 +1,31 @@
|
||||
// FILE: JavaAnn.java
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
String value() default "default";
|
||||
}
|
||||
|
||||
// FILE: JavaAnn2.java
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn2 {
|
||||
int a() default 1;
|
||||
byte b() default 1;
|
||||
short c() default 1;
|
||||
double d() default 1;
|
||||
float e() default 1;
|
||||
long j() default 1;
|
||||
String f() default "default";
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
@JavaAnn class MyClass
|
||||
@JavaAnn2 class MyClass2
|
||||
|
||||
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
class Foo {
|
||||
public static final int i = -2;
|
||||
public static final short s = -2;
|
||||
public static final float f = -2f;
|
||||
public static final double d = -2.0;
|
||||
public static final long l = -2L;
|
||||
public static final byte b = -2;
|
||||
}
|
||||
Vendored
+14
-1
@@ -1,3 +1,16 @@
|
||||
// FILE: Foo.java
|
||||
|
||||
class Foo {
|
||||
public static final int i = -2;
|
||||
public static final short s = -2;
|
||||
public static final float f = -2f;
|
||||
public static final double d = -2.0;
|
||||
public static final long l = -2L;
|
||||
public static final byte b = -2;
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
@Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b) class MyClass
|
||||
|
||||
fun box(): String {
|
||||
@@ -20,4 +33,4 @@ annotation class Ann(
|
||||
val d: Double,
|
||||
val l: Long,
|
||||
val b: Byte
|
||||
)
|
||||
)
|
||||
|
||||
Vendored
-13
@@ -1,13 +0,0 @@
|
||||
class Foo {
|
||||
public static final int i = 2;
|
||||
public static final short s = 2;
|
||||
public static final float f = 2f;
|
||||
public static final double d = 2.0;
|
||||
public static final long l = 2L;
|
||||
public static final byte b = 2;
|
||||
public static final boolean bool = true;
|
||||
public static final char c = 'c';
|
||||
public static final String str = "str";
|
||||
public static final int charAsInt = '3';
|
||||
public static final char intAsChar = 3;
|
||||
}
|
||||
+20
-2
@@ -1,8 +1,26 @@
|
||||
// FILE: Foo.java
|
||||
|
||||
class Foo {
|
||||
public static final int i = 2;
|
||||
public static final short s = 2;
|
||||
public static final float f = 2f;
|
||||
public static final double d = 2.0;
|
||||
public static final long l = 2L;
|
||||
public static final byte b = 2;
|
||||
public static final boolean bool = true;
|
||||
public static final char c = 'c';
|
||||
public static final String str = "str";
|
||||
public static final int charAsInt = '3';
|
||||
public static final char intAsChar = 3;
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
@Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b, Foo.bool, Foo.c, Foo.str, Foo.charAsInt, Foo.intAsChar) class MyClass
|
||||
|
||||
fun box(): String {
|
||||
val ann = MyClass::class.java.getAnnotation(Ann::class.java)
|
||||
if (ann == null) return "fail: cannot find Ann on MyClass}"
|
||||
if (ann == null) return "fail: cannot find Ann on MyClass"
|
||||
if (ann.i != 2) return "fail: annotation parameter i should be 2, but was ${ann.i}"
|
||||
if (ann.s != 2.toShort()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
|
||||
if (ann.f != 2.toFloat()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
|
||||
@@ -30,4 +48,4 @@ annotation class Ann(
|
||||
val str: String,
|
||||
val i2: Int,
|
||||
val c2: Char
|
||||
)
|
||||
)
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
class Foo {
|
||||
public static final int i = 2;
|
||||
public static final short s = 2;
|
||||
public static final float f = 2;
|
||||
public static final double d = 2;
|
||||
public static final long l = 2;
|
||||
public static final byte b = 2;
|
||||
public static final char c = 99;
|
||||
}
|
||||
+16
-2
@@ -1,8 +1,22 @@
|
||||
// FILE: Foo.java
|
||||
|
||||
class Foo {
|
||||
public static final int i = 2;
|
||||
public static final short s = 2;
|
||||
public static final float f = 2;
|
||||
public static final double d = 2;
|
||||
public static final long l = 2;
|
||||
public static final byte b = 2;
|
||||
public static final char c = 99;
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
@Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b, Foo.c) class MyClass
|
||||
|
||||
fun box(): String {
|
||||
val ann = MyClass::class.java.getAnnotation(Ann::class.java)
|
||||
if (ann == null) return "fail: cannot find Ann on MyClass}"
|
||||
if (ann == null) return "fail: cannot find Ann on MyClass"
|
||||
if (ann.i != 2) return "fail: annotation parameter i should be 2, but was ${ann.i}"
|
||||
if (ann.s != 2.toShort()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
|
||||
if (ann.f != 2.toFloat()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
|
||||
@@ -22,4 +36,4 @@ annotation class Ann(
|
||||
val l: Long,
|
||||
val b: Byte,
|
||||
val c: Char
|
||||
)
|
||||
)
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?>[] args();
|
||||
}
|
||||
+12
@@ -1,3 +1,15 @@
|
||||
// FILE: JavaAnn.java
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?>[] args();
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
class O
|
||||
class K
|
||||
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?>[] args();
|
||||
}
|
||||
|
||||
class O {}
|
||||
class K {}
|
||||
|
||||
@JavaAnn(args = {O.class, K.class})
|
||||
class MyJavaClass {}
|
||||
compiler/testData/codegen/boxAgainstJava/annotations/kClassMapping/arrayClassParameterOnJavaClass.kt
Vendored
+20
@@ -1,3 +1,23 @@
|
||||
// FILE: JavaAnn.java
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?>[] args();
|
||||
}
|
||||
|
||||
// FILE: MyJavaClass.java
|
||||
|
||||
class O {}
|
||||
class K {}
|
||||
|
||||
@JavaAnn(args = {O.class, K.class})
|
||||
class MyJavaClass {}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val args = MyJavaClass::class.java.getAnnotation(JavaAnn::class.java).args
|
||||
val argName1 = args[0].simpleName ?: "fail 1"
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?> value();
|
||||
}
|
||||
+11
@@ -1,3 +1,14 @@
|
||||
// FILE: JavaAnn.java
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?> value();
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
class OK
|
||||
|
||||
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?> value();
|
||||
}
|
||||
|
||||
class OK {}
|
||||
|
||||
@JavaAnn(OK.class)
|
||||
class MyJavaClass {}
|
||||
Vendored
+18
@@ -1,3 +1,21 @@
|
||||
// FILE: JavaAnn.java
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?> value();
|
||||
}
|
||||
|
||||
// FILE: MyJavaClass.java
|
||||
|
||||
class OK {}
|
||||
|
||||
@JavaAnn(OK.class)
|
||||
class MyJavaClass {}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val ann = MyJavaClass::class.java.getAnnotation(JavaAnn::class.java)
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?>[] value();
|
||||
}
|
||||
+12
@@ -1,3 +1,15 @@
|
||||
// FILE: JavaAnn.java
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?>[] value();
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
class O
|
||||
class K
|
||||
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?>[] value();
|
||||
}
|
||||
|
||||
class O {}
|
||||
class K {}
|
||||
|
||||
@JavaAnn({O.class, K.class})
|
||||
class MyJavaClass {}
|
||||
+20
@@ -1,3 +1,23 @@
|
||||
// FILE: JavaAnn.java
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?>[] value();
|
||||
}
|
||||
|
||||
class O {}
|
||||
class K {}
|
||||
|
||||
// FILE: MyJavaClass.java
|
||||
|
||||
@JavaAnn({O.class, K.class})
|
||||
class MyJavaClass {}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
class O
|
||||
class K
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@interface Foo {
|
||||
}
|
||||
@@ -1,8 +1,17 @@
|
||||
import java.lang.annotation.*
|
||||
// FILE: Foo.java
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@interface Foo {
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
@Foo class Bar
|
||||
|
||||
fun box(): String {
|
||||
Bar()
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
class A {
|
||||
public A(double x, int y) { }
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
// FILE: A.java
|
||||
|
||||
class A {
|
||||
public A(double x, int y) { }
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
(::A)(0.0, 0)
|
||||
return "OK"
|
||||
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
public class publicFinalField {
|
||||
public final String field = "OK";
|
||||
}
|
||||
+9
-1
@@ -1 +1,9 @@
|
||||
fun box() = (publicFinalField::field).get(publicFinalField())
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public final String field = "OK";
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box() = (A::field).get(A())
|
||||
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
public class publicMutableField {
|
||||
public int field = 239;
|
||||
}
|
||||
+7
-1
@@ -1,4 +1,10 @@
|
||||
import publicMutableField as A
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public int field = 239;
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class A {
|
||||
public static void main(String[] args) {
|
||||
args[0] = "OK";
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,13 @@
|
||||
// FILE: A.java
|
||||
|
||||
class A {
|
||||
public static void main(String[] args) {
|
||||
args[0] = "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val args = arrayOf("Fail")
|
||||
(A::main)(args)
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package test;
|
||||
|
||||
public class genericConstructor<T extends Number> {
|
||||
public genericConstructor(T number) {}
|
||||
}
|
||||
+12
-2
@@ -1,6 +1,16 @@
|
||||
import test.genericConstructor
|
||||
// FILE: test/Foo.java
|
||||
|
||||
class Subclass : genericConstructor<Int>(42) {
|
||||
package test;
|
||||
|
||||
public class Foo<T extends Number> {
|
||||
public Foo(T number) {}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import test.Foo
|
||||
|
||||
class Subclass : Foo<Int>(42) {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package test;
|
||||
|
||||
public class secondaryConstructor {
|
||||
private final String x;
|
||||
private final String y;
|
||||
|
||||
public secondaryConstructor(String x, String y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public secondaryConstructor(String x) {
|
||||
this(x, "def_y");
|
||||
}
|
||||
|
||||
public secondaryConstructor() {
|
||||
this("def_x");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + "#" + y;
|
||||
}
|
||||
}
|
||||
+31
-2
@@ -1,6 +1,35 @@
|
||||
import test.secondaryConstructor;
|
||||
// FILE: test/Foo.java
|
||||
|
||||
class Child : secondaryConstructor {
|
||||
package test;
|
||||
|
||||
public class Foo {
|
||||
private final String x;
|
||||
private final String y;
|
||||
|
||||
public Foo(String x, String y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public Foo(String x) {
|
||||
this(x, "def_y");
|
||||
}
|
||||
|
||||
public Foo() {
|
||||
this("def_x");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + "#" + y;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import test.Foo;
|
||||
|
||||
class Child : Foo {
|
||||
constructor(): super() {}
|
||||
constructor(x: String): super(x) {}
|
||||
constructor(x: String, y: String): super(x, y) {}
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
import java.util.Set;
|
||||
|
||||
public class delegationAndInheritanceFromJava {
|
||||
public interface A extends Set<String> {}
|
||||
|
||||
public interface B extends Set<String> {}
|
||||
}
|
||||
+13
-1
@@ -1,4 +1,16 @@
|
||||
import delegationAndInheritanceFromJava.*
|
||||
// FILE: Foo.java
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class Foo {
|
||||
public interface A extends Set<String> {}
|
||||
|
||||
public interface B extends Set<String> {}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import Foo.*
|
||||
import java.util.HashSet
|
||||
|
||||
class Impl(b: B): A, B by b
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package test;
|
||||
|
||||
public enum simpleJavaEnum {
|
||||
A;
|
||||
}
|
||||
@@ -1,5 +1,15 @@
|
||||
// FILE: test/En.java
|
||||
|
||||
package test;
|
||||
|
||||
public enum En {
|
||||
A;
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box() =
|
||||
if (simpleJavaEnum.A.toString() == "A") "OK"
|
||||
if (En.A.toString() == "A") "OK"
|
||||
else "fail"
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package test;
|
||||
|
||||
import java.lang.Override;
|
||||
import java.lang.String;
|
||||
|
||||
public enum simpleJavaEnumWithFunction {
|
||||
A {
|
||||
@Override
|
||||
public String repr() {
|
||||
return "A";
|
||||
}
|
||||
},
|
||||
B;
|
||||
|
||||
public String repr() {
|
||||
return "ololol" + toString();
|
||||
}
|
||||
}
|
||||
+24
-1
@@ -1,4 +1,27 @@
|
||||
import test.simpleJavaEnumWithFunction.*
|
||||
// FILE: test/En.java
|
||||
|
||||
package test;
|
||||
|
||||
import java.lang.Override;
|
||||
import java.lang.String;
|
||||
|
||||
public enum En {
|
||||
A {
|
||||
@Override
|
||||
public String repr() {
|
||||
return "A";
|
||||
}
|
||||
},
|
||||
B;
|
||||
|
||||
public String repr() {
|
||||
return "ololol" + toString();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import test.En.*
|
||||
|
||||
fun box() =
|
||||
if (A.repr() == "A" && B.repr() == "olololB") "OK"
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package test;
|
||||
|
||||
public enum simpleJavaEnumWithStaticImport {
|
||||
A;
|
||||
}
|
||||
+11
-1
@@ -1,4 +1,14 @@
|
||||
import test.simpleJavaEnumWithStaticImport.A
|
||||
// FILE: test/En.java
|
||||
|
||||
package test;
|
||||
|
||||
public enum En {
|
||||
A;
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import test.En.A
|
||||
|
||||
fun box() =
|
||||
if (A.toString() == "A") "OK"
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package test;
|
||||
|
||||
public class simpleJavaInnerEnum {
|
||||
public enum MyEnum {
|
||||
A;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,18 @@
|
||||
// FILE: test/Foo.java
|
||||
|
||||
package test;
|
||||
|
||||
public class Foo {
|
||||
public enum MyEnum {
|
||||
A;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import test.*
|
||||
import test.simpleJavaInnerEnum.MyEnum.A
|
||||
import test.Foo.MyEnum.A
|
||||
|
||||
fun box() =
|
||||
if (simpleJavaInnerEnum.MyEnum.A.toString() == "A" && A.toString() == "A") "OK"
|
||||
if (Foo.MyEnum.A.toString() == "A" && A.toString() == "A") "OK"
|
||||
else "fail"
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package test;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public enum staticField {
|
||||
INSTANCE;
|
||||
|
||||
public static int foo = 42;
|
||||
|
||||
public static final Set<staticField> INSTANCES = EnumSet.of(INSTANCE);
|
||||
}
|
||||
@@ -1,4 +1,21 @@
|
||||
import test.staticField as E
|
||||
// FILE: test/E.java
|
||||
|
||||
package test;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public enum E {
|
||||
INSTANCE;
|
||||
|
||||
public static int foo = 42;
|
||||
|
||||
public static final Set<E> INSTANCES = EnumSet.of(INSTANCE);
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import test.E
|
||||
|
||||
fun box(): String {
|
||||
val instances = E.INSTANCES
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package test;
|
||||
|
||||
public enum staticMethod {
|
||||
ENTRY;
|
||||
|
||||
public static String foo() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
@@ -1 +1,15 @@
|
||||
fun box() = test.staticMethod.foo()
|
||||
// FILE: test/En.java
|
||||
|
||||
package test;
|
||||
|
||||
public enum En {
|
||||
ENTRY;
|
||||
|
||||
public static String foo() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box() = test.En.foo()
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
class A {
|
||||
public A() {}
|
||||
|
||||
public A(String x) {}
|
||||
|
||||
public A(long l, double z) {}
|
||||
}
|
||||
@@ -1,3 +1,15 @@
|
||||
// FILE: A.java
|
||||
|
||||
class A {
|
||||
public A() {}
|
||||
|
||||
public A(String x) {}
|
||||
|
||||
public A(long l, double z) {}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
A()
|
||||
A("")
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import java.util.*;
|
||||
|
||||
public class max {
|
||||
public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll) {
|
||||
return Collections.max(coll);
|
||||
}
|
||||
}
|
||||
+14
-2
@@ -1,3 +1,15 @@
|
||||
fun box(): String {
|
||||
return max.max(java.util.Arrays.asList("AK", "OK", "EK"))!!
|
||||
// FILE: Foo.java
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Foo {
|
||||
public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll) {
|
||||
return Collections.max(coll);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
return Foo.max(java.util.Arrays.asList("AK", "OK", "EK"))!!
|
||||
}
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
class R {
|
||||
public static class id {
|
||||
public static final int main = 17;
|
||||
}
|
||||
}
|
||||
+10
@@ -1,2 +1,12 @@
|
||||
// FILE: R.java
|
||||
|
||||
class R {
|
||||
public static class id {
|
||||
public static final int main = 17;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box() =
|
||||
if (R.id.main == 17) "OK" else "fail"
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
class R {
|
||||
public static class id {
|
||||
public static class zzz {
|
||||
public static final int main = 17;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -1,2 +1,14 @@
|
||||
// FILE: R.java
|
||||
|
||||
class R {
|
||||
public static class id {
|
||||
public static class zzz {
|
||||
public static final int main = 17;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box() =
|
||||
if (R.id.zzz.main == 17) "OK" else "fail"
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import java.util.Collection;
|
||||
|
||||
public class unrelatedUpperBounds {
|
||||
public static <T extends CharSequence & java.io.Serializable> T id(T p) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
+14
-2
@@ -1,3 +1,15 @@
|
||||
fun box(): String {
|
||||
return unrelatedUpperBounds.id("OK" as java.lang.String)!! as kotlin.String
|
||||
// FILE: Foo.java
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class Foo {
|
||||
public static <T extends CharSequence & java.io.Serializable> T id(T p) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
return Foo.id("OK" as java.lang.String)!! as kotlin.String
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
public class kt3532 {
|
||||
public class Inner { }
|
||||
}
|
||||
@@ -1,4 +1,12 @@
|
||||
// FILE: Foo.java
|
||||
|
||||
public class Foo {
|
||||
public class Inner { }
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
kt3532().Inner()
|
||||
Foo().Inner()
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
public class kt3812 {
|
||||
public class Inner {
|
||||
|
||||
}
|
||||
|
||||
public class Inner$ {
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,18 @@
|
||||
// FILE: Foo.java
|
||||
|
||||
public class Foo {
|
||||
public class Inner {
|
||||
|
||||
}
|
||||
|
||||
public class Inner$ {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
kt3812().Inner()
|
||||
kt3812().`Inner$`()
|
||||
Foo().Inner()
|
||||
Foo().`Inner$`()
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
public class kt4036 {
|
||||
public class Inner1$class {
|
||||
|
||||
}
|
||||
|
||||
public class Inner2$class {
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,17 @@
|
||||
// FILE: Foo.java
|
||||
|
||||
public class Foo {
|
||||
public class Inner1$class {
|
||||
}
|
||||
|
||||
public class Inner2$class {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
kt4036().`Inner1$class`()
|
||||
kt4036().`Inner2$class`()
|
||||
Foo().`Inner1$class`()
|
||||
Foo().`Inner2$class`()
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
interface A {
|
||||
void foo();
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
// FILE: A.java
|
||||
|
||||
interface A {
|
||||
void foo();
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
internal interface B : A {
|
||||
fun bar() = 1
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
public class Delegation {
|
||||
public static class ReturnNull {
|
||||
public String foo() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
class RightElvisOperand {
|
||||
static String foo() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+13
-1
@@ -1,3 +1,15 @@
|
||||
// FILE: Delegation.java
|
||||
|
||||
public class Delegation {
|
||||
public static class ReturnNull {
|
||||
public String foo() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
interface Tr {
|
||||
fun foo(): String
|
||||
}
|
||||
@@ -18,4 +30,4 @@ fun box(): String {
|
||||
println(e.message)
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -1,3 +1,13 @@
|
||||
// FILE: RightElvisOperand.java
|
||||
|
||||
class RightElvisOperand {
|
||||
static String foo() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun baz(): String? = null
|
||||
|
||||
fun bar(): String = baz() ?: RightElvisOperand.foo()
|
||||
@@ -1,11 +0,0 @@
|
||||
public class GenericUnit {
|
||||
public static class Key<T> {}
|
||||
|
||||
public static <T> T getNull(Key<T> key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> T get(Key<T> key, T t) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
+18
-2
@@ -1,4 +1,20 @@
|
||||
import GenericUnit.*
|
||||
// FILE: Foo.java
|
||||
|
||||
public class Foo {
|
||||
public static class Key<T> {}
|
||||
|
||||
public static <T> T getNull(Key<T> key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> T get(Key<T> key, T t) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import Foo.*
|
||||
|
||||
val key = Key<Unit>()
|
||||
|
||||
@@ -14,4 +30,4 @@ fun box(): String {
|
||||
if (n3 != Unit) return "Fail 3.1: $n3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
public class fieldAccessFromExtensionInTraitImpl {
|
||||
public final String result = "OK";
|
||||
}
|
||||
+8
-2
@@ -1,6 +1,12 @@
|
||||
// KT-4878
|
||||
// FILE: D.java
|
||||
|
||||
import fieldAccessFromExtensionInTraitImpl as D
|
||||
public class D {
|
||||
public final String result = "OK";
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
// KT-4878
|
||||
|
||||
interface T {
|
||||
fun Int.foo(d: D) = d.result!!
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
public class fieldAccessViaSubclass {
|
||||
public String fieldO;
|
||||
|
||||
public static String fieldK;
|
||||
}
|
||||
+15
-6
@@ -1,12 +1,21 @@
|
||||
// FILE: D.java
|
||||
|
||||
public class D {
|
||||
public String fieldO;
|
||||
|
||||
public static String fieldK;
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
// KT-3492
|
||||
|
||||
class MyWrongClass : fieldAccessViaSubclass() {
|
||||
|
||||
class MyWrongClass : D() {
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val clazz = MyWrongClass()
|
||||
clazz.fieldO = "O"
|
||||
fieldAccessViaSubclass.fieldK = "K"
|
||||
return clazz.fieldO!! + fieldAccessViaSubclass.fieldK!!
|
||||
val clazz = MyWrongClass()
|
||||
clazz.fieldO = "O"
|
||||
D.fieldK = "K"
|
||||
return clazz.fieldO!! + D.fieldK!!
|
||||
}
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package test;
|
||||
|
||||
public class referenceToJavaFieldViaBridge {
|
||||
|
||||
protected String field = "OK";
|
||||
|
||||
}
|
||||
+11
-3
@@ -1,8 +1,16 @@
|
||||
// FILE: test/D.java
|
||||
|
||||
import test.referenceToJavaFieldViaBridge
|
||||
package test;
|
||||
|
||||
class A : referenceToJavaFieldViaBridge() {
|
||||
public class D {
|
||||
protected String field = "OK";
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import test.D
|
||||
|
||||
class A : D() {
|
||||
fun a(): String {
|
||||
return {field!!}()
|
||||
}
|
||||
@@ -10,4 +18,4 @@ class A : referenceToJavaFieldViaBridge() {
|
||||
|
||||
fun box(): String {
|
||||
return A().a()
|
||||
}
|
||||
}
|
||||
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
public class javaClassLiteral {
|
||||
}
|
||||
+7
-2
@@ -1,8 +1,13 @@
|
||||
import javaClassLiteral as J
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String {
|
||||
val j = J::class
|
||||
if (j.simpleName != "javaClassLiteral") return "Fail: ${j.simpleName}"
|
||||
if (j.simpleName != "J") return "Fail: ${j.simpleName}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
public class jClass2kClass {}
|
||||
+5
-1
@@ -1,4 +1,8 @@
|
||||
import jClass2kClass as J
|
||||
// FILE: J.java
|
||||
|
||||
public class J {}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import kotlin.reflect.jvm.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
public class javaConstructor {
|
||||
public final String result;
|
||||
|
||||
public javaConstructor(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
+12
-1
@@ -1,6 +1,17 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public final String result;
|
||||
|
||||
public J(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
import kotlin.reflect.jvm.*
|
||||
import javaConstructor as J
|
||||
|
||||
fun box(): String {
|
||||
val reference = ::J
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
public class javaFields {
|
||||
public final int i;
|
||||
public String s;
|
||||
|
||||
public javaFields(int i, String s) {
|
||||
this.i = i;
|
||||
this.s = s;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,17 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public final int i;
|
||||
public String s;
|
||||
|
||||
public J(int i, String s) {
|
||||
this.i = i;
|
||||
this.s = s;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
// FULL_JDK
|
||||
import javaFields as J
|
||||
|
||||
import java.lang.reflect.*
|
||||
import kotlin.reflect.*
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
public class javaMethods {
|
||||
public String f(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
public static String g(String s) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
+14
-1
@@ -1,6 +1,19 @@
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public String f(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
public static String g(String s) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
import kotlin.reflect.jvm.*
|
||||
import javaMethods as J
|
||||
|
||||
fun box(): String {
|
||||
val f = J::f
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
package test;
|
||||
|
||||
public class equalsHashCodeToString {
|
||||
public final boolean b;
|
||||
public char c;
|
||||
|
||||
public equalsHashCodeToString() {
|
||||
this.b = false;
|
||||
this.c = '0';
|
||||
}
|
||||
}
|
||||
+18
-3
@@ -1,11 +1,26 @@
|
||||
// FILE: test/J.java
|
||||
|
||||
package test;
|
||||
|
||||
public class J {
|
||||
public final boolean b;
|
||||
public char c;
|
||||
|
||||
public J() {
|
||||
this.b = false;
|
||||
this.c = '0';
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.test.*
|
||||
import test.equalsHashCodeToString as J
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("val test.equalsHashCodeToString.b: kotlin.Boolean", (J::b).toString())
|
||||
assertEquals("var test.equalsHashCodeToString.c: kotlin.Char", (J::c).toString())
|
||||
assertEquals("val test.J.b: kotlin.Boolean", (J::b).toString())
|
||||
assertEquals("var test.J.c: kotlin.Char", (J::c).toString())
|
||||
|
||||
assertTrue(J::b == J::b)
|
||||
assertFalse(J::c == J::b)
|
||||
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
class JavaClass {
|
||||
public interface Super1<T> {
|
||||
Thread call(T t);
|
||||
}
|
||||
|
||||
public interface Super2<T> {
|
||||
T call(String s);
|
||||
}
|
||||
|
||||
public interface Sub extends Super1<String>, Super2<Thread> {
|
||||
Thread call(String s);
|
||||
}
|
||||
|
||||
static void samAdapter(Sub sub) {
|
||||
((Super1) sub).call("");
|
||||
((Super2) sub).call("");
|
||||
sub.call("");
|
||||
}
|
||||
}
|
||||
+24
@@ -1,3 +1,27 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
class JavaClass {
|
||||
public interface Super1<T> {
|
||||
Thread call(T t);
|
||||
}
|
||||
|
||||
public interface Super2<T> {
|
||||
T call(String s);
|
||||
}
|
||||
|
||||
public interface Sub extends Super1<String>, Super2<Thread> {
|
||||
Thread call(String s);
|
||||
}
|
||||
|
||||
static void samAdapter(Sub sub) {
|
||||
((Super1) sub).call("");
|
||||
((Super2) sub).call("");
|
||||
sub.call("");
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun box(): String? {
|
||||
var s: String?
|
||||
s = "FAIL for function literal"
|
||||
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
// KT-5912
|
||||
class JavaClass<T> {
|
||||
public static interface Action<T> {
|
||||
void call(T t);
|
||||
}
|
||||
|
||||
public static class Some<T> {
|
||||
public Some(T t) {
|
||||
}
|
||||
}
|
||||
|
||||
public static interface OnSubscribe<T> extends Action<Some<T>> {}
|
||||
|
||||
void perform(T t, OnSubscribe<T> subscribe) {
|
||||
subscribe.call(new Some(t));
|
||||
}
|
||||
}
|
||||
+22
@@ -1,3 +1,25 @@
|
||||
// FILE: JavaClass.java
|
||||
|
||||
// KT-5912
|
||||
class JavaClass<T> {
|
||||
public static interface Action<T> {
|
||||
void call(T t);
|
||||
}
|
||||
|
||||
public static class Some<T> {
|
||||
public Some(T t) {
|
||||
}
|
||||
}
|
||||
|
||||
public static interface OnSubscribe<T> extends Action<Some<T>> {}
|
||||
|
||||
void perform(T t, OnSubscribe<T> subscribe) {
|
||||
subscribe.call(new Some(t));
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
// KT-5912
|
||||
fun box(): String {
|
||||
var s = "Failt"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user