-
Notifications
You must be signed in to change notification settings - Fork 39
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
Prevent NestedOptionals
from throwing an NPE
#412
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -39,4 +39,19 @@ void identification() { | |||||
"}") | ||||||
.doTest(); | ||||||
} | ||||||
|
||||||
@Test | ||||||
void failingTypeCheck() { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Slightly more in line which what we do in a few other places
Suggested change
(Funny: I tried to replace the |
||||||
compilationTestHelper | ||||||
.addSourceLines( | ||||||
"B.java", | ||||||
"import java.time.temporal.ChronoUnit;", | ||||||
"", | ||||||
"class B {", | ||||||
" void m() {", | ||||||
" java.time.Duration.of(1, ChronoUnit.YEARS);", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest using a slightly more realistic case ;)
|
||||||
" }", | ||||||
"}") | ||||||
.doTest(); | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, so I guess that the issue happens if the
Optional
class isn't loaded during compilation at all. That realization also lead to this code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have a preference for an early return with
Description.NO_MATCH
: