File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ trait Sys { type X }
3+
4+ trait Obj {
5+ erased val s : Sys
6+ lazy val t : Sys
7+
8+ type S = s.X // error: not a legal path, since nonfinal
9+ type T = t.X // error: not a legal path, since nonfinal
10+ }
Original file line number Diff line number Diff line change 1+ trait Sys
2+
3+ trait Obj {
4+ erased val s : Sys
5+
6+ type S = s.type // error: non final
7+ }
Original file line number Diff line number Diff line change 1+ trait Txn [S <: Sys [S ]] {
2+ def system : S
3+
4+ def newId (): S # Id
5+
6+ def newVar [A ](id : S # Id , init : A ): S # Vr [A ]
7+ }
8+
9+ trait Var [Tx , A ] {
10+ def apply ()(implicit tx : Tx ): A
11+
12+ def update (x : A )(implicit tx : Tx ): Unit
13+ }
14+
15+ trait Sys [S <: Sys [S ]] {
16+ type Tx <: Txn [S ]
17+ type Id
18+ type Vr [A ] <: Var [S # Tx , A ]
19+ }
20+
21+ abstract class UseCase [S <: Sys [S ]](id : S # Id ) {
22+ def mk (x : Int )(implicit tx : S # Tx ): S # Vr [Int ] = {
23+ val vr = tx.newVar[Int ](id, x)
24+ vr
25+ }
26+
27+ def rd (vr : S # Vr [Int ])(implicit tx : S # Tx ): Int = vr()
28+ }
You can’t perform that action at this time.
0 commit comments