Scala 为什么隐式解析在跨类型投影中不起作用?

Scala 为什么隐式解析在跨类型投影中不起作用?,scala,implicit,type-level-computation,Scala,Implicit,Type Level Computation,我试图使用一个类型类来建立类型之间的(部分)顺序,其中类型通过一个类型成员知道它们的后续类型。但我面临以下隐式解决问题: trait T { type Next <: T } object T { implicit def succ[S <: T]: Succ[S,S#Next] = new Succ[S,S#Next]{} } trait T1 extends T { type Next = T2 } trait T2 extends T { type Nex

我试图使用一个类型类来建立类型之间的(部分)顺序,其中类型通过一个类型成员知道它们的后续类型。但我面临以下隐式解决问题:

trait T {
  type Next <: T
}

object T {
  implicit def succ[S <: T]: Succ[S,S#Next] = new Succ[S,S#Next]{}
}

trait T1 extends T {
  type Next = T2
}

trait T2 extends T {
  type Next = Nothing
}

trait Succ[X1 <: T, X2 <: T]

object Test {
  implicitly[Succ[T1,T2]](T.succ[T1])  //works

  implicitly[Succ[T1,T2]](T.succ)      //fails
  implicitly[Succ[T1,T2]]              //fails
}
trait T{

键入Next我没有一个完整的答案,但这对我来说并不太奇怪scalac抓住一切机会忘记改进。
implicit def success[N@TravisBrown你的建议至少让代码可以编译。想把它变成一个答案吗?我没有一个完整的答案,但这对我来说并不太奇怪scalac利用一切可能的机会忘记改进。
implicit def success[N@TravisBrown你的建议至少能让代码编译。想把它变成一个答案吗?
Error:(23, 29) polymorphic expression cannot be instantiated to expected type;
 found   : [S <: test.objectinf.T]test.objectinf.Succ[S,S#Next]
 required: test.objectinf.Succ[test.objectinf.T1,test.objectinf.T2]
  implicitly[Succ[T1,T2]](T.succ)
                            ^
Error:(23, 29) type mismatch;
 found   : test.objectinf.Succ[S,S#Next]
 required: test.objectinf.Succ[test.objectinf.T1,test.objectinf.T2]
  implicitly[Succ[T1,T2]](T.succ)
                            ^
Error:(24, 13) could not find implicit value for parameter e: test.objectinf.Succ[test.objectinf.T1,test.objectinf.T2]
  implicitly[Succ[T1,T2]]
            ^
Error:(24, 13) not enough arguments for method implicitly: (implicit e: test.objectinf.Succ[test.objectinf.T1,test.objectinf.T2])test.objectinf.Succ[test.objectinf.T1,test.objectinf.T2].
Unspecified value parameter e.
  implicitly[Succ[T1,T2]]
            ^