diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-09-24 15:09:16 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-09-24 15:15:06 +0200 |
commit | fa271e24342831bb6d7b683fddd1a4a11825d39d (patch) | |
tree | b1004cae617496946a7c256becbbc3b534bd02b0 /test/files/run/t4742.scala | |
parent | c2e3b0656bb449e95a529e266294aeabb9cbef3f (diff) | |
download | scala-fa271e24342831bb6d7b683fddd1a4a11825d39d.tar.gz scala-fa271e24342831bb6d7b683fddd1a4a11825d39d.tar.bz2 scala-fa271e24342831bb6d7b683fddd1a4a11825d39d.zip |
SI-4742 Make -Xcheckinit aware of constants.
Members defined as `final val x = <literal>` are given
a ConstantType. The constant is folded into the accessor
method `x`, and the field itself is never initialized.
(Related discussion: SI-4605)
As such, -Xcheckinit spuriously warns when calling that
accessor.
This commit disables the checks for constants.
This will also fix the checkinit build (failure tracked as SI-7839),
which is the victim of this a spurious scolding.
Diffstat (limited to 'test/files/run/t4742.scala')
-rw-r--r-- | test/files/run/t4742.scala | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/files/run/t4742.scala b/test/files/run/t4742.scala new file mode 100644 index 0000000000..3b42c0c120 --- /dev/null +++ b/test/files/run/t4742.scala @@ -0,0 +1,7 @@ +trait T { val x: Int = 0 } +object O extends T { override final val x = 1 } + +object Test extends App { + // was throwing an UnitializedFieldError as constant 1 is folded into the accessor + assert((O: T).x == 1) +} |