From 886e0a6a1c5623337e0362bd37fc4a2d82887675 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 11 Apr 2011 07:01:55 +0000 Subject: Closes #4396. No review. --- .../scala/tools/nsc/transform/Constructors.scala | 1 + test/files/run/t4396.check | 4 ++++ test/files/run/t4396.scala | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 test/files/run/t4396.check create mode 100644 test/files/run/t4396.scala diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 75c35ffb49..1fb1cf11f9 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -77,6 +77,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { def isParamRef(sym: Symbol) = sym.isParamAccessor && sym.owner == clazz && + !(clazz isSubClass DelayedInitClass) && !(sym.isGetter && sym.accessed.isVariable) && !sym.isSetter private def possiblySpecialized(s: Symbol) = specializeTypes.specializedTypeVars(s).nonEmpty diff --git a/test/files/run/t4396.check b/test/files/run/t4396.check new file mode 100644 index 0000000000..b0b4014430 --- /dev/null +++ b/test/files/run/t4396.check @@ -0,0 +1,4 @@ +hallo +constructor +out:22 +bye diff --git a/test/files/run/t4396.scala b/test/files/run/t4396.scala new file mode 100644 index 0000000000..9911f323a5 --- /dev/null +++ b/test/files/run/t4396.scala @@ -0,0 +1,18 @@ +trait M extends DelayedInit { + def delayedInit(body : => Unit) { + println("hallo") + body + println("bye") + } +} + +class C(init : Int) extends M { + def foo = init + println("constructor") + var x = init + println("out:"+x) +} + +object Test extends App { + new C(22) +} -- cgit v1.2.3