Commit d91e42f
committed
Fix setter name for Scala 2 traits
Solution: only use simple name for fields
Before the change, given the following code
class A extends App
The compiler will generate the following setter in the phase Mixin:
scala[Qualified $ App][Qualified $_setter_$ scala$App$$initCode_=]
However, the field created by the getter will be:
scala[Qualified $ App][Qualified $$ initCode][Suffix $$local]
It will cause a problem in the phase Memoize in the line below:
val field = sym.field.orElse(newField).asTerm
The problem is that, for the setter, `sym.field` will be unable to
find the field generated by the getter, due to the name mismatch.
Consequently, the method `newField` will be called to create another
field symbol without corresponding trees.
After the change, the following field is generated instead:
scala$App$$initCode[Suffix $$local]
Now, the setter will be able to find the field via `sym.field`.
This fix avoids generate a phantom symbol without corresponding trees.1 parent cd6341e commit d91e42f
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| |||
0 commit comments