File: t1957.scala

package info (click to toggle)
scala 2.11.12-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 62,924 kB
  • sloc: javascript: 28,808; java: 13,415; xml: 3,135; sh: 1,620; python: 756; makefile: 38; awk: 36; ansic: 6
file content (38 lines) | stat: -rw-r--r-- 1,248 bytes parent folder | download | duplicates (4)
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
object Test {
    abstract class Settings {}

    abstract class Grist
    { self =>
        type settingsType <: Settings
        type moduleType <: Module {type settingsType = self.settingsType}
        val module: moduleType
    }

    abstract class Tool
    { self =>
        type settingsType <: Settings
        type moduleType = Module { type settingsType = self.settingsType }
        type gristType = Grist { type moduleType <: self.moduleType; type settingsType <: self.settingsType }

        def inputGrist: List[gristType]
    }

    abstract class Module
    { self =>
        type settingsType <: Settings
        final type commonModuleType = Module {type settingsType = self.settingsType}
        type selfType >: self.type <: commonModuleType

        // BTW: if we use the commented out type decls, the code compiles successfully
        // type gristType = Grist {type settingsType <: self.settingsType; type moduleType <: commonModuleType }

        val tools: List[Tool {type settingsType = self.settingsType}]

        protected def f: List[commonModuleType] =
        {
            val inputGrists = tools.flatMap(_.inputGrist) // val inputGrists: List[gristType] =
            inputGrists.map(_.module)
        }

    }
}