Fix generic signature for SAM adapters and constructors

SAM-related code in codegen was using JavaClassDescriptor directly, which has
an erased signature. Create and use a new abstraction SamType which has a full
generic signature of a type which was used in the SAM construct
This commit is contained in:
Alexander Udalov
2014-05-13 19:57:08 +04:00
parent 51a16fe491
commit de8b2b3668
14 changed files with 202 additions and 110 deletions
@@ -0,0 +1,8 @@
import java.util.Arrays;
import java.util.Comparator;
class JavaClass {
public static String foo(Comparator<String> comparator) {
return Arrays.toString(comparator.getClass().getGenericInterfaces());
}
}
@@ -0,0 +1,5 @@
fun box(): String {
val supertypes = JavaClass.foo { a, b -> a.compareTo(b) }
if (supertypes != "[java.util.Comparator<java.lang.String>]") return "Fail: $supertypes"
return "OK"
}
@@ -0,0 +1,9 @@
class JavaClass {
interface Computable<T> {
T compute();
}
static <T> T compute(Computable<T> computable) {
return computable.compute();
}
}
@@ -0,0 +1,8 @@
import java.util.Arrays
fun box(): String {
val r: JavaClass.Computable<String> = JavaClass.Computable { "OK" }
val supertypes = Arrays.toString(r.getClass().getGenericInterfaces())
if (supertypes != "[JavaClass.JavaClass\$Computable<java.lang.String>]") return "Fail: $supertypes"
return JavaClass.compute(r)!!
}