Skip to content
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

Type becomes @UnknownInitialization after switch #609

Closed
cpovirk opened this issue Oct 23, 2023 · 2 comments · Fixed by #620
Closed

Type becomes @UnknownInitialization after switch #609

cpovirk opened this issue Oct 23, 2023 · 2 comments · Fixed by #620

Comments

@cpovirk
Copy link

cpovirk commented Oct 23, 2023

New in 3.39.0-eisop1:

$ cat E.java
enum E {
  FOO;

  E getIt() {
    return FOO;
  }

  String go() {
    E e = getIt();
    switch (e) {
      case FOO:
        return "foo";
    }
    throw new AssertionError(e);
  }
}

$ checker/bin/javac -processor nullness E.java
E.java:14: error: [argument.type.incompatible] incompatible argument for parameter detailMessage of AssertionError constructor.
    throw new AssertionError(e);
                             ^
  found   : @UnknownInitialization E
  required: @Initialized Object
1 error
@cpovirk
Copy link
Author

cpovirk commented Oct 24, 2023

Liam reports that this behavior happens with typetools, too. (Sorry for not checking.) Maybe it's related to the changes for null cases in switch?

@wmdietl
Copy link
Member

wmdietl commented Oct 24, 2023

Liam reports that this behavior happens with typetools, too. (Sorry for not checking.) Maybe it's related to the changes for null cases in switch?

No problem. Thanks to you and Liam for reporting these issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants