Created
November 16, 2016 02:50
-
-
Save aeisenberg/de558a35d09de0184be2707cfe42c921 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Collection; | |
public class Ambiguity { | |
public void foo(CriteriaBuilder builder) { | |
// change Object -> Number (or any other type) and it compiles | |
Expression<Object> objectExpression = null; | |
Expression<Collection<Object>> collectionOfObjectExpression = null; | |
builder.isNotMember(objectExpression, collectionOfObjectExpression); | |
} | |
} | |
class Expression<T> { } | |
class CriteriaBuilder { | |
public <E,C extends Collection<E>> void isNotMember(E elem, Expression<C> collection) {} | |
public <E,C extends Collection<E>> void isNotMember(Expression<E> elem, Expression<C> collection) {} | |
} |
@otrosien has a workaround in the other gist I created: https://gist.github.com/olivergierke/c644327bb89191f2b52e298427ebf201
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It still doesn't entirely make sense to me:
E
has to be bound toExpression<Object>
. That'd mean the second parameter is expected to be anExpression<Collection<Expression<Object>>>
. But we hand in aExpression<Collection<Object>>
so that shouldn't match, should it?Expression<Object>
andExpression<Collection<Object>>
, how do I tell the compiler I want to bind to the second method? There doesn't seem to be any way (through type hints, casts or the like) to get this to work.