-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Anys, not wildcards, for converter output types #139
Conversation
4733b4d
to
340c806
Compare
340c806
to
6fe3990
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Very clean. I just have two tiny nitpicks, and one slightly less tiny nitpick. But nothing that should hold up a merge.
if (t instanceof TypeVariable<?>) { | ||
TypeVariable<?> tv = (TypeVariable<?>) t; | ||
return Nil.of(new Any(tv.getBounds())); | ||
} | ||
var vars = new HashMap<TypeVariable<?>, Type>(); | ||
for (Type typeParam : typeParams) { | ||
if (typeParam instanceof TypeVariable<?>) { | ||
// Get the type variable | ||
TypeVariable<?> from = (TypeVariable<?>) typeParam; | ||
// Create a wildcard type with the type variable bounds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is no longer correct.
@@ -55,7 +55,7 @@ public class IdentityCollection<T, U extends T> implements OpCollection { | |||
@OpHints(hints = { Conversion.FORBIDDEN, | |||
BaseOpHints.DependencyMatching.FORBIDDEN }) | |||
@OpField(names = "engine.convert, engine.identity", priority = Priority.FIRST) | |||
public final Function<U, T> identity = (t) -> t; | |||
public final Function<T, T> identity = (t) -> t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parens are unnecessary; you can just write t -> t
.
* Op. | ||
* </p> | ||
*/ | ||
@OpMethod(names = "test.boundsConversion", type = BiFunction.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once again I got confused by the name of this op. It's weird to me that we have test ops named after the functionality being tested rather than named for what they do like normal ops. In this case, the op test.boundsConversion
is a static method named foo
(which I find unhelpful in understanding) and it returns the max of two objects. So why not name it "max" instead? Especially since the functionality being tested here, multiple type bounds, is also a sort of comparison, which was the source of my momentary confusion: "What does x > y ? x : y
have to do with multiple bounds?" I thought, "It's just one bound..."
Wildcard types are problematic due to the restrictions on e.g. the number of bounds.
Any
s are more flexible in this regard, and better reflect our needs.TODO: