Я пытаюсь сделать следующее с Scala 2.10.0-M1:
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
}
Проблема при использовании этой формы та же:
def bar[C <: Container](c: C)(x: C#X): c.X = x
Я не оченьпонять, почему 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
Есть идеи?