summaryrefslogtreecommitdiff
path: root/test/junit/scala/tools/nsc/typechecker/Implicits.scala
blob: 75f4e70827aab489c278ec371d6179e1dbf3b98b (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
package scala.tools.nsc
package typechecker

import org.junit.Assert._
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

import scala.tools.testing.BytecodeTesting

@RunWith(classOf[JUnit4])
class ImplicitsTests extends BytecodeTesting {
  import compiler.global._, definitions._, analyzer._

  @Test
  def implicitInfoHashCode(): Unit = {
    val run = new global.Run

    enteringPhase(run.typerPhase) {
      val T0 = IntClass.tpeHK
      val T1 = refinedType(List(T0), NoSymbol)

      assert(T0 =:= T1)
      assert(T0 != T1)
      assert(T0.hashCode != T1.hashCode)

      val I0 = new ImplicitInfo(TermName("dummy"), T0, NoSymbol)
      val I1 = new ImplicitInfo(TermName("dummy"), T1, NoSymbol)

      assert(I0 == I1)
      assert(I0.hashCode == I1.hashCode)

      val pHash = (TermName("dummy"), NoSymbol).hashCode

      assert(I0.hashCode == pHash)
      assert(I1.hashCode == pHash)
    }
  }
}