summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2013-03-11 22:32:08 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2013-03-11 22:32:08 -0700
commit221f52757aa64d47fffe0a8e2204943423041316 (patch)
treedccdea4814193953de9cb92886586dede4a14b4b
parent2ff7650fb9f337dd123449e6cbcefc521cac8556 (diff)
parent7e52fb910b8547930f203233e46140a2daf8b511 (diff)
downloadscala-221f52757aa64d47fffe0a8e2204943423041316.tar.gz
scala-221f52757aa64d47fffe0a8e2204943423041316.tar.bz2
scala-221f52757aa64d47fffe0a8e2204943423041316.zip
Merge pull request #2228 from retronym/ticket/7226
SI-7226 Fix inference regression caused by TypeVar equality
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala6
-rw-r--r--test/files/pos/t7226.scala26
2 files changed, 32 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index ea193465ad..a27b37dae5 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -3052,6 +3052,12 @@ trait Types extends api.Types { self: SymbolTable =>
val origin: Type,
var constr: TypeConstraint
) extends Type {
+
+ // We don't want case class equality/hashing as TypeVar-s are mutable,
+ // and TypeRefs based on them get wrongly `uniqued` otherwise. See SI-7226.
+ override def hashCode(): Int = System.identityHashCode(this)
+ override def equals(other: Any): Boolean = this eq other.asInstanceOf[AnyRef]
+
def untouchable = false // by other typevars
override def params: List[Symbol] = Nil
override def typeArgs: List[Type] = Nil
diff --git a/test/files/pos/t7226.scala b/test/files/pos/t7226.scala
new file mode 100644
index 0000000000..06f0c95dc4
--- /dev/null
+++ b/test/files/pos/t7226.scala
@@ -0,0 +1,26 @@
+trait HK {
+ type Rep[X]
+
+ // okay
+ def unzip2[A, B](ps: Rep[List[(A, B)]])
+ unzip2(null.asInstanceOf[Rep[List[(Int, String)]]])
+
+ // okay
+ def unzipHK[A, B, C[_]](ps: Rep[C[(A, B)]])
+ unzipHK(null.asInstanceOf[Rep[List[(Int, String)]]])
+
+ def unzipHKRet0[A, C[_]](ps: C[A]): C[Int]
+ def ls: List[String]
+ unzipHKRet0(ls)
+
+ // fail
+ def unzipHKRet[A, C[_]](ps: Rep[C[A]]): Rep[C[Int]]
+ def rls: Rep[List[String]]
+ unzipHKRet(rls)
+}
+
+trait HK1 {
+ type Rep[A]
+ def unzip1[A, B, C[_]](ps: Rep[C[(A, B)]]): (Rep[C[A]], Rep[C[B]])
+ def doUnzip1[A, B](ps: Rep[List[(A, B)]]) = unzip1(ps)
+}