More detail in incompatible types compiler error
Brought to you by:
bonniot
I received this message
"Arguments (?bossa.util.Location) do not fit:
<T> nice.lang.Class<!T> getClass(!T)"
when trying to compile the following code:
Definition d....
println(d.getName().location().getClass());
I was very confused because getClass() is inherited
from object, so I couldn't see why it wouldn't work for
Location. Of course, the problem is that location()
might return null. However, it took a few minutes to
work this out. I would like a message along the lines of
"To allow s to contain the null value, it should be
declared as: ?java.lang.String s"
That is received when trying to assign a variables.
Logged In: YES
user_id=88952
Agreed, this would be a clearer message. Thanks for the
suggestion.
In this specific case, I wonder why location() returns a
null type. The default for Java methods is to return
non-null type, unless there is a specific retyping. I guess
it's because there is a field called location. We should
change the behaviour so that this rule also applies to fields.
Also note that there is a location() method in Definition,
so you could simply write:
println(d.location().getClass());