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

Remove tvars introduced while testing normalizedCompatible #21466

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Aug 28, 2024

Having looked at the type var constraints for so long, I wanted to finally get rid of these temporary typevars (and a type lambda) added for the purpose of typing a qualifier against a selection prototype, and when the selection is actually typed, brand new typevars (and a type lambda) are added. Given it's from the same type lambda, they're necessarily all called the same, so they're indistinguishable in the constraint debugging.

@dwijnand dwijnand marked this pull request as ready for review August 28, 2024 07:25
@dwijnand dwijnand requested a review from odersky August 28, 2024 07:25
@dwijnand
Copy link
Member Author

@odersky I assume you've seen this as well. I'm not sure of the best way to fix this, but this way works and seems clean enough. But I'm happy to experiment with other ways, if you have ideas.

@odersky
Copy link
Contributor

odersky commented Sep 23, 2024

I am out of bandwidth to page in the context for this one. Maybe @smarter can take a look?

@dwijnand dwijnand assigned smarter and unassigned odersky Sep 23, 2024
@dwijnand dwijnand requested review from smarter and removed request for odersky September 23, 2024 20:14
@dwijnand dwijnand assigned dwijnand and unassigned smarter Oct 18, 2024
@dwijnand dwijnand force-pushed the dnw-drop-lambda branch 2 times, most recently from 57522df to b6f36d0 Compare October 23, 2024 16:48
compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala Outdated Show resolved Hide resolved
// This is done to compensate for the fact that normally every
// reference to a polytype would have to be a fresh copy of that type,
// but we want to avoid that because it would increase compilation cost.
// See pos/i6682a.scala for a test case where the defensive copying matters.
val ensureFresh = new TypeMap with CaptureSet.IdempotentCaptRefMap:
Copy link
Member

Choose a reason for hiding this comment

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

How are the changes in this file and Typer related to the change in ProtoTypes?

Copy link
Member Author

Choose a reason for hiding this comment

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

So the ones in Typer, i.e. when adapting by applying fresh type vars, is necessary for the recursive programs like i6682a (and in the comment). I then randomly grepped the reference i6682a and found the code in TypeAssigner, so I started expanding my Typer comment. But I noticed that the way its done in TypeAssigner is in cloning the lambda in the args. So I thought I could hit two birds with one stone by (1) do it consistently in both (making it easier to document) and (2) do it more efficiently in TypeAssigner by doing it once rather than for each argument.

@dwijnand dwijnand assigned smarter and unassigned dwijnand Oct 26, 2024
Comment on lines 507 to 505
// variable. NOTE: this does not suffice to discard type variables
// in ancestors of `protoTyperState`, if this situation ever
// comes up, an assertion in TyperState will trigger and this code
// will need to be generalized.
Copy link
Member

Choose a reason for hiding this comment

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

I believe this code is flawed since the situation in the NOTE can happen which I think is what causes #21555 and similar issues, but it's not clear to me that just removing this is fine, and it seems unrelated to the rest of this PR?

Copy link
Member Author

@dwijnand dwijnand Oct 30, 2024

Choose a reason for hiding this comment

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

I went to reverify things, and I can't find a test case that fails without your code here (and without anything in this PR). So I can't say that my code replaces it, because it doesn't seem to do anything for any of our tests. So I put it back (by dropping my commit).

@dwijnand
Copy link
Member Author

dwijnand commented Nov 6, 2024

@smarter good now, right?

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.

3 participants