Skip to content

Commit ec64c09

Browse files
committed
Rename Not to NotGiven. Hopefully this makes it easier to understand
1 parent ed93a48 commit ec64c09

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

library/src/scala/util/Not.scala renamed to library/src/scala/util/NotGiven.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,38 @@ package scala.util
88
* putting them in different traits we can instead define the following:
99
*
1010
* given i1: D(using ev: C) = ...
11-
* given i2: D(using ev: Not[C]) = ...
11+
* given i2: D(using ev: NotGiven[C]) = ...
1212
*
13-
* `Not` is treated specially in implicit search, similar to the way logical negation
14-
* is treated in Prolog: The implicit search for `Not[C]` succeeds if and only if the implicit
13+
* `NotGiven` is treated specially in implicit search, similar to the way logical negation
14+
* is treated in Prolog: The implicit search for `NotGiven[C]` succeeds if and only if the implicit
1515
* search for `C` fails.
1616
*
1717
* In Scala 2 this form of negation can be simulated by setting up a conditional
1818
* ambiguous implicit and an unconditional fallback, the way it is done with the
1919
* `default`, `amb1` and `amb2` methods below. Due to the way these two methods are
20-
* defined, `Not` is also usable from Scala 2.
20+
* defined, `NotGiven` is also usable from Scala 2.
2121
*
2222
* In Dotty, ambiguity is a global error, and therefore cannot be used to implement negation.
23-
* Instead, `Not` is treated natively in implicit search.
23+
* Instead, `NotGiven` is treated natively in implicit search.
2424
*/
25-
final class Not[+T] private ()
25+
final class NotGiven[+T] private ()
2626

27-
trait LowPriorityNot {
27+
trait LowPriorityNotGiven {
2828

2929
/** A fallback method used to emulate negation in Scala 2 */
30-
given default[T] as Not[T] = Not.value
30+
given default[T] as NotGiven[T] = NotGiven.value
3131
}
32-
object Not extends LowPriorityNot {
32+
object NotGiven extends LowPriorityNotGiven {
3333

34-
/** A value of type `Not` to signal a successful search for `Not[C]` (i.e. a failing
34+
/** A value of type `NotGiven` to signal a successful search for `NotGiven[C]` (i.e. a failing
3535
* search for `C`). A reference to this value will be explicitly constructed by Dotty's
3636
* implicit search algorithm
3737
*/
38-
def value: Not[Nothing] = new Not[Nothing]()
38+
def value: NotGiven[Nothing] = new NotGiven[Nothing]()
3939

4040
/** One of two ambiguous methods used to emulate negation in Scala 2 */
41-
given amb1[T](using ev: T) as Not[T] = ???
41+
given amb1[T](using ev: T) as NotGiven[T] = ???
4242

4343
/** One of two ambiguous methods used to emulate negation in Scala 2 */
44-
given amb2[T](using ev: T) as Not[T] = ???
44+
given amb2[T](using ev: T) as NotGiven[T] = ???
4545
}

0 commit comments

Comments
 (0)