blob: ac4e971062e58b76a90f3b6cb2318e4d8ea7a8b5 (
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
27
28
29
|
abstract class Module {}
abstract class T {
type moduleType <: Module
val module: moduleType
}
abstract class Base {
type mType = Module
type tType = T { type moduleType <: mType }
}
abstract class Derived extends Base {
val t: T = ???
// trying a simple dependent closure body first
def cont1[X, Y](x: X)(f: X => Y): Y = f(x)
cont1(t)(x => x.module)
// trying an indirectly dependent closure body first
def cont2[X, Y](x: X)(f: X => Int => Y): Y = f(x)(1)
cont2(t)(x => z => x.module)
// trying the original, harder case next
def f(inputs: List[tType]): Unit = {
for (t <- inputs; m = t.module) { }
}
}
|