Function types versus arrays
Howard Lovatt
howard.lovatt at iee.org
Thu Feb 18 02:41:13 PST 2010
The example:
class Ex {
static #String()[] array = new #String()[1];
static Object[] objectArray = array;
static <T> void impossible() {
final T t = null;
objectArray[0] = #()(t); // assign a function of type #T()
into objectArray
}
}
Using reified lambdas:
http://www.artima.com/weblogs/viewpost.jsp?thread=278567
Would allow both Ex.<String>impossible() and Ex.<Integer>impossible()
since null is always assignable to #String(). This is similar to:
class Ex {
static String[] array = new String[1];
static Object[] objectArray = array;
static <T> void impossible() {
final T t = null;
objectArray[0] = t; // assign a T into objectArray
}
}
Therefore the reified lambda behavior would be consistent with
generics (maybe not liked behavior - but expected!).
-- Howard.
More information about the lambda-dev
mailing list