summaryrefslogtreecommitdiff
path: root/test/files/run/t5543.scala
blob: 651bc7f2b24f25e575dffb11f2eabb9de6a2ee74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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, in a happier world
    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()())
  }
}