-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Issue with Symbols#mapSymbols leads to various errors when using TreeTypeMap #1812
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
Comments
I wonder if this could be fixed by setting the denotations of mapped symbols lazily in |
Looking at it. Btw: why |
Yeah I guess area:transform is more appropriate |
Seems to be the source of a bug. As we have forward references, order shouldn't be important and TTM is suposed to handle it. |
…rmation. Reasoning similar to one in the previous commit also applies to annotations.
…rmation. Reasoning similar to one in the previous commit also applies to annotations.
Fix #1812, Symbols.mapSymbols shouldn't replace denotations
Every usage of
TreeTypeMap
is affected, even if run usingatGroupEnd
like we do inExtensionMethods
, so this is a different issue than #1770:This fails
-Ycheck:tailrec
with:It's pretty hard to understand what's going on here but I think I've narrowed it down to
mapSymbols
, recall that it works in three steps:original
TreeTypeMap
, etc.The issue happens in 3., to create the new infos we map over the old infos (
info = ttmap1.mapType(oinfo)
) for each symbol in order, but when we map over the info of one mapped symbol, we may end up looking at another mapped symbol whose denotation is still set to the original denotation, even if we don't end up taking any decision based on that symbol denotation we may end up corrupting some cache (for example,NamedType
cache denotations).More specifically, in the example above:
class Foo
is in a method that becomes an extension method, so its symbol ends up being transformed byTreeTypeMap
TreeTypeMap#withMappedSyms
we callmapSymbols
with every declaration inFoo
, in the list of declarationscompose
appears beforeFF$R
, this is important.mapSymbols
we get to the step 3 explained above, we map the info ofcompose
which is()Foo.this.FF$R
, this is done successfully but note that at this point the denotation of the new symbol forFF$R
is still incorrect, andFoo.this.FF$R
is aNamedType
which means that we cache its denotation.mapSymbols
we correctly set the denotation of the new symbol forFF$R
but it's too late.Later in
TreeChecker
when we look at the type ofsuper[FF].compose()
we get the old cached denotation which points to the old symbol forBla
, thus the error.The text was updated successfully, but these errors were encountered: