Skip to content

Commit d264aa2

Browse files
committed
Fix #5234: Add regression test
1 parent 845fd59 commit d264aa2

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

tests/neg/i5234a.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
}

tests/neg/i5234b.scala

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
}

tests/neg/i5234c.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
}

0 commit comments

Comments
 (0)