public
Created

  • Download Gist
gistfile1.scala
Scala
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
 
trait Page
trait PageData
trait PageOperation {
type P <: Page
}
 
trait PageComponent {
self: PageOperation =>
 
protected var page:P = _
protected var pageData:PageData = _
def initialise(page0:P, pageData0:PageData) {
page = page0
pageData = pageData0
}
}
 
trait AhoyPageOperation extends PageOperation {
type P = AhoyPage
}
 
class AhoyPage extends Page
 
object MyPageComponent extends PageComponent with AhoyPageOperation {}
 
 
trait PageInfo {
self: PageOperation =>
 
def page : P
}
 
trait AhoyPageInfo extends PageInfo with AhoyPageOperation {
def page = new AhoyPage // for the example
}
 
object MyApp extends App {
MyPageComponent.initialise(new AhoyPage, new PageData {})
//
MyPageComponent.initialise(new MyPageComponent.P, new PageData {})
 
 
MyPageComponent.initialise((new AhoyPageInfo {}).page , new PageData{})
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.