-
Notifications
You must be signed in to change notification settings - Fork 362
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
KEEP for custom equals in inline classes #338
base: master
Are you sure you want to change the base?
Conversation
} | ||
``` | ||
|
||
Type of `other` will be erased during compilation and passing argument will not require boxing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not erased, but unboxed.
|
||
More precise, we define typed equals as a function such that: | ||
|
||
* Has name `"equals"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to make examples conform the restrictions. For example, the one above does not have the annotation.
### Inline classes over inline classes | ||
|
||
Suppose we have an inline class `B` over inline class `A` and `A` declares typed equals. In this case, | ||
default-generated equals in `B` will be comparing it underlying values using custom equals of `A`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will B
require opt-in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Any usage of A
will require opt-in and B
will use A
in its primary constructor declaration
} | ||
|
||
@Override | ||
public boolean equals(Object other) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, this equals
does not follow its contract. Second, how typed equals will be compiled into Valhalla class method?
|
||
### Resolving references to typed equals in compiler frontend | ||
|
||
Currently `'=='` operator is being resolved to typed equals in compiler backend, but resolving it in frontend could let |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current decision is that ==
is never resolved on front-end, but IDE makes everything it can to resolve it. So, it is not about FE support, but rather IDE one.
No description provided.