File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change
1
+ opaque type Opt [A >: Null ] = A
2
+
3
+ inline def (x : Opt [A ]) nonEmpty[A >: Null ]: Boolean = x.get != null // error: Implementation restriction
4
+ inline def (x : Opt [A ]) isEmpty[A >: Null ]: Boolean = x.get == null // error: Implementation restriction
5
+ inline def (x : Opt [A ]) isDefined[A >: Null ]: Boolean = x.nonEmpty // error: Implementation restriction
6
+ inline def (x : Opt [A ]) get[A >: Null ]: A = Opt .unOpt(x) // error: Implementation restriction
7
+
8
+ object Opt
9
+ {
10
+ inline def unOpt [A >: Null ](x : Opt [A ]): A = x // error: Implementation restriction
11
+ inline def apply [A >: Null ](x : A ): Opt [A ] = x // error: Implementation restriction
12
+ inline def some [A >: Null ](x : A ): Opt [A ] = x // error: Implementation restriction
13
+ inline def none [A >: Null ]: Opt [A ] = null // error: Implementation restriction
14
+ inline def fromOption [A >: Null ](x : Option [A ]) = x.orNull // error: Implementation restriction
15
+ }
You can’t perform that action at this time.
0 commit comments