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

Checker crash with pattern matching latest version #5047

Closed
tmarback opened this issue Feb 9, 2022 · 3 comments
Closed

Checker crash with pattern matching latest version #5047

tmarback opened this issue Feb 9, 2022 · 3 comments

Comments

@tmarback
Copy link

tmarback commented Feb 9, 2022

Updating to version 3.21.2 gives me a AsSuperVisitor: type is not an erased subtype of supertype. error and crashes the framework when using pattern matching on an Object-type value. The full exception trace is here, and the code that caused the crash is the following:

public boolean equals( final @Nullable Object o ) {

    if ( o instanceof NumberParameterBuilder<?, ?, ?> b ) {
        return super.equals( o ) && Objects.equals( this.minimum, b.minimum )
                && Objects.equals( this.maximum, b.maximum );
    } else {
        return false;
    }

}

Based on the exception output, it seems to be flipping which is the subtype and which is the supertype. Also I would expect this to be reported as a normal error, not crash the framework.

The previous version (3.21.1) did not have this issue and finished normally.

@mernst
Copy link
Member

mernst commented Feb 9, 2022

Thanks for reporting the problem, and I am sorry you encountered the crash.

I am not able to reproduce this problem using the master branch of the Checker Framework. I did not try it with version 3.21.2, though it is possible that 4c9c5d9 fixed the problem. Are you able to build the Checker Framework from its repository and test it?

For completeness, this is the file I used to try to reproduce the problem.

// Test case for issue #5047: https://tinyurl.com/cfissue/5047

import java.util.Objects;
import org.checkerframework.checker.nullness.qual.Nullable;

public class Issue5047 {}

class NumberParameterBuilder<T, U, V> {

  @Nullable Object minimum;
  @Nullable Object maximum;

  public boolean equals(final @Nullable Object o) {

    if (o instanceof NumberParameterBuilder<?, ?, ?> b) {
      return super.equals(o)
          && Objects.equals(this.minimum, b.minimum)
          && Objects.equals(this.maximum, b.maximum);
    } else {
      return false;
    }
  }
}

@tmarback
Copy link
Author

You're right, it seems that this issue has been resolved by one of the recent commits in master (seems to have been 7e16a9c rather than 4c9c5d9 though), so that's good. I'll just stick with 3.21.1 until the next version is out 👍

Thanks!

@mernst
Copy link
Member

mernst commented Feb 10, 2022

@tmarback Thanks for confirming. We are sorry you encountered the problem, but I'm glad it is now fixed.

wmdietl pushed a commit to eisop/checker-framework that referenced this issue Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants