Repository navigation
Also call avoidingType when using the custom unpackProxiesFromResultType during inlining - #26893
Conversation
|
|
eacfd30 to
0f37313
Compare
| * term references to symbols in `symsToAvoid`, | ||
| * term references that have a widened type of which some part refers | ||
| * to a symbol in `symsToAvoid`, | ||
| * type references to symbols in `symsToAvoid`, |
There was a problem hiding this comment.
Previous (incorrect) fix I tried relied on bringing back this behavior documented here, which turns out to have been removed a few years ago. That however broke the macwire community build test, which I minimized and added separately as a compiler test.
To minimize the confusion for other maintainers, I remove the incorrect documentation here
tanishiking
left a comment
There was a problem hiding this comment.
My understanding is that:
normally, the return type of an inline method has inlined.tpe which has avoidingType so that local terms/types don't leak outside.
However, for a transparent inline, the return type is refined by returning the expanded type of the inline via unpackProxiesFromResultType, and that type was not being avoided.
And, as a result, when the return value of a transparent inline was a value whose type contained a local proxy (usually because of nested inline methods), that local proxy appeared in the return type, and assertion fail.
This fix avoids the expanded type when computing the return type of a transparent inline. I think this is a reasonable fix 👍
|
Thank you so much! I just noticed I left the old title for the PR, will change before merging. Sorry about that :( I probably made things unnecessarily confusing because of that. |
…ype during inlining (scala#26893) In scala#23792, when in `unpackProxiesFromResultType` I used inlined.expansion.tpe instead of Inlined.tpe, I didn't realize that when creating the inlined Inlined node and assigning type to it, avoidingType is also called: ```scala def assignType(tree: untpd.Inlined, bindings: List[Tree], expansion: Tree)(using Context): Inlined = tree.withType(avoidingType(expansion, bindings)) ``` Without this avoidingType here, the skolem type from the minimization does not get replaced early enough, and subsequent cavoidingType calls can't see it as by that point the skolem is replaced with a term ref, causing it to effectively leak. So as a fix, we read the avoiding type after unpacking the inlined node with inlined.epression.tpe. Fixes scala#26785 ## Have you relied on LLM-based tools in this contribution? <!-- Pick one; "running tests" is not enough; refer to https://github.com/scala/scala3/blob/main/LLM_POLICY.md for details --> Yes, and I manually checked the logic and output. ## How was the solution tested? <!-- Pick one; exceptions must have a very good reason --> New automated tests (including the issue's reproducer, if applicable) [Cherry-picked c202f34]
In #23792, when in
unpackProxiesFromResultTypeI used inlined.expansion.tpe instead of Inlined.tpe, I didn't realize that when creating the inlined Inlined node and assigning type to it, avoidingType is also called:Without this avoidingType here, the skolem type from the minimization does not get replaced early enough, and subsequent cavoidingType calls can't see it as by that point the skolem is replaced with a term ref, causing it to effectively leak.
So as a fix, we read the avoiding type after unpacking the inlined node with inlined.epression.tpe.
Fixes #26785
Have you relied on LLM-based tools in this contribution?
Yes, and I manually checked the logic and output.
How was the solution tested?
New automated tests (including the issue's reproducer, if applicable)