开发者

Are recursive structural types not supported in scala anymore?

Some people claim that scala is able to deal with recursive structural types if you use the -Yrecursion option of scalac. Nevertheless my minimalistic example does not compile:

type Num = {
  def +(n: Num): Num
}

Compilation yields:

$ scalac -version
Scala compiler ve开发者_运维百科rsion 2.8.0.final -- Copyright 2002-2010, LAMP/EPFL
$ scalac -Yrecursion 100 Num.scala 
Num.scala:3: error: recursive method + needs result type
def +(n: Num): Num
               ^
one error found

Did this change? Shouldn't the example compile?


Recursive structural types have never been supported. The -Yrecursion option does something unrelated to structural types.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜