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

@MonotonicNonNull and @Nullable fields now prevent final-class constructors from using a method reference at the end #640

Closed
cpovirk opened this issue Nov 27, 2023 · 0 comments · Fixed by #642
Assignees

Comments

@cpovirk
Copy link

cpovirk commented Nov 27, 2023

This is like #610 but:

I see it with 3.39.0-eisop1 and with 3.40.0-eisop2 but not with 3.40.0-eisop2, so I assume that it's part of the general initialization-checker restructuring.

$ cat I2.java 
import org.checkerframework.checker.nullness.qual.Nullable;

final class I2 {
  @Nullable String s;

  I2() {
    use(this::init);
  }

  void init() {}

  static void use(Runnable r) {}
}

$ checker/bin/javac -processor nullness I2.java
I2.java:7: error: [methodref.receiver.bound.invalid] Incompatible receiver type
    use(this::init);
        ^
  found   : @UnderInitialization I2
  required: @Initialized I2
  Consequence: method
    @UnderInitialization I2
  is not a valid method reference for method in @UnderInitialization I2
    void init(@Initialized I2 this)
1 error
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