-
Notifications
You must be signed in to change notification settings - Fork 62
Troublesome cast from Java object to Java HashMap and ceylonification via CeylonMap #7442
Comments
I don't think this is a compelling example for the change. The narrowing issue is largely orthogonal to null safety introp. You might also want to narrow to Types like Finally, IIRC there already is an upper bound on TPs of methods, and long ago @renatoathaydes pointed out some real usability problems with it (but I don't recall the details.) |
Java type parameters can't have default type arguments, so perhaps the syntax That is, have implied default arguments of if (is JHashMap<> obj) {
assert (is JHashMap<out Object, out Anything> obj);
value map = CeylonMap(obj);
... |
Hey guys, good to see you're still making improvements... @jvasileff I can't remember the compatibility issues anymore, but honestly, in this case I don't fault Ceylon at all... if you have an |
Here’s the old issue: I suspect, given enough time thinking through this, the conclusion would be to remove the constraint on method TPS rather than adding one to type TPs. Take note of @renatoathaydes comment “but I need to return Null as well“ and that we also want to have flexibility when refining Java types. |
I wanted to check if a Java object is a Java
HashMap
and iff then pass it toCeylonMap
, so with some guidance I was trying to use:A workaround is to use e.g.
.. which only gives a warning for the assert line.
Based on discussions with @gavinking we were considering that "perhaps ... there should be an implied upper bound of
Object
on all Java type args".... but the question is perhaps also what to do with the fact that Java
HashMap
s can have null keys while theCeylonMap
adapter just assumes there are no null keys in the given maps and declare that theKey
type parameter does not intersect withNull
. ChangingCeylonMap
to accept JavaHashMap
s with null keys but to satisfy theMap
interface with non-null keys and do the filtering internally would perhaps be an option?The text was updated successfully, but these errors were encountered: