diff options
author | Miles Sabin <miles@milessabin.com> | 2017-04-03 16:46:03 +0100 |
---|---|---|
committer | Miles Sabin <miles@milessabin.com> | 2017-04-03 16:50:33 +0100 |
commit | d6f25c2501c2b6f13cde620d09b8b952d05588b7 (patch) | |
tree | 66061c5c3f6f5b6c8195869fe465a86f8cf602ad /test | |
parent | f5ce29b7f4afaf00ac644665963e017a9fa253d9 (diff) | |
download | scala-d6f25c2501c2b6f13cde620d09b8b952d05588b7.tar.gz scala-d6f25c2501c2b6f13cde620d09b8b952d05588b7.tar.bz2 scala-d6f25c2501c2b6f13cde620d09b8b952d05588b7.zip |
Make ImplicitInfo hashCode consistent with equals.
Diffstat (limited to 'test')
-rw-r--r-- | test/junit/scala/tools/nsc/typechecker/Implicits.scala | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/junit/scala/tools/nsc/typechecker/Implicits.scala b/test/junit/scala/tools/nsc/typechecker/Implicits.scala new file mode 100644 index 0000000000..75f4e70827 --- /dev/null +++ b/test/junit/scala/tools/nsc/typechecker/Implicits.scala @@ -0,0 +1,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) + } + } +} |