/
any.scala
55 lines (50 loc) · 1.43 KB
/
any.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package scala.compiletime
package ops
import annotation.experimental
object any:
/** Equality comparison of two singleton types.
* ```scala
* val eq1: 1 == 1 = true
* val eq2: 1 == "1" = false
* val eq3: "1" == "1" = true
* ```
* @syntax markdown
*/
type ==[+X, +Y] <: Boolean
/** Inequality comparison of two singleton types.
* ```scala
* val eq1: 1 != 1 = false
* val eq2: 1 != "1" = true
* val eq3: "1" != "1" = false
* ```
* @syntax markdown
*/
type !=[+X, +Y] <: Boolean
/** Tests if a type is a constant.
* ```scala
* val c1: IsConst[1] = true
* val c2: IsConst["hi"] = true
* val c3: IsConst[false] = true
* val c4: IsConst[Any] = false
* ```
* If the type is not yet known, then `IsConst` remains unevaluated, and
* will be evaluated only at its concrete type application. E.g.:
* ```scala
* //def `isConst`` returns the type `IsConst[X]`, since `X` is not yet known.
* def isConst[X] : IsConst[X] = ???
* val c5 : true = isConst[1] //now the type is known to be a constant
* val c6 : false = isConst[Any] //now the type is known to be not a constant
* ```
* @syntax markdown
*/
@experimental
type IsConst[X] <: Boolean
/** String conversion of a constant singleton type.
* ```scala
* val s1: ToString[1] = "1"
* val sTrue: ToString[true] = "true"
* ```
* @syntax markdown
*/
@experimental
type ToString[+X] <: String