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

Correctly substitue poly qualifier from type argument bounds #1078

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Ao-senXiong
Copy link
Member

Fixes #1074

@Ao-senXiong
Copy link
Member Author

OK, the CI reproduce the crash.

@Ao-senXiong
Copy link
Member Author

Ao-senXiong commented Jan 30, 2025

@wmdietl
For this code,

class MyCollection<E> { 
  void copyOf(MyCollection<? extends E> elements) {
    Object[] array = elements.toArray();
  }
  @PolyVP Object [] toArray(MyCollection<@PolyVP E> this) {
      return null;
  };
}

Currently, @PolyVP E as a type argument is applying polymorphic qualifier to both bounds, i.e. @PolyVP void as lower bound and @PolyVP Object as upper bound. However, elements is using @Bottom void as lower bound and @Top Object as upper bound. There is a mismatch in polymorphic qualifier substitution as in type argument we can not specify lower and upper bound seperately. We need to neither reject the code or use one bound conservatively e.g. replace both bounds to @Top.

Do you have better idea on how to solve this problem?

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 this pull request may close these issues.

Polymorphic qualifier on type argument result in Viewpoint adapter crash
2 participants