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

Fix mapping of annotations #22407

Merged
merged 1 commit into from
Jan 19, 2025
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jan 19, 2025

We previously did not do an (expensive) TreeTypeMap on an annotation if the mapped versions of all types of subtrees of the annotation tree were =:= to the original types. But it turns out this is too coarse. In the test we have capture set variables where we intend to map a TypeRef to a TypeParamRef but the two were considered as =:= because of the bounds they had. So no mapping took place.

We now use eql instead of =:=, which is structural comparison with eq for references to corresponding binders.

We previously did not do an (expensive) TreeTypeMap on an annotation if the mapped versions
of all types of subtrees of the annotation tree were =:= to the original types. But it turns
out this is too coarse. In the test we have capture set variables where we intend to map a
TypeRef to a TypeParamRef but the two were considered as =:= because of the bounds they had.
So no mapping took place.

We now use `eql` instead of =:=, which is structural comparison with `eq` for references to
corresponding binders.
@odersky odersky requested a review from mbovel January 19, 2025 19:40
@odersky
Copy link
Contributor Author

odersky commented Jan 19, 2025

@mbovel You looked at this code last, and I remember we discussed several alternatives. Do you see a reason why eql would not work? I know I was skeptical about changing this before, but this failure convinced me that comparing types with frozen_=:= is not correct.

@mbovel
Copy link
Member

mbovel commented Jan 19, 2025

@mbovel You looked at this code last, and I remember we discussed several alternatives. Do you see a reason why eql would not work? I know I was skeptical about changing this before, but this failure convinced me that comparing types with frozen_=:= is not correct.

I concluded in #19957 (comment) that tp1 frozen_=:= worked for comparing TermRef and TermParamRef. I remember also doing some tests with TypeRef and TypeParamRef, but I guess I didn't stumble across the situation you have here.

Using eql sounds okay to me.

@mbovel mbovel enabled auto-merge January 19, 2025 20:12
@mbovel mbovel merged commit bd699fc into scala:main Jan 19, 2025
29 checks passed
@mbovel mbovel deleted the fix-annot-typemaps branch January 19, 2025 20:39
@odersky
Copy link
Contributor Author

odersky commented Jan 19, 2025

It was a very special setup where we now have TypeParam/Refs that might contain each other in their lower as well as upper bounds. That's what made frozen_=:= pass. It was a recent improvement to capture set variables by @noti0na1. Which shows that no good deed goes unpunished 😜 .

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