summaryrefslogtreecommitdiff
path: root/test/files/neg/userdefined_apply.scala
blob: 1f2aff6e822caf365cddd4f2603de186c30353d3 (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
25
26
27
28
29
30
31
object ClashOverloadNoSig {
  // error: overloaded method apply needs result type
  private def apply(x: Int) = if (x > 0) new ClashOverloadNoSig(x) else apply("")

  def apply(x: String): ClashOverloadNoSig = ???
}

case class ClashOverloadNoSig private(x: Int)

object ClashRecNoSig {
  // error: recursive method apply needs result type
  private def apply(x: Int) = if (x > 0) ClashRecNoSig(1) else ???
}

case class ClashRecNoSig private(x: Int)

object NoClashNoSig {
  // error: overloaded method apply needs result type
  private def apply(x: Boolean) = if (x) NoClashNoSig(1) else ???
}

case class NoClashNoSig private(x: Int)

object NoClashOverload {
  // error: overloaded method apply needs result type
  private def apply(x: Boolean) = if (x) NoClashOverload(1) else apply("")

  def apply(x: String): NoClashOverload = ???
}

case class NoClashOverload private(x: Int)