@@ -46,8 +46,11 @@ class Constructors extends MiniPhaseTransform with IdentityDenotTransformer { th
46
46
private def markUsedPrivateSymbols (tree : RefTree )(implicit ctx : Context ): Unit = {
47
47
48
48
val sym = tree.symbol
49
- def retain () =
49
+ def retain () = {
50
+ // println(i"retained: $sym")
51
+ // assert(i"$sym" != "value sf", ctx.owner.ownersIterator.toList)
50
52
retainedPrivateVals.add(sym)
53
+ }
51
54
52
55
if (sym.exists && sym.owner.isClass && mightBeDropped(sym)) {
53
56
val owner = sym.owner.asClass
@@ -56,7 +59,8 @@ class Constructors extends MiniPhaseTransform with IdentityDenotTransformer { th
56
59
case Ident (_) | Select (This (_), _) =>
57
60
def inConstructor = {
58
61
val method = ctx.owner.enclosingMethod
59
- method.isPrimaryConstructor && ctx.owner.enclosingClass == owner
62
+ method.isPrimaryConstructor && ctx.owner.enclosingClass == owner// ||
63
+ // method.isGetter && !method.is(Lazy)
60
64
}
61
65
if (inConstructor && (sym.is(ParamAccessor ) || seenPrivateVals.contains(sym))) {
62
66
// used inside constructor, accessed on this,
@@ -79,8 +83,10 @@ class Constructors extends MiniPhaseTransform with IdentityDenotTransformer { th
79
83
}
80
84
81
85
override def transformValDef (tree : tpd.ValDef )(implicit ctx : Context , info : TransformerInfo ): tpd.Tree = {
82
- if (mightBeDropped(tree.symbol))
86
+ if (mightBeDropped(tree.symbol)) {
83
87
(if (isWildcardStarArg(tree.rhs)) retainedPrivateVals else seenPrivateVals) += tree.symbol
88
+ assert(! isWildcardStarArg(tree.rhs))
89
+ }
84
90
tree
85
91
}
86
92
@@ -183,11 +189,13 @@ class Constructors extends MiniPhaseTransform with IdentityDenotTransformer { th
183
189
case stat @ ValDef (name, tpt, _) if ! stat.symbol.is(Lazy ) && ! stat.symbol.hasAnnotation(defn.ScalaStaticAnnot ) =>
184
190
val sym = stat.symbol
185
191
if (isRetained(sym)) {
192
+ // println(i"$sym is retained")
186
193
if (! stat.rhs.isEmpty && ! isWildcardArg(stat.rhs))
187
194
constrStats += Assign (ref(sym), intoConstr(stat.rhs, sym)).withPos(stat.pos)
188
195
clsStats += cpy.ValDef (stat)(rhs = EmptyTree )
189
196
}
190
197
else if (! stat.rhs.isEmpty) {
198
+ // println(i"$sym ${sym.flags} is not retained")
191
199
dropped += sym
192
200
sym.copySymDenotation(
193
201
initFlags = sym.flags &~ Private ,
0 commit comments