aboutsummaryrefslogtreecommitdiff
path: root/tests/neg/function-arity.scala
blob: 86fbab49ff128463da07b44931fc8e20cacc0fa6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
object Test {

  // From #873:

  trait X extends Function1[Int, String]
  implicit def f2x(f: Function1[Int, String]): X = ???
  ({case _ if "".isEmpty => 0} : X) // error: expected String, found Int

  // Tests where parameter list cannot be made into a pattern

  def unary[T](x: T => Unit) = ???
  unary((x, y) => ())   // error

  unary[(Int, Int)]((x, y) => ())

  unary[(Int, Int)](() => ())   // error
  unary[(Int, Int)]((x, y, _) => ()) // error

  unary[(Int, Int)]((x: String, y) => ()) // error

  def foo(a: Tuple2[Int, Int] => String): String = ""
  def foo(a: Any => String) = ()
  foo((a: Int, b: String) => a + b) // error: none of the overloaded alternatives of method foo match arguments (Int, Int)
}