Skip to content

Fix #5234: Add regression test #5719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/neg/i5234a.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
object Test {
import implicits.Not

class Foo
class Bar
implicit def foo: Foo = ???
implicitly[Foo]
implicitly[Not[Foo]] // error
implicitly[Not[Bar]]
}
30 changes: 30 additions & 0 deletions tests/neg/i5234b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
final class Not2[T] private ()

trait LowPriorityNot2 {

/** A fallback method used to emulate negation in Scala 2 */
implicit def default[T]: Not2[T] = Not2.value.asInstanceOf[Not2[T]]
}
object Not2 extends LowPriorityNot2 {

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

/** One of two ambiguous methods used to emulate negation in Scala 2 */
implicit def amb1[T](implicit ev: T): Not2[T] = ???

/** One of two ambiguous methods used to emulate negation in Scala 2 */
implicit def amb2[T](implicit ev: T): Not2[T] = ???
}

object Test {
class Foo
class Bar
implicit def foo: Foo = ???
implicitly[Foo]
implicitly[Not2[Foo]] // error
implicitly[Not2[Bar]]
}
9 changes: 9 additions & 0 deletions tests/neg/i5234c.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
object Test {
import implicits.Not

class Foo
implicit def foo: Foo = ???

def foo[T](implicit ev: Not[T]) = ???
foo[Foo] // error
}