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
resetAttrs now always erases This.tpe #2134
Conversation
The symbol of This, if it points to a package class, isn't touched, just as usual, so that our Select(Select(Select(...))) => This(...) optimization works fine with attr reset. However the tpe is now erased, so that subsequent reflective compilation doesn't spuriously fail when seeing that some subtrees of a tree being compiled are typed. Erasing the tpe doesn't pose even a tiniest problem, because, as it can be seen in typedThis, type is trivially reconstructed from the symbol.
I can't say a patch such as this looks good to me; I don't know how anyone can be very confident of the before/after behavior. Imagine we were tasked with convincing someone not raised from birth on compiler arcanery of the correctness of this change. How would we go about that? Maybe you could at least add a comment explaining what is happening with the "vetoscope/vetolabel/vetothis" calculations. |
for starters, the patch fixes an obvious contract violation of the typer: he's not supposed to a) set the "tpe" field of trees that are passed into it, b) return the same tree that's passed into it, and c) return a tree which is partially typed (subtrees of the returned tree have tpe / symbol still |
actually, b) is not true if the input tree is already typed. |
"Well," says the hypothetical person we're trying to convince, "I looked into how contractual this contract is."
And here are the results compiling only the library and stopping after phase typer in the interests of mercy.
I suppose this is what I'm driving at when I say I don't see how anyone can have much confidence about whether such a change is correct. What makes this an obvious violation of the typer contract? For it to be an obvious violation of the typer contract we should probably share some common idea of what the typer contract is. Is it written down somewhere, or is it a strictly verbal tradition? The location one might predict, 'def typed', doesn't even arrive bearing a comment. |
uh, paul i'm sorry, i confused two pull requests, i thought your comment was on #2118 - my answer doesn't make much sense here... |
added comments, fixed something we've supposedly overlooked in resetAttrs for |
PLS REBUILD ALL |
(kitty-note-to-self: ignore 13774338) |
oops the "fix" was incorrect. rolled it back. |
@lrytz I realized it must be something like that when I looked at the commit again and couldn't find the referents. Still, it would be great to get some answers to those questions about the typer contract regardless of their applicability here. |
lgtm We now can say:
Other tree invariants?
|
Actually "reset trees are completely untyped, although they may retain some defined symbols" is incorrect. Some type trees aren't erased. See the last commit. PLS REBUILD ALL |
(kitty-note-to-self: ignore 13778952) |
PLS REBUILD ALL |
(kitty-note-to-self: ignore 13796627) |
Shall we merge? |
@retronym you gave the lgtm above, but there have been commits since then. Do you want to take a second look? |
I only updated the comment, so the review shouldn't be hard I think. |
Oh actually that wasn't just a comment. Sorry |
dupl.tpe = null | ||
dupl | ||
else { | ||
val refersToErasedSymbols = tpt.tpe != null && (tpt.tpe exists (tp => locals contains tp.typeSymbol)) |
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.
refersToLocalSymbols
leaves less room for confusion; "erasure" is too synonymous with the type erasure phase.
You are my hero. P.S. There are also tools which are your tools. However in this case they mostly serve to illustrate why periods and whitespace are still valuable in 2013.
|
PLS REBUILD ALL |
Note that I consider it a bug when you have to ask the kitten to rebuild explicitly. It won't speed things up in the current design. |
(Since it builds commits that are not built yet as they are pushed to the PR's branch.) |
(kitty-note-to-self: ignore 14131850) |
thank you, Adriaan! |
s/idiosynchrazies/idiosynchracies/ and we're done. Thanks for the prettification. |
done |
Thanks. |
resetAttrs now always erases This.tpe
The symbol of This, if it points to a package class, isn't touched, just
as usual, so that our Select(Select(Select(...))) => This(...) optimization
works fine with attr reset.
However the tpe is now erased, so that subsequent reflective compilation
doesn't spuriously fail when seeing that some subtrees of a tree being
compiled are typed.
Erasing the tpe doesn't pose even a tiniest problem, because, as it can
be seen in typedThis, type is trivially reconstructed from the symbol.