You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid too eager transform of $outer for lhs & accessor rhs (#18949)
Fix#18927
The transformer in `mapOuter` in `Constructors` was transforming trees
it should not:
```scala
override def transform(tree: Tree)(using Context) = tree match {
[....]
case tree: RefTree if tree.symbol.is(ParamAccessor) && tree.symbol.name == nme.OUTER =>
ref(outerParam)
[...]
```
There were two problems:
- This case transformed LHS of `$outer` assignments in constructors. So, instead of setting the `$outer` field in the current class with the constructor, it was replaced with the $outer of the outer class. That resulted in not assigning any value to the `$outer` in inner class, and double assignment to the val in outer class.
- LHS of the accessor def was also transformed, so it was evaluated to the `$outer` of the outer class.
This only happened when the nested class is created in the secondary constructor, as the primary constructor is not transformed (only the template body)
0 commit comments