Skip to content

Commit c65a608

Browse files
committed
Getters now also makes getters for lazy vals.
1 parent e3449e9 commit c65a608

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/dotty/tools/dotc/transform/Getters.scala

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,21 @@ import Decorators._
1616
/** Performs the following rewritings for fields of a class:
1717
*
1818
* <mods> val x: T = e
19-
* --> <mods> <stable> def x: T = e
19+
* --> <mods> <stable> <accessor> def x: T = e
2020
* <mods> var x: T = e
21-
* --> <mods> def x: T = e
21+
* --> <mods> <accessor> def x: T = e
2222
*
2323
* <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
2528
*
2629
* <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
2834
*
2935
* Omitted from the rewritings are
3036
*
@@ -47,7 +53,7 @@ class Getters extends MiniPhaseTransform with SymTransformer { thisTransform =>
4753
override def transformSym(d: SymDenotation)(implicit ctx: Context): SymDenotation = {
4854
def noGetterNeeded =
4955
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) ||
5157
d.is(Module) && d.isStatic ||
5258
d.isSelfSym
5359
if (d.isTerm && d.owner.isClass && d.info.isValueType && !noGetterNeeded) {
@@ -58,7 +64,7 @@ class Getters extends MiniPhaseTransform with SymTransformer { thisTransform =>
5864
}
5965
else d
6066
}
61-
private val NoGetterNeeded = Method | Param | JavaDefined | JavaStatic | Lazy
67+
private val NoGetterNeeded = Method | Param | JavaDefined | JavaStatic
6268

6369
override def transformValDef(tree: ValDef)(implicit ctx: Context, info: TransformerInfo): Tree =
6470
if (tree.symbol is Method) DefDef(tree.symbol.asTerm, tree.rhs) else tree

0 commit comments

Comments
 (0)