summaryrefslogtreecommitdiff
path: root/test/files/run/t8280.scala
blob: 0734d63b6ea405085e5a53bf60d9c2a1b8e5bd36 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import scala.language.implicitConversions

object Test {
  def main(args: Array[String]): Unit = {
    Moop1.ob1
    Moop1.ob2
    Moop1.ob3
    Moop2.ob1
    Moop2.ob2
    Moop2.ob3
    Moop3.ob1
    Moop3.ob2
    Moop3.ob3
  }
}

// int object vs.
object Moop1 {
  object ob1 {
    implicit object f1 extends (Int => String) { def apply(x: Int): String = "Int" }
    implicit object f2 extends (Long => String) { def apply(x: Long): String = "Long" }

    println(5: String)
  }
  object ob2 {
    implicit object f1 extends (Int => String) { def apply(x: Int): String = "Int" }
    implicit def f2(x: Long): String = "Long"

    println(5: String)
  }
  object ob3 {
    implicit object f1 extends (Int => String) { def apply(x: Int): String = "Int" }
    implicit val f2: Long => String = _ => "Long"

    println(5: String)
  }
}

// int def vs.
object Moop2 {
  object ob1 {
    implicit def f1(x: Int): String = "Int"
    implicit object f2 extends (Long => String) { def apply(x: Long): String = "Long" }

    println(5: String)
  }
  object ob2 {
    implicit def f1(x: Int): String = "Int"
    implicit def f2(x: Long): String = "Long"

    println(5: String)
  }
  object ob3 {
    implicit def f1(x: Int): String = "Int"
    implicit val f2: Long => String = _ => "Long"

    println(5: String)
  }
}

// int val vs.
object Moop3 {
  object ob1 {
    implicit val f1: Int => String  = _ => "Int"
    implicit object f2 extends (Long => String) { def apply(x: Long): String = "Long" }

    println(5: String)
  }
  object ob2 {
    implicit val f1: Int => String  = _ => "Int"
    implicit def f2(x: Long): String = "Long"

    println(5: String)
  }
  object ob3 {
    implicit val f1: Int => String  = _ => "Int"
    implicit val f2: Long => String = _ => "Long"

    println(5: String)
  }
}