Menu ▾ ▴

#179 ":" constraint in type variables gives badly worded errors

open
nobody
None
5
2006-06-29
2006-06-29
B S
No

All nice-0.9.12.
The code:
interface A{}
<T | T : A> T f(T a);

gives the error message:
T is not a class

Which doesn't make much sense. The same error occurs if
A is an abstract interface. Worse yet, if you declare f
like using this constraint <Object T | T: A> (which
seems unlikely), you get "Object is not a class".

If you add a different class to the constraint like this:
interface A{}
<Integer T | T : A> T f(T a);

you get:
A should be an interface

Which also makes no sense. If instead A is an abstract
interface you get this message, which makes some more
sense:
The type of method f is not well formed: <T | T <
java.lang.Integer, T:test.A> (T)->T
mlsub.typing.TypingEx: Unsatisfiable 1:[NO MESSAGE]

The ":" or "implements" only works if you have
something like this:
abstract interface A{}
abstract interface B {}
<B T | T : A> T f(T a);

I assume this is how it is supposed to work, since
using <B T |T <: A> gives an error message. The only
problem is that the error messages could use some work.

Discussion


Log in to post a comment.