diff --git a/tests/neg/implicitSearch.scala b/tests/neg/implicitSearch.scala new file mode 100644 index 000000000000..bcb12c3e9a7c --- /dev/null +++ b/tests/neg/implicitSearch.scala @@ -0,0 +1,18 @@ +object Test { + + type T = String + + class Ord[T] + implicit def listOrd[T](implicit o: Ord[T]): Ord[List[T]] = ??? + implicit def intOrd: Ord[Int] = ??? + + def sort[T](xs: List[T])(implicit o: Ord[T]): List[T] = ??? + + def g(xs: List[Int]) = + sort(xs) + + def f[T](xs: List[List[List[T]]]) = + sort(xs) // error TODO: improve the -explain-implicts diagnostic + + listOrd(listOrd(implicitly[Ord[T]] /*not found*/)) // error +} diff --git a/tests/pos/cm/ConfManagement.scala b/tests/pos/cm/ConfManagement.scala new file mode 100644 index 000000000000..2a7e37dd0ae1 --- /dev/null +++ b/tests/pos/cm/ConfManagement.scala @@ -0,0 +1,25 @@ +package cm + +case class Person(name: String) +case class Paper(title: String, authors: List[Person], body: String) + +class Viewers(val persons: Set[Person]) + +class ConfManagement(papers: List[Paper], realScore: Map[Paper, Int]) { + + private def hasConflict(ps1: Set[Person], ps2: Iterable[Person]) = + ps2.exists(ps1 contains _) + + def viewers(implicit vs: Viewers): Set[Person] = + vs.persons + + def score(paper: Paper)(implicit vs: Viewers): Int = + if (hasConflict(viewers, paper.authors)) -100 + else realScore(paper) + + def viewRankings(implicit vs: Viewers): List[Paper] = + papers.sortBy(score(_)) + + def delegate[T](query: Viewers => T, p: Person)(implicit vs: Viewers): T = + query(new Viewers(viewers + p)) +} \ No newline at end of file diff --git a/tests/run/i2508.scala b/tests/run/i2508.scala new file mode 100644 index 000000000000..28875d69f3cf --- /dev/null +++ b/tests/run/i2508.scala @@ -0,0 +1,16 @@ +trait Eq[T] { + def eq(a: T, b: T): Boolean +} + +object Eq { + implicit object int extends Eq[Int] { + def eq(a: Int, b: Int) = a == b + } +} + +object Test { + def f[T](a: T, b: T)(implicit T: Eq[T]) = T.eq(a, b) + + def main(args: Array[String]) = + assert(!f(1, 2)) +}