Type equality for values
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Fri Aug 1 18:14:46 UTC 2014
If by 'realizable' you mean non-denotable, then there are several other
places where inference infers non-denotable types:
<Z> Z choose(Z z1, Z z2) { ... }
choose(1, "");
So I wouldn't be too worried about it at this stage. Of course, in the
long run this would be bad for the type-specialization story as I don't
think we want to end up with an instantiated generic method where Z (or
T in your example) is any.
Maurizio
On 01/08/14 10:10, Paul Govereau wrote:
> The following code is valid for reference types:
>
> class A<T> {
> int x = 0;
>
> <T,U> boolean foo(A<T> a, A<U> b) {
> return (a == b);
> }
> }
>
> However, I don't think this makes sense for value types. In the case
> of reference types, the "top" is a realizable type, namely Object;
> but, for values the "top" is not realizable?
>
> final __ByValue class A<T> {
> final int x = 0;
>
> <any T, any U> boolean foo(A<T> a, A<U> b) {
> return (a == b); // <<--- type error ??
> }
> }
>
> Should this be a type error?
>
> Paul
More information about the valhalla-dev
mailing list