@@ -16,15 +16,21 @@ import Decorators._
16
16
/** Performs the following rewritings for fields of a class:
17
17
*
18
18
* <mods> val x: T = e
19
- * --> <mods> <stable> def x: T = e
19
+ * --> <mods> <stable> <accessor> def x: T = e
20
20
* <mods> var x: T = e
21
- * --> <mods> def x: T = e
21
+ * --> <mods> <accessor> def x: T = e
22
22
*
23
23
* <mods> val x: T
24
- * --> <mods> <stable> def x: T
24
+ * --> <mods> <stable> <accessor> def x: T
25
+ *
26
+ * <mods> lazy val x: T = e
27
+ * --> <mods> <accessor> lazy def x: T =e
25
28
*
26
29
* <mods> var x: T
27
- * --> <mods> def x: T
30
+ * --> <mods> <accessor> def x: T
31
+ *
32
+ * <mods> non-static <module> val x$ = e
33
+ * --> <mods> <module> <accessor> def x$ = e
28
34
*
29
35
* Omitted from the rewritings are
30
36
*
@@ -47,7 +53,7 @@ class Getters extends MiniPhaseTransform with SymTransformer { thisTransform =>
47
53
override def transformSym (d : SymDenotation )(implicit ctx : Context ): SymDenotation = {
48
54
def noGetterNeeded =
49
55
d.is(NoGetterNeeded ) ||
50
- d.initial.asInstanceOf [SymDenotation ].is(PrivateLocal ) && ! d.owner.is(Trait ) ||
56
+ d.initial.asInstanceOf [SymDenotation ].is(PrivateLocal ) && ! d.owner.is(Trait ) && ! d.is( Flags . Lazy ) ||
51
57
d.is(Module ) && d.isStatic ||
52
58
d.isSelfSym
53
59
if (d.isTerm && d.owner.isClass && d.info.isValueType && ! noGetterNeeded) {
@@ -58,7 +64,7 @@ class Getters extends MiniPhaseTransform with SymTransformer { thisTransform =>
58
64
}
59
65
else d
60
66
}
61
- private val NoGetterNeeded = Method | Param | JavaDefined | JavaStatic | Lazy
67
+ private val NoGetterNeeded = Method | Param | JavaDefined | JavaStatic
62
68
63
69
override def transformValDef (tree : ValDef )(implicit ctx : Context , info : TransformerInfo ): Tree =
64
70
if (tree.symbol is Method ) DefDef (tree.symbol.asTerm, tree.rhs) else tree
0 commit comments