Skip to content
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

Incorrect inference of method type arguments #93

Closed
GoogleCodeExporter opened this issue Jul 3, 2015 · 8 comments
Closed

Incorrect inference of method type arguments #93

GoogleCodeExporter opened this issue Jul 3, 2015 · 8 comments
Labels

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. A sample code is attached, download it
2. and compile it with the nullness checker processor
3. javac -processor checkers.nullness.NullnessChecker Test.java

What is the expected output? What do you see instead?

The expected output is, the first method call to (A.badMethod(T, K)) should be 
rejected.

What version of the product are you using? On what operating system?

javac 1.7.0-jsr308-1.1.2 under Ubuntu 10.10 (Linux Kernel: 2.6.35-25-generic)

Please provide any additional information below.

The thing is, the parametric polymorphic variable, which is also used as the 
return type, is miscalculated, for example, in the example that I attached, T 
(in badMethod) should be @NonNull in the same way that K should be @NonNull! 
but since it is also the return type, it is miscalculated!

Thanks for the help :)

Original issue reported on code.google.com by amanj...@gmail.com on 26 Feb 2011 at 12:55

Attachments:

@GoogleCodeExporter
Copy link
Author

Type argument inference uses the method arguments to infer the method type 
arguments.
It currently seems to assume that the arguments are correct. It needs to be 
changed to ensure that the inferred type arguments are subtypes of the declared 
upper bounds.
See tests/nullness/MethodTypeVars.java for a test case.

Thanks for the report!

Original comment by wdi...@gmail.com on 27 Feb 2011 at 12:10

  • Changed title: Incorrect inference of method type arguments
  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Hello and thanks for the reply,

Indeed, I am not sure if the bug is related to the Nullness checker or not, 
since I am programming a checker for thread locality, and I suffer the same 
thing, thus I guess it is more about the checker framework rather than the 
Nullness checker only.

Another thing, (I think) the framework only fails to check the ones which 
participate in the return type, others won't be affected!

Before I forget, I couldn't find the file, are you sure about the name?

Amanj :)

Original comment by amanj...@gmail.com on 27 Feb 2011 at 12:36

@GoogleCodeExporter
Copy link
Author

Both of your points are correct.
The issue affects the method type argument inference, which is shared by all 
checkers. The fix will benefit all checkers.
Also, currently only type variables that occur in the return type are inferred. 
I'm not sure why this restriction was chosen.

Did you pull the latest changes? I see the file here:

http://code.google.com/p/checker-framework/source/browse/checkers/tests/nullness
/MethodTypeVars.java

cu, WMD.

Original comment by wdi...@gmail.com on 27 Feb 2011 at 12:37

@GoogleCodeExporter
Copy link
Author

Amanj,
I've improved handling of method type argument inference.
If you check out trunk, you will need to adapt your methodFromUse 
implementation, if you have one. See my commits for an example of what to do.
Let me know whether this works for your checker.

Original comment by wdi...@gmail.com on 3 Mar 2011 at 2:13

  • Changed state: Pushed

@GoogleCodeExporter
Copy link
Author

See this changeset for an example of what to change:

http://code.google.com/p/checker-framework/source/detail?r=8381a213a4

Original comment by wdi...@gmail.com on 3 Mar 2011 at 2:17

@GoogleCodeExporter
Copy link
Author

Thanks a lot for the fast fix, this is really a great work. Unfortunately, I 
hadn't had time to test it yet, but once I did I will get back to you. 

Original comment by amanj...@gmail.com on 5 Mar 2011 at 8:25

@GoogleCodeExporter
Copy link
Author

Original comment by michael.ernst@gmail.com on 6 Jul 2011 at 11:54

  • Changed state: Fixed

smillst pushed a commit to smillst/checker-framework that referenced this issue Apr 5, 2019
smillst pushed a commit to smillst/checker-framework that referenced this issue Apr 5, 2019
wmdietl added a commit that referenced this issue Nov 10, 2019
Update from typetools/master 2019-08-17
flo2702 pushed a commit to flo2702/checker-framework that referenced this issue Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants