{"action":"created","issue":{"url":"https://api.github.com/repos/typetools/checker-framework/issues/596","repository_url":"https://api.github.com/repos/typetools/checker-framework","labels_url":"https://api.github.com/repos/typetools/checker-framework/issues/596/labels{/name}","comments_url":"https://api.github.com/repos/typetools/checker-framework/issues/596/comments","events_url":"https://api.github.com/repos/typetools/checker-framework/issues/596/events","html_url":"https://github.com/typetools/checker-framework/issues/596","id":133267458,"number":596,"title":"Cannot infer combination of Optional.fromNullable() and or()","user":{"login":"henrikssn","id":859779,"avatar_url":"https://avatars.githubusercontent.com/u/859779?v=3","gravatar_id":"","url":"https://api.github.com/users/henrikssn","html_url":"https://github.com/henrikssn","followers_url":"https://api.github.com/users/henrikssn/followers","following_url":"https://api.github.com/users/henrikssn/following{/other_user}","gists_url":"https://api.github.com/users/henrikssn/gists{/gist_id}","starred_url":"https://api.github.com/users/henrikssn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henrikssn/subscriptions","organizations_url":"https://api.github.com/users/henrikssn/orgs","repos_url":"https://api.github.com/users/henrikssn/repos","events_url":"https://api.github.com/users/henrikssn/events{/privacy}","received_events_url":"https://api.github.com/users/henrikssn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-12T15:23:25Z","updated_at":"2016-02-18T08:04:47Z","closed_at":null,"body":"    private static String getOrEmpty(AtomicReference<String> ref) {\r\n      return Optional.fromNullable(ref.get()).or(\"\");\r\n    }\r\n\r\nError:\r\n\r\n    incompatible types in assignment.\r\n      return fromNullable(ref.get()).or(\"\");\r\n                                       ^   \r\n    found   : @NonNull ? extends T extends @Initialized @Nullable Object\r\n    required: @Initialized @NonNull String"},"comment":{"url":"https://api.github.com/repos/typetools/checker-framework/issues/comments/185588396","html_url":"https://github.com/typetools/checker-framework/issues/596#issuecomment-185588396","issue_url":"https://api.github.com/repos/typetools/checker-framework/issues/596","id":185588396,"user":{"login":"mernst","id":121025,"avatar_url":"https://avatars.githubusercontent.com/u/121025?v=3","gravatar_id":"","url":"https://api.github.com/users/mernst","html_url":"https://github.com/mernst","followers_url":"https://api.github.com/users/mernst/followers","following_url":"https://api.github.com/users/mernst/following{/other_user}","gists_url":"https://api.github.com/users/mernst/gists{/gist_id}","starred_url":"https://api.github.com/users/mernst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mernst/subscriptions","organizations_url":"https://api.github.com/users/mernst/orgs","repos_url":"https://api.github.com/users/mernst/repos","events_url":"https://api.github.com/users/mernst/events{/privacy}","received_events_url":"https://api.github.com/users/mernst/received_events","type":"User","site_admin":false},"created_at":"2016-02-18T08:04:47Z","updated_at":"2016-02-18T08:04:47Z","body":"Thanks for reporting the problem, and I'm sorry you are having trouble.\r\n\r\nI cannot reproduce the problem.  The given source code is not complete (it's just a snippet rather than a complete .java file), and the given error message cites a source code line that does not appear in the snippet.  There is no fromNullable method in the JDK's Optional class, so I guess that is the Guava version.  There is no command line given that was used for compilation.\r\n\r\nI tried the following test case (which is also checked into the repository), but type-checking of it succeeded with the command `$CHECKERFRAMEWORK/checker/bin/javac -processor nullness Issue596.java`:\r\n\r\n    // Test case for Issue 596:\r\n    // https://github.com/typetools/checker-framework/issues/596\r\n    // @below-java8-jdk-skip-test\r\n\r\n    import java.util.concurrent.atomic.AtomicReference;\r\n    import org.checkerframework.checker.nullness.qual.*;\r\n\r\n    class Issue596 {\r\n\r\n      private static String getOrEmpty(AtomicReference<String> ref) {\r\n        return Optional.fromNullable(ref.get()).or(\"\");\r\n      }\r\n\r\n    }\r\n\r\n    // From Google Guava\r\n    class Optional<T> {\r\n\r\n      public static <T> Optional<T> fromNullable(/*@Nullable*/ T nullableReference) {\r\n        return new Optional<T>();\r\n      }\r\n\r\n      public T or(T defaultValue) {\r\n        return defaultValue;\r\n      }\r\n\r\n    }\r\n\r\nCan you please give a complete, reproducible test case so that we can understand and fix your problem?  Thanks!"}}