我试图使用Scala 2.10.0-M1如下:类型等效问题
def bar[C <: Container](c: C)(x: C#X): c.X = x
:使用这种形式时
trait Container {
type X
}
class Test[C <: Container](val c: C) {
def foo(x: c.X): C#X = x // this compiles fine
def bar(x: C#X): c.X = x // this does not compile
}
的问题是相同的
我真的不明白为什么foo
编译,而bar
没有。
我认为c.X
和C#X
这里应该是一样的。
另外,我不明白的错误消息:
[error] found : x.type (with underlying type C#X)
[error] required: Test.this.c.X
[error] possible cause: missing arguments for method or constructor
[error] def bar(x: C#X): c.X = x // this does not compile
任何想法?
这是一个通常是一个设计问题,我想从路径依赖类型中检索类型。我为此创建了[另一个问题](http://stackoverflow.com/questions/9065343/exposing-a-path-dependent-type-coming-from-a-singleton-type)。 – betehess 2012-01-30 14:29:18