File tree 3 files changed +49
-0
lines changed
3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ object Test {
2
+ import implicits .Not
3
+
4
+ class Foo
5
+ class Bar
6
+ implicit def foo : Foo = ???
7
+ implicitly[Foo ]
8
+ implicitly[Not [Foo ]] // error
9
+ implicitly[Not [Bar ]]
10
+ }
Original file line number Diff line number Diff line change
1
+ final class Not2 [T ] private ()
2
+
3
+ trait LowPriorityNot2 {
4
+
5
+ /** A fallback method used to emulate negation in Scala 2 */
6
+ implicit def default [T ]: Not2 [T ] = Not2 .value.asInstanceOf [Not2 [T ]]
7
+ }
8
+ object Not2 extends LowPriorityNot2 {
9
+
10
+ /** A value of type `Not` to signal a successful search for `Not[C]` (i.e. a failing
11
+ * search for `C`). A reference to this value will be explicitly constructed by
12
+ * Dotty's implicit search algorithm
13
+ */
14
+ def value : Not2 [Nothing ] = new Not2 [Nothing ]()
15
+
16
+ /** One of two ambiguous methods used to emulate negation in Scala 2 */
17
+ implicit def amb1 [T ](implicit ev : T ): Not2 [T ] = ???
18
+
19
+ /** One of two ambiguous methods used to emulate negation in Scala 2 */
20
+ implicit def amb2 [T ](implicit ev : T ): Not2 [T ] = ???
21
+ }
22
+
23
+ object Test {
24
+ class Foo
25
+ class Bar
26
+ implicit def foo : Foo = ???
27
+ implicitly[Foo ]
28
+ implicitly[Not2 [Foo ]] // error
29
+ implicitly[Not2 [Bar ]]
30
+ }
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ import implicits .Not
3
+
4
+ class Foo
5
+ implicit def foo : Foo = ???
6
+
7
+ def foo [T ](implicit ev : Not [T ]) = ???
8
+ foo[Foo ] // error
9
+ }
You can’t perform that action at this time.
0 commit comments