-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
base: main
Are you sure you want to change the base?
Implement tracked
members
#21761
Conversation
…behind a flag, reemove debugs and add some more tests
if sym.allOverriddenSymbols.exists(_.flags.is(Tracked)) then | ||
sym.setFlag(Tracked) | ||
if sym.flags.is(Tracked) && tpt.isEmpty then | ||
sym.info = rhs.tpe |
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.
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.
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.
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?
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.
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?
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.
Sounds good to me to wait on Martin's opinion.
And my PR currently fails picklings test actually.
closes #21754