From 47bfd744177121de08fed489a5b0b1b59a1ae06a Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Wed, 21 Mar 2012 16:02:21 -0700 Subject: Ctor default-getters unique name and are typed in constructor context --- test/files/run/t5543.check | 3 +++ test/files/run/t5543.scala | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 test/files/run/t5543.check create mode 100644 test/files/run/t5543.scala (limited to 'test/files') diff --git a/test/files/run/t5543.check b/test/files/run/t5543.check new file mode 100644 index 0000000000..517038f4c7 --- /dev/null +++ b/test/files/run/t5543.check @@ -0,0 +1,3 @@ +Test, 7, 119 +m, 3, 19 +Test, 5, 85 diff --git a/test/files/run/t5543.scala b/test/files/run/t5543.scala new file mode 100644 index 0000000000..9d9c645d7a --- /dev/null +++ b/test/files/run/t5543.scala @@ -0,0 +1,26 @@ + +object Test extends Function0[Int] { + // this and v resolve to Test.this, Test.v not A.this, A.v + class A(x: Function0[Int] = this)(val a: Int = v, val b: Int = v * x()) extends Function0[Int] { + val v = 3 + override def toString = x.toString +", "+ a +", "+ b + // ordinary instance scope + def m(i: Int = v, y: Function0[Int] = this) = "m, "+ i +", "+ y() + def apply() = 19 + } + object A { + val v = 5 + // should happily coexist with default getters + def init(x: Function0[Int] = Test.this)(a: Int = v, b: Int = v * x()) = x.toString +", "+ a +", "+ b + override def toString = "A" + } + val v = 7 + def apply() = 17 + override def toString = "Test" + def main(args: Array[String]) { + val sut = new A()() + println(sut.toString) + println(sut.m()) + println(A.init()()) + } +} -- cgit v1.2.3