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

Array.length treated as @UnknownInitialization #3449

Closed
mernst opened this issue Jul 8, 2020 · 1 comment · Fixed by #3459
Closed

Array.length treated as @UnknownInitialization #3449

mernst opened this issue Jul 8, 2020 · 1 comment · Fixed by #3459

Comments

@mernst
Copy link
Member

mernst commented Jul 8, 2020

Consider the following test case:

import org.checkerframework.framework.qual.AnnotatedFor;

@AnnotatedFor("nullness")
public class Issue3449 {

  int length;

  public Issue3449(Object... args) {
    length = args.length;
  }
}

Compiling it with

javac -g Issue3449.java -processor nullness -AuseConservativeDefaultsForUncheckedCode=source

yields this error:

Issue3449.java:9: error: [assignment.type.incompatible] incompatible types in assignment.
    length = args.length;
                 ^
  found   : @UnknownInitialization @NonNull int
  required: @Initialized @NonNull int
1 error

The file type-checks if I remove @AnnotatedFor or the -AuseConservativeDefaultsForUncheckedCode=source command-line option.

mernst added a commit that referenced this issue Jul 8, 2020
@smillst smillst changed the title Constructor formal parameters treated as @UnknownInitialization Array.length treated as @UnknownInitialization Jul 9, 2020
@smillst
Copy link
Member

smillst commented Jul 9, 2020

It's not the formal parameter that's @UnknownInitialization; it's the field access of length. I've got a fix in #3459.

smillst added a commit that referenced this issue Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants