I have the following:
class Graph {
case class Node(val a: Int)
def createNodes = Node(5) :: Node(7) :: Nil
}
def test(g: Graph): List[g.Node] = g.createNodes
Then I do:
def test2(g: Graph) = {
val nodes = test(g)
}
I was expecting for the compiler to track that nodes
is of type List[g.Node]
, but it seems to unable to do that and assigns its type to List[Graph#Node]
. If I try type ascription, it still does not help: val nodes: List[g.Node] = test(g)
I feel like I'm missing something important behind path-dependent types in scala. How can I make test(g)
return List[g.Node]
and why scala needs path-dependent types converted to A#B
if almost always we need a.B
?
g
? - Daniel Langdon