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

Implement tracked members #21761

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

Conversation

KacperFKorban
Copy link
Member

closes #21754

@KacperFKorban KacperFKorban marked this pull request as ready for review October 17, 2024 18:49
if sym.allOverriddenSymbols.exists(_.flags.is(Tracked)) then
sym.setFlag(Tracked)
if sym.flags.is(Tracked) && tpt.isEmpty then
sym.info = rhs.tpe
Copy link
Member

Choose a reason for hiding this comment

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

It seems dangerous to set info here. This means that the symbol info gets modified when the val is type-checked, so it's not the same before and after in definition order.

Here is an example:

abstract class Vec:
  tracked val size: Int

@main def main =
  val v = new Vec:
    val size0: size.type = 10 // error: found (10 : Int), required (size : Int)
    val size = 10
    val size1: size.type = 10 // okay, because size is known to be (10 : Int) here

I am wondering if the logic wouldn't be better placed in Namer.Completer, maybe setting the flag in completeInCreationContext and computing the precise member type in valOrDefDefSig? Have you thought about doing so? However this is not easy to do without causing cyclic references.

Copy link
Member

Choose a reason for hiding this comment

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

I haven't been able to do exactly what I described above due to cyclic references, but I could move the whole setAbstractTrackedInfo to Namer.Completer: dotty-staging#53.
Still seems dirty to write over .info, but at least it's done directly when completing the symbol. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, seemed dirty to me too, but it also seemed like the least intrusive way to do it. If moving the logic to Namer works, then it should be the better solution, so we can merge dotty-staging#53.
I would probably wait on Martin's opinion though. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me to wait on Martin's opinion.
And my PR currently fails picklings test actually.

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.

Implement tracked members
2 participants