我使用從屬方法類型和編譯器(2.10.0.r26005-b20111114020239)的每晚構建試圖抽象case類的模塊中進行匹配。我從Miles Sabin' example發現了一些靈感。 我真的不明白什麼是錯在下面的(自足)代碼。輸出取決於foo中的模式順序。 // afaik, the compiler doesn't not expose the unapply method
//
我試圖讓Scala找到來自單例類型的路徑依賴類型的正確類型。 首先,這裏是該示例的類型的容器,和一個實例: trait Container {
type X
def get(): X
}
val container = new Container {
type X = String
def get(): X = ""
}
我可以看到在第一次嘗試的
當與Scala的相關方法類型的打,我遇到了默認的方法的參數衝突: abstract class X {
type Y
case class YY(y: Y)
}
object XX extends X {
type Y = String
}
trait SomeTrait {
def method(x: X)(y: x.YY, default:
我試圖使用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 compile
我有一堆看起來都一樣的數據存儲類型類。 trait FooStore[C] {
def create(f: FooId => Foo)(c: C): Foo
// update and find methods
}
我想簡化事情,並希望利用相關的方法類型,以獲得更接近於 sealed trait AR {
type Id
type Type
}