Are recursive structural types not supported in scala?

Some people claim that scala can deal with recursive structural types if you use the -Yrecursion option for scalac. However, my minimalist example does not compile:

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

Compilation output:

$ scalac -version
Scala compiler version 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

Has this changed? Should I compile an example?

+5
source share
1 answer

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

+8
source

All Articles