aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/t0017.scala
blob: d2bcda08d486ee7388483b0809cda112e7fea51b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Quantity {
    def getValue = 0;
    def connect(c: Constraint) = c.newValue;
}

abstract class Constraint(q: Quantity) {
    def newValue: Unit;
    q connect this
}

class Adder(q: Quantity) extends Constraint(q) {
    def newValue = Console.println(q.getValue);
}

object Main {
    def main(args: Array[String]): Unit = {
        val x = new Quantity;
        new Adder(x);
        ()
    }
}