{"action":"created","issue":{"url":"https://api.github.com/repos/typetools/checker-framework/issues/2465","repository_url":"https://api.github.com/repos/typetools/checker-framework","labels_url":"https://api.github.com/repos/typetools/checker-framework/issues/2465/labels{/name}","comments_url":"https://api.github.com/repos/typetools/checker-framework/issues/2465/comments","events_url":"https://api.github.com/repos/typetools/checker-framework/issues/2465/events","html_url":"https://github.com/typetools/checker-framework/issues/2465","id":437858218,"node_id":"MDU6SXNzdWU0Mzc4NTgyMTg=","number":2465,"title":"Checking of @EnsuresNonNull / @RequiresNonNull varies with use of fluent API","user":{"login":"msridhar","id":193105,"node_id":"MDQ6VXNlcjE5MzEwNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/193105?v=4","gravatar_id":"","url":"https://api.github.com/users/msridhar","html_url":"https://github.com/msridhar","followers_url":"https://api.github.com/users/msridhar/followers","following_url":"https://api.github.com/users/msridhar/following{/other_user}","gists_url":"https://api.github.com/users/msridhar/gists{/gist_id}","starred_url":"https://api.github.com/users/msridhar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msridhar/subscriptions","organizations_url":"https://api.github.com/users/msridhar/orgs","repos_url":"https://api.github.com/users/msridhar/repos","events_url":"https://api.github.com/users/msridhar/events{/privacy}","received_events_url":"https://api.github.com/users/msridhar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2019-04-26T21:49:26Z","updated_at":"2019-04-30T21:27:08Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I am getting some unexpected results using `@EnsuresNonNull` / `@RequiresNonNull` with a fluent API.  This is with Checker Framework 2.8.0.  Consider the following example:\r\n```java\r\nimport org.checkerframework.checker.nullness.qual.EnsuresNonNull;\r\nimport org.checkerframework.checker.nullness.qual.MonotonicNonNull;\r\nimport org.checkerframework.checker.nullness.qual.RequiresNonNull;\r\npublic class Library {\r\n    static class Example {\r\n        @MonotonicNonNull String s;\r\n        public Example() {}\r\n        @EnsuresNonNull(\"this.s\")\r\n        public Example setS(String s1) {\r\n            this.s = s1;\r\n            return this;\r\n        }\r\n        @RequiresNonNull(\"this.s\")\r\n        public void print() {\r\n            System.out.println(this.s.toString());\r\n        }\r\n    }\r\n    static void withVars() {\r\n        Example example = new Example();\r\n        example.setS(\"hi\");\r\n        example.print();\r\n    }\r\n    static void fluent1() {\r\n        Example example = new Example();\r\n        example\r\n            .setS(\"hi\")\r\n            .print();\r\n    }\r\n    static void fluent2() {\r\n        (new Example())\r\n            .setS(\"hi\")\r\n            .print();\r\n    }\r\n}\r\n```\r\nI would expect this code to typecheck with no errors.  However, when running Nullness Checker I get the following error inside `fluent1()`:\r\n```\r\nLibrary.java:43: error: [contracts.precondition.not.satisfied] example.setS(\"hi\").print's precondition about 'example.setS(\"hi\").s' is not satisfied\r\n            .print();\r\n                  ^\r\n1 error\r\n```\r\nAdding an `@Pure` annotation to `setS()` does not fix the problem.  Also, it is a bit surprising that `fluent1()` does not type check, but getting rid of the `example` local variable in `fluent2()` makes the code type check.\r\n  "},"comment":{"url":"https://api.github.com/repos/typetools/checker-framework/issues/comments/488121673","html_url":"https://github.com/typetools/checker-framework/issues/2465#issuecomment-488121673","issue_url":"https://api.github.com/repos/typetools/checker-framework/issues/2465","id":488121673,"node_id":"MDEyOklzc3VlQ29tbWVudDQ4ODEyMTY3Mw==","user":{"login":"msridhar","id":193105,"node_id":"MDQ6VXNlcjE5MzEwNQ==","avatar_url":"https://avatars1.githubusercontent.com/u/193105?v=4","gravatar_id":"","url":"https://api.github.com/users/msridhar","html_url":"https://github.com/msridhar","followers_url":"https://api.github.com/users/msridhar/followers","following_url":"https://api.github.com/users/msridhar/following{/other_user}","gists_url":"https://api.github.com/users/msridhar/gists{/gist_id}","starred_url":"https://api.github.com/users/msridhar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msridhar/subscriptions","organizations_url":"https://api.github.com/users/msridhar/orgs","repos_url":"https://api.github.com/users/msridhar/repos","events_url":"https://api.github.com/users/msridhar/events{/privacy}","received_events_url":"https://api.github.com/users/msridhar/received_events","type":"User","site_admin":false},"created_at":"2019-04-30T21:27:08Z","updated_at":"2019-04-30T21:27:08Z","author_association":"CONTRIBUTOR","body":"Nothing urgent, but @smillst @wmdietl let me know if you want me to refocus this issue on the unsoundness, which is likely a more urgent issue than support for fluent APIs."}}
{"actor":{"display_login":"msridhar"}}