Scala 类型为的成员的隐式转换

Scala 类型为的成员的隐式转换,scala,implicit,dependent-type,path-dependent-type,scala-2.11,Scala,Implicit,Dependent Type,Path Dependent Type,Scala 2.11,鉴于: 这: 收益率: val foo = (_: Int) * 2 val x: foo.Ret = 3 但是,以下方法可行: error: type Ret is not a member of Int => Int val x: foo.Ret = ??? ^ 隐式转换不用于访问类型成员吗?隐式转换不能用于访问类型成员。无论实施细节如何,这都可以看作是规范中两项的逻辑结果: 导致路径依赖类型的路径必须只有稳定元素(在规范中) 隐式转换是一种方法/函数,其

鉴于:

这:

收益率:

val foo = (_: Int) * 2
val x: foo.Ret = 3
但是,以下方法可行:

  error: type Ret is not a member of Int => Int
val x: foo.Ret = ???
          ^

隐式转换不用于访问类型成员吗?

隐式转换不能用于访问类型成员。无论实施细节如何,这都可以看作是规范中两项的逻辑结果:

  • 导致路径依赖类型的路径必须只有稳定元素(在规范中)
  • 隐式转换是一种方法/函数,其结果总是不稳定的

因此,这两者不兼容:您不能在导致路径依赖类型的路径上进行隐式转换,因为转换本身是不稳定的,使路径无效。

这似乎是相关的源代码:但需要花时间来仔细研究:)我猜此功能在类型声明级别上不起作用。我尝试查看引用,但没有找到此限制。在我看来是一只虫子。
  error: type Ret is not a member of Int => Int
val x: foo.Ret = ???
          ^
val foo = (_: Int) * 2
val fooR = new WithRetType(foo)
val x: fooR.Ret = 3