File tree Expand file tree Collapse file tree 3 files changed +3
-25
lines changed
src/compiler/scala/tools/nsc/transform Expand file tree Collapse file tree 3 files changed +3
-25
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ abstract class Constructors extends Statics with Transform with TypingTransforme
171
171
// class Outer { def test = {class LocalParent; class LocalChild extends LocalParent } }
172
172
//
173
173
// See run/t9408.scala for related test cases.
174
- def omittableParamAcc (sym : Symbol ) = sym.isParamAccessor && sym.isPrivateLocal
174
+ def omittableParamAcc (sym : Symbol ) = sym.isParamAccessor && sym.isPrivateLocal && ! sym.isVariable
175
175
def omittableOuterAcc (sym : Symbol ) = isEffectivelyFinal && sym.isOuterAccessor && ! sym.isOverridingSymbol
176
176
val omittables = mutable.Set .empty[Symbol ] ++ (decls filter (sym => omittableParamAcc(sym) || omittableOuterAcc(sym))) // the closure only captures isEffectivelyFinal
177
177
@@ -192,31 +192,9 @@ abstract class Constructors extends Statics with Transform with TypingTransforme
192
192
}
193
193
}
194
194
195
- class DetectVarUses (targets : mutable.Set [Symbol ]) extends Traverser {
196
- override def traverse (tree : Tree ): Unit = if (targets.nonEmpty) {
197
- def mark (sym : Symbol ): Unit = {
198
- targets -= sym
199
- omittables -= sym
200
- }
201
- tree match {
202
- case _ : Select if targets(tree.symbol) => mark(tree.symbol)
203
- case Assign (lhs, _) if targets(lhs.symbol) => mark(lhs.symbol)
204
- case _ =>
205
- }
206
- super .traverse(tree)
207
- }
208
- }
209
-
210
195
if (omittables.nonEmpty)
211
196
(defs.iterator ++ auxConstructors.iterator) foreach detectUsages.traverse
212
197
213
- if (omittables.nonEmpty) {
214
- val omittedVars = omittables.filter(_.isVariable)
215
- if (omittedVars.nonEmpty) {
216
- val detector = new DetectVarUses (omittedVars)
217
- constructor.foreach(detector.traverse)
218
- }
219
- }
220
198
omittables.toSet
221
199
}
222
200
} // OmittablesHelper
Original file line number Diff line number Diff line change 1
1
good boy!
2
2
List()
3
3
List()
4
- List()
4
+ List(private int C.x )
5
5
List(private int D.x)
6
6
List(private int E.x)
7
7
List(private int F.x)
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ class C0(private[this] var c: String) {
7
7
8
8
class A (x : Int ) { assert(x == 1 ) } // elided
9
9
class B (private [this ] val x : Int ) { assert(x == 1 ) } // elided
10
- class C (private [this ] var x : Int ) { } // elided
10
+ class C (private [this ] var x : Int ) { } // kept
11
11
class D (private [this ] var x : Int ) { assert(x == 1 ) } // kept
12
12
class E (private [this ] var x : Int ) { x = 2 } // kept
13
13
class F (private [this ] var x : Int ) { x = 2 ; assert(x == 2 ) } // kept
You can’t perform that action at this time.
0 commit comments