summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-09-24 15:09:16 +0200
committerJason Zaugg <jzaugg@gmail.com>2013-09-24 15:15:06 +0200
commitfa271e24342831bb6d7b683fddd1a4a11825d39d (patch)
treeb1004cae617496946a7c256becbbc3b534bd02b0 /src
parentc2e3b0656bb449e95a529e266294aeabb9cbef3f (diff)
downloadscala-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 'src')
-rw-r--r--src/compiler/scala/tools/nsc/transform/Mixin.scala1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala
index 7b545be07e..4eb8eb933c 100644
--- a/src/compiler/scala/tools/nsc/transform/Mixin.scala
+++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala
@@ -89,6 +89,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
settings.checkInit
&& sym.isGetter
&& !sym.isInitializedToDefault
+ && !isConstantType(sym.info.finalResultType) // SI-4742
&& !sym.hasFlag(PARAMACCESSOR | SPECIALIZED | LAZY)
&& !sym.accessed.hasFlag(PRESUPER)
&& !sym.isOuterAccessor