Return false if validation fails in commonAssignmentCheck#736
Return false if validation fails in commonAssignmentCheck#736aosen-xiong wants to merge 18 commits into
commonAssignmentCheck#736Conversation
commonAssignmentCheckcommonAssignmentCheck
|
Is any code actually using the returned value of |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates commonAssignmentCheck control flow to reflect a failed assignment check when an unexpected varType kind is encountered.
Changes:
- Switches the return value from
truetofalsein the unexpected-type branch ofcommonAssignmentCheck.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds a small dedicated test checker that triggers the validateType failure path of BaseTypeVisitor.commonAssignmentCheck(Tree, ExpressionTree, ...). The visitor's commonAssignmentCheck override emits a sentinel warning only when super returns true, which surfaces the contract violation: before the fix, super returned true after a failed validateType, causing the warning to be issued; after the fix, super correctly returns false.
Restores the return false fix in commonAssignmentCheck after the temporary revert that demonstrated the test failure. Also adds SKIP-REQUIRE-JAVADOC to skip the requireJavadoc check while this PR is in progress.
|
Are the return values used? Yes. In
Subclass overrides that compose with
Test that fails before the change: I added one and pushed it to this branch. Take a typical conflicting-annotations assignment: @CommonInvalid Object o = new Object();When The new The test checker currently lacks full Javadoc, so I added a |
wmdietl
left a comment
There was a problem hiding this comment.
Thanks for the extensive test. It seems like a very specialized test. I'm not sure we need to keep it around. Do you think we'll have any use for it in the future?
Is there no existing checker where we could cause a type.invalid error?
Thanks, that makes sense. I replaced the dedicated
So yes, we can use an existing checker, and the specialized checker is gone. |
wmdietl
left a comment
There was a problem hiding this comment.
Nice way to test it! One question about a warning we no longer get.
| public class TypeRefinement { | ||
| // :: warning: (cast.unsafe.constructor.invocation) | ||
| @H1Top Object o = new @H1S1 Object(); | ||
| // :: error: (h1h2checker.h1invalid.forbidden) :: warning: (cast.unsafe.constructor.invocation) |
There was a problem hiding this comment.
Does it make sense that the cast.unsafe.constructor.invocation warning is gone?
No description provided.