From 63d68bf4d3cbac82f6d9faf19acd5589603a17ee Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 5 Jan 2017 09:58:21 +0100 Subject: Fix #1878: Generate fields for final vars. --- compiler/src/dotty/tools/dotc/transform/Memoize.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compiler/src/dotty/tools/dotc/transform/Memoize.scala') diff --git a/compiler/src/dotty/tools/dotc/transform/Memoize.scala b/compiler/src/dotty/tools/dotc/transform/Memoize.scala index 0314d4ec4..63edc0256 100644 --- a/compiler/src/dotty/tools/dotc/transform/Memoize.scala +++ b/compiler/src/dotty/tools/dotc/transform/Memoize.scala @@ -102,7 +102,7 @@ import Decorators._ case _ => t } skipBlocks(tree.rhs) match { - case lit: Literal if sym.is(Final) && isIdempotentExpr(tree.rhs) => + case lit: Literal if sym.is(Final, butNot = Mutable) && isIdempotentExpr(tree.rhs) => // duplicating scalac behavior: for final vals that have rhs as constant, we do not create a field // and instead return the value. This seemingly minor optimization has huge effect on initialization // order and the values that can be observed during superconstructor call -- cgit v1.2.3