- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
projection types or existential types not handled correctly in 2.8
Tue, 2010-03-30, 16:39
Hi,
I recently added a bug 3211 that got rejected today.
My simplified code is:
class GraphFun {
class Node(val out : Edge)
class Edge
}
class CfgFun {
val gfun = new GraphFun
class Cfg {
type Node = gfun.Node
type Edge = gfun.Edge
}
}
object DFST {
def apply(cfg : CfgFun#Cfg) {
type Node = cfg.Node
type Edge = cfg.Edge
def visit(n: Node, e: Edge): Unit = visit(n, n.out)
()
}
}
The code fails compilation with the following error message:
graph.scala:20: error: type mismatch;
found : _11.type#gfun.Edge
required: Edge
def visit(n: Node, e: Edge): Unit = visit(n, n.out)
I was told the code is ill-typed and the reason for it is projection
type used. While I don't know the details of scala typing rules and
cannot confirm or deny it, if I change the code to use existential val
as in:
def apply(cfg : f.Cfg forSome {val f : CfgFun})
the code still fails (though the simplified version listed in my issue
compiles).
Is there a bug somewhere and what else can I do to fix the problem?
Thank you in advance,
Eugene.
P.S. The code compiles under 2.7.7, so it looks like the typing rules
have changed?