diff options
author | Som Snytt <som.snytt@gmail.com> | 2012-03-21 16:02:21 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2012-03-23 12:13:11 -0700 |
commit | 47bfd744177121de08fed489a5b0b1b59a1ae06a (patch) | |
tree | 628d19292c3596a94eda799b5583b99af494d44a /test/files | |
parent | e2951867f51bf464b07f759662bfc50dfaf48e5b (diff) | |
download | scala-47bfd744177121de08fed489a5b0b1b59a1ae06a.tar.gz scala-47bfd744177121de08fed489a5b0b1b59a1ae06a.tar.bz2 scala-47bfd744177121de08fed489a5b0b1b59a1ae06a.zip |
Ctor default-getters unique name and are typed in constructor context
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/t5543.check | 3 | ||||
-rw-r--r-- | test/files/run/t5543.scala | 26 |
2 files changed, 29 insertions, 0 deletions
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()()) + } +} |