File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -212,7 +212,6 @@ class Constructors extends MiniPhase with IdentityDenotTransformer { thisPhase =
212212 }
213213 splitStats(stats1)
214214 case Nil =>
215- (Nil , Nil )
216215 }
217216 splitStats(tree.body)
218217
@@ -222,6 +221,10 @@ class Constructors extends MiniPhase with IdentityDenotTransformer { thisPhase =
222221 dropped += acc
223222 Nil
224223 }
224+ else if (! isRetained(acc.field)) { // It may happen for unit fields, tests/run/i6987.scala
225+ dropped += acc.field
226+ Nil
227+ }
225228 else {
226229 if (acc.hasAnnotation(defn.TransientParamAnnot ))
227230 ctx.error(em " transient parameter $acc is retained as field in class ${acc.owner}" , acc.sourcePos)
Original file line number Diff line number Diff line change 1+ enum SingleCase {
2+ case TheCase1 (u : Unit )
3+ }
4+
5+ case class TheCase2 (u : Unit )
6+
7+ case class TheCase3 (s : String , u : Unit )
8+
9+ class TheCase4 (val u : Unit )
10+
11+ abstract class TheCase5 (val u : Unit )
12+
13+ @ main def Test =
14+ SingleCase .TheCase1 (())
15+ TheCase2 (())
16+ TheCase3 (" " , ())
17+ TheCase4 (())
18+ new TheCase5 (()) {}
You can’t perform that action at this time.
0 commit comments