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

Make PTBKey not extend ReferenceBinding #3452

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jukzi
Copy link
Contributor

@jukzi jukzi commented Dec 13, 2024

  • Introduces interface TypeBindingWrapper.
  • Removes little code from PTBKey that is irrelevant for the wrapper

relates to #3412

jukzi pushed a commit to jukzi/eclipse.jdt.core that referenced this pull request Dec 13, 2024
Its just an IdentityWrapper - do not rely on ReferenceBinding
implementation.

relates to
eclipse-jdt#3452
@jukzi
Copy link
Contributor Author

jukzi commented Dec 17, 2024

@srikanth-sankaran may i ask for review? I would like to improve ReferenceBinding in small steps.

@srikanth-sankaran
Copy link
Contributor

@srikanth-sankaran may i ask for review? I would like to improve ReferenceBinding in small steps.

I'll try - but can't promise, I am trying to wrap up some projects I am working on before this week since post that I am away till 2nd Jan.

jukzi pushed a commit that referenced this pull request Dec 17, 2024
Its just an IdentityWrapper - do not rely on ReferenceBinding
implementation.

relates to
#3452
@jukzi
Copy link
Contributor Author

jukzi commented Jan 7, 2025

@srikanth-sankaran ping, please review.

@srikanth-sankaran
Copy link
Contributor

Sure, I will look into these this week. Happy new year!

@srikanth-sankaran
Copy link
Contributor

Sure, I will look into these this week. Happy new year!

Sorry, it looks like my full return to work will be delayed until a few days more. I will be at work 3 out of 5 days next week and I am hopeful the review can be completed well ahead of M2.

Copy link
Contributor

@srikanth-sankaran srikanth-sankaran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments, need some clarifications on what exactly we are trying to accomplish here.

I am yet to come to grips with what the new additional interface buys us.

Also the title of the PR PTBKey is not a ReferenceBinding - need clarification. What exactly do you mean by that.

I don't see anything seriously wrong/faulty - but simply don't get yet where we are going with this and why

@@ -53,18 +53,18 @@ public TypeBinding clone(TypeBinding outerType) {
return copy;
}

void addWrapper(TypeBinding wrapper, LookupEnvironment environment) {
void addWrapper(TypeBindingWrapper wrapper, LookupEnvironment environment) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only usage of the proposed interface. Here the instance is called "wrapper" and the method name add"Wrapper" also suggest to have "Wapper" in the interface name. Thats why i chose "TypeBindingWrapper". but i would be fine with any other Name.

@jukzi jukzi changed the title PTBKey is not a ReferenceBinding PTBKey does not need to implement ReferenceBinding Jan 17, 2025
@jukzi jukzi force-pushed the TypeBindingWrapper branch from 54187ac to 068f092 Compare January 17, 2025 10:00
@srikanth-sankaran
Copy link
Contributor

Not sure if you are planning to explain the PR title change - the new one still doesn't clear the mystery for me :)

Do you have a scenario where the PTBKey is actually not a reference binding ??

Without the additional name TypeBindingWrapper being used, things were working so far - so what does extracting the swapUnresolved behavior into its own type buy us ?

@jukzi
Copy link
Contributor Author

jukzi commented Jan 17, 2025

Without the additional name TypeBindingWrapper being used, things were working so far - so what does extracting the swapUnresolved behavior into its own type buy us ?

I am trying to clean up the ReferenceBinding equals/hashCode contract as it hard to understand and errorprone to accidentialy use when using a ReferenceBinding as key (for example #3561 ). As this PTBKey does not need to implement ReferenceBinding one could just ignore the PTBKey in such scenarios. At the end it will be fine if the PTBKey will have a custom equals/hashcode, but any actual ReferenceBinding probably won't need to override equals/hashcode => no more worries in the future.

PTBKey needs a custom hashCode/equals contract, while ReferenceBinding
should not need any.

* PTBKey not extends ReferenceBinding anymore
* Introduces interface Resolvable.
* Removes little code from PTBKey that is irrelevant for the wrapper

relates to eclipse-jdt#3412
@jukzi jukzi force-pushed the TypeBindingWrapper branch from 068f092 to cf810f5 Compare January 17, 2025 10:13
@jukzi jukzi changed the title PTBKey does not need to implement ReferenceBinding Make PTBKey not extend ReferenceBinding Jan 17, 2025
@srikanth-sankaran
Copy link
Contributor

Without the additional name TypeBindingWrapper being used, things were working so far - so what does extracting the swapUnresolved behavior into its own type buy us ?

I am trying to clean up the ReferenceBinding equals/hashCode contract as it hard to understand and errorprone to accidentialy use when using a ReferenceBinding as key (for example #3561 ). As this PTBKey does not need to implement ReferenceBinding one could just ignore the PTBKey in such scenarios. At the end it will be fine if the PTBKey will have a custom equals/hashcode, but any actual ReferenceBinding probably won't need to override equals/hashcode => no more worries in the future.

PTBKey is not "implementing" ReferenceBinding but ISA ReferenceBinding - do you know of cases where it is NOT a ReferenceBinding ? If not this whole PR will become moot and will only serve to obfuscate by introducing additional names...

@jukzi
Copy link
Contributor Author

jukzi commented Jan 17, 2025

PTBKey is not "implementing" ReferenceBinding but ISA ReferenceBinding - do you know of cases where it is NOT a ReferenceBinding ? If not this whole PR will become moot and will only serve to obfuscate by introducing additional names...

It was a ReferenceBinding but did not need to be ReferenceBinding. It is only a wrapper used as key for ParameterizedTypeBinding. It is not used as ReferenceBinding itself anywhere. Especially PTBKey.hash(TypeBinding) will never call PTBKey.hashCode() which was not clear from the type hierarchy.

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.

2 participants