blob: f2f10bbfb72f3de1004143f6f9ed7822284ff96a (
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
30
31
32
33
34
35
|
import language.higherKinds
object higherKinded {
type Untyped = Null
class Tree[-T >: Untyped] {
type ThisType[-U >: Untyped] <: Tree[U]
def withString(s: String): ThisType[String] = withString(s)
}
class Ident[-T >: Untyped] extends Tree[T] {
type ThisType[-U] = Ident[U]
}
val id = new Ident[Integer]
val y = id.withString("abc")
val z: Ident[String] = y
val zz: tpd.Tree = y
abstract class Instance[T >: Untyped] {
type Tree = higherKinded.Tree[T]
}
object tpd extends Instance[String]
def transform(tree: Tree[String]) = {
val tree1 = tree.withString("")
tree1: Tree[String]
}
}
|