diff options
Diffstat (limited to 'test/files/neg/t0764.scala')
-rw-r--r-- | test/files/neg/t0764.scala | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/test/files/neg/t0764.scala b/test/files/neg/t0764.scala index f2cc65cf7d..9f77a59414 100644 --- a/test/files/neg/t0764.scala +++ b/test/files/neg/t0764.scala @@ -1,14 +1,45 @@ class Top[A] { - type AType = A + type AType = A } trait Node { outer => - type T <: Node - def prepend = new Node { type T = outer.type } + 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 }] { + extends Top[Node { type T = NextType }] { - new Main[AType]( (value: AType).prepend ) + 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) +} +*/
\ No newline at end of file |