0__*_*0__ 4 types scala path-dependent-type
这是一个非常简洁的版本:
case class Brickwall[A](otherSide: A)
trait Monoman { def me(m: this.type): Unit }
def test(m: Monoman): Unit = m.me(Brickwall(m).otherSide)
-> error: type mismatch;
found : Monoman
required: m.type
Run Code Online (Sandbox Code Playgroud)
愚蠢的砖墙不让我通过.任何想法如何可能?秘密斯卡拉隧道的影响?希望...
据我所知,Scala编译器拒绝推断路径依赖类型,因此一点类型注释有助于:
def test( m: Monoman ) { m.me( Brickwall[m.type]( m ).otherSide )}
Run Code Online (Sandbox Code Playgroud)