Quantcast

[jira] [Commented] (LUCENE-7796) Make reThrow idiom return Throwable to enforce code unreachability

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[jira] [Commented] (LUCENE-7796) Make reThrow idiom return Throwable to enforce code unreachability

JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/LUCENE-7796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15978259#comment-15978259 ]

Dawid Weiss commented on LUCENE-7796:
-------------------------------------

Sorry, I wasn't clear -- this method would *still* unconditionally always throw an exception. So even if you forgot to do a {{throw}}, the code wouldn't get past this method. The return unchecked exception is only useful for cases like switch statements or (theoretically) reachable code but practically we know reThrow never returns. See Mike's code in LUCENE-7792 and you'll see what I mean.

> Make reThrow idiom return Throwable to enforce code unreachability
> ------------------------------------------------------------------
>
>                 Key: LUCENE-7796
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7796
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Dawid Weiss
>            Assignee: Dawid Weiss
>            Priority: Trivial
>             Fix For: 6.x, master (7.0)
>
>
> A spinoff from LUCENE-7792: reThrow can return an unchecked exception so that one can use {{throw reThrow(...)}} idiom to let the compiler know subsequent code would be unreachable.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...