Open GoogleCodeExporter opened 9 years ago
The log shows that I used version 1.8.9. Turns out this is because I used an
old checkout of the code and performed only an `hg pull`, without an `hg
update`. I just *properly* updated the working directory and re-ran the test
using version 1.8.11. Can confirm the ticket is still valid.
Original comment by stephan...@gmail.com
on 4 Mar 2015 at 9:51
Thanks for the report! I can reproduce the issue.
Jonathan, I assigned this to you because type argument inference in the hacks
repository crashes on this example. In the trunk version inference was
imprecise, resulting in the false positive.
Original comment by wdi...@gmail.com
on 17 Mar 2015 at 4:55
I'll take a look right now.
Original comment by jbu...@cs.washington.edu
on 17 Mar 2015 at 9:19
So there a couple of issues here:
1) We are missing annotations for the Java 8 Comparator in the Annotated JDK.
I can add these no problem.
2) The crash in the type variable repo was occurring because of a failure in
type argument inference. I have fixed the crashing issue in the type variable
repo.
3) However, though type argument inference will not crash, it will not lead to
a correctly inferred type in these instances. The issue is discussed below:
Suppose we have two methods:
<T> T getT() {}
<U> void setU(U u) {}
And a call to these methods:
setU(getT())
In this case, we would first try to infer T and we would u as the "assignedTo"
value and create a constraint as follows: T <: U
And then we would infer that the call to getT was actually of the form
<U>getT()
Except U doesn't actually exist in the scope in which getT was called. In the
new type argument inference I was making the same mistake. Because U is out of
scope we encounter it in certain visitors in locations we would not expect it.
This caused the exception in the type variables repo.
To correctly handle this, we would actually have to detect these cases and
combine the inference of both T and U. For instance say we had the following
declarations:
<T> T getT(List<T> t) {}
<U> void setU(U u, List<U> u) {}
In Java (forgetting annotated types at the moment), this example would require
us to use the type of T to determine U:
setU(getT(new ArrayList<String>()), null)
Whereas this example would require us top use the type of U to determine T:
setT(getU(null), new ArrayList<String>())
So, we need to actually solve for the two type arguments simultaneously. The
new type argument inference should make this much easier but the work is still
non-trivial.
For now, I am going to fix the crash. In the long run I will fix type-argument
inference to handle these cases and at that point this example should typecheck.
Original comment by jbu...@cs.washington.edu
on 19 Mar 2015 at 10:38
Thanks for taking the time to perform such an in-depth analysis. Very excited
to hear the framework will at some point be able to handle this scenario!
Original comment by stephan...@gmail.com
on 19 Mar 2015 at 10:42
You're welcome. Thanks for catching it. We'll change this issue to pushed
when this example typechecks.
Original comment by jbu...@cs.washington.edu
on 19 Mar 2015 at 10:52
Note that this is one improvement in Java 8 type argument inference. As
discussed, rewriting the new annotated type argument inference to follow the
Java 8 logic should solve this issue and better support lambdas as well.
Original comment by wdi...@gmail.com
on 20 Mar 2015 at 2:15
Original issue reported on code.google.com by
stephan...@gmail.com
on 28 Feb 2015 at 9:33Attachments: