You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 6, 2019. It is now read-only.
When executing this code both assignable1 and assignable2 evaluate to true where they actually should be false (assignable1 would only be true in case tpA would have an extends bound for String).
The text was updated successfully, but these errors were encountered:
I managed to fix the first of the two cases mentioned above (boolean assignable1 = tpString.isAssignableBy(tpA);) and I also wrote a test for that. However, the second case may not behave wrongly at all. I thought that it had to be working incorrectly because the following code snippet would not compile in java.
<T> voidfoo() {
Tt = newString();
}
But it turnes out that the isAssignable method is used when trying to figure out if a method declaration is applicable when solving a method call (regarding the method's name and the passed argument types). In this case a method declaration that specifies a parameter type T can be applicable when called with a String argument :)
It is tricky, isn't it? :D
I agree with your thinking process, and I think the only way out of this is building one example at the time. Probably I should also document better isAssignableBy. However your PR for this one looks good to me, so we are getting closer! And we also remove one "TODO" from the code
Oh yes, it's tricky. I only had to change a few lines of code but it felt like a whole day of debugging ;) Thanks for the review, I'll close this one now.
It looks like the behavior of Type.isAssignableBy(...) for TypeVariables is not implemented correctly yet. Consider the following code snippet:
When executing this code both
assignable1
andassignable2
evaluate to true where they actually should be false (assignable1
would only be true in case tpA would have anextends
bound forString
).The text was updated successfully, but these errors were encountered: