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

[23] VerifyError during conversion between T extends Short and short #2958

Merged

Conversation

stephan-herrmann
Copy link
Contributor

when checking primitive conversions involving a type variable, always use the superclass to find a boxing type, knowing that all boxing types are classes, so other bounds are irrelevant.

fixes #2937

when checking primitive conversions involving a type variable, always
use the superclass to find a boxing type, knowing that all boxing types
are classes, so other bounds are irrelevant.

fixes eclipse-jdt#2937
@stephan-herrmann stephan-herrmann added this to the BETA_JAVA23 milestone Sep 15, 2024
@stephan-herrmann
Copy link
Contributor Author

We have been using erasure() already in a few placed to find a boxing type hidden in a type variable, but we missed (at least) one relevant location.

OTOH, I don't think we have a card blanche to use erasure() for other situations, so I tried to establish the following principles:

  • consistently use superclass() for the substitution rather than erasure() with the following justification:
    • we only look for boxing types among supers
    • since boxing types are classes, they must be found in superclass
  • only perform such substitution if both are true:
    • the original type is a type variable (including capture)
    • the superclass is a boxing type indeed

The first item should not be a semantic change, just document that and why looking in this one location is sufficient.

I left one questionable use of erasure() in the context of NARROWING_AND_UNBOXING_CONVERSION which has a TODO anyway.

@stephan-herrmann stephan-herrmann merged commit 8cc314e into eclipse-jdt:BETA_JAVA23 Sep 15, 2024
6 checks passed
@stephan-herrmann stephan-herrmann deleted the issue2937 branch September 15, 2024 11:03
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.

1 participant