blob: 7ee76feabd1e387909678c083195b60aa8621ba9 (
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
36
37
38
39
40
41
42
43
44
45
|
class Top[A] {
type AType = A
}
trait Node { outer =>
type T <: Node
def prepend = new Node { type T = outer.type }
}
class Main[NextType <: Node](value: Node { type T = NextType })
extends Top[Node { type T = NextType }] {
new Main[AType]( (value: AType).prepend )
}
/* we've been back-and-forth on this one -- see PRs on SI-8177 for the reasoning
I think it should compile and that the following error is due to broken =:= on existentials
found : Node{type T = _1.type} where val _1: Node{type T = NextType}
required: Node{type T = Main.this.AType}
(which expands to) Node{type T = Node{type T = NextType}}
I claim (omitting the forSome for brevity, even though the premature skolemization is probably the issue)
_1.type =:= Main.this.AType
because
(1) _1.type <:< Main.this.AType and (2) Main.this.AType <:< _1.type
(1), because:
_1.type <:< Node{type T = NextType} (because skolemization and _1's upper bound)
(2), because:
Node{type T = NextType} <:< _1.type forSome val _1: Node{type T = NextType}
because:
Node{type T = NextType} <:< T forSome {type T <: Node{type T = NextType} with Singleton}
because
Node{type T = NextType} <:< Node{type T = NextType} with Singleton
hmmm.. might the with Singleton be throwing a wrench in our existential house?
Behold the equivalent program which type checks without the fix for SI-8177.
(Expand type alias, convert type member to type param;
note the covariance to encode subtyping on type members.)
class Node[+T <: Node[_]] { def prepend = new Node[this.type] }
class Main[NextType <: Node[_]](value: Node[NextType]) {
new Main(value.prepend)
}
*/
|