Is scala.Singleton pure compiler fiction?

前端 未结 1 1186
孤街浪徒
孤街浪徒 2021-01-12 12:38

The Scala Language Specification says under §3.2.1:

A stable type is either a singleton type or a type which is declared to be a subtype of trait

1条回答
  •  -上瘾入骨i
    2021-01-12 13:12

    Finally found something on this:

    The type Singleton is essentially an encoding trick for existentials with values. I.e.

    T forSome { val x: T } 
    

    is turned into

    [x.type := X] T forSome { type X <:T with Singleton } 
    

    Source: http://scala-programming-language.1934581.n4.nabble.com/scala-Singleton-td1940630.html

    0 讨论(0)
提交回复
热议问题