Skip to content

Commit 54d691e

Browse files
committed
Merge pull request #763 from dotty-staging/constructors/setters
Constructors: fields should be set before super constructor is invoked.
2 parents eec8191 + 6c7d972 commit 54d691e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
245245

246246
cpy.Template(tree)(
247247
constr = cpy.DefDef(constr)(
248-
rhs = Block(mappedSuperCalls ::: copyParams ::: followConstrStats, unitLiteral)),
248+
rhs = Block(copyParams ::: mappedSuperCalls ::: followConstrStats, unitLiteral)),
249249
body = clsStats.toList)
250250
}
251251
}

tests/run/i763.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
abstract class A {
2+
val s: Int
3+
assert(s == 1)
4+
}
5+
6+
class B(val s: Int) extends A
7+
8+
object Test extends B(1) {
9+
def main(args: Array[String]): Unit = {
10+
s
11+
}
12+
}

0 commit comments

Comments
 (0)