summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2010-09-22 20:39:00 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2010-09-22 20:39:00 +0000
commit2e7bd469cd4bf887c7fd230f56e2f77e1241f6b5 (patch)
treea7427776f20a69c4353f05089ee85c1720b1af0c
parent3e70e56427e9b4eed821863e233bc71a907464b5 (diff)
downloadscala-2e7bd469cd4bf887c7fd230f56e2f77e1241f6b5.tar.gz
scala-2e7bd469cd4bf887c7fd230f56e2f77e1241f6b5.tar.bz2
scala-2e7bd469cd4bf887c7fd230f56e2f77e1241f6b5.zip
closes #3792: type equality for singleton types...
closes #3792: type equality for singleton types did not take type aliases into account while chasing the chain of underlying types (if the underlying type is an alias of a singleton type, it should be followed) review by odersky
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala20
-rw-r--r--test/files/pos/t3792.scala4
2 files changed, 15 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index cced26a780..a82f292ed2 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -4297,16 +4297,18 @@ A type's typeSymbol should never be inspected directly.
case _: SingletonType =>
tp2 match {
case _: SingletonType =>
- var origin1 = tp1
- while (origin1.underlying.isInstanceOf[SingletonType]) {
- assert(origin1 ne origin1.underlying, origin1)
- origin1 = origin1.underlying
- }
- var origin2 = tp2
- while (origin2.underlying.isInstanceOf[SingletonType]) {
- assert(origin2 ne origin2.underlying, origin2)
- origin2 = origin2.underlying
+ @inline def chaseDealiasedUnderlying(tp: Type): Type = {
+ var origin = tp
+ var next = origin.underlying.dealias
+ while (next.isInstanceOf[SingletonType]) {
+ assert(origin ne next, origin)
+ origin = next
+ next = origin.underlying.dealias
+ }
+ origin
}
+ val origin1 = chaseDealiasedUnderlying(tp1)
+ val origin2 = chaseDealiasedUnderlying(tp2)
((origin1 ne tp1) || (origin2 ne tp2)) && (origin1 =:= origin2)
case _ =>
false
diff --git a/test/files/pos/t3792.scala b/test/files/pos/t3792.scala
new file mode 100644
index 0000000000..10773c5f5b
--- /dev/null
+++ b/test/files/pos/t3792.scala
@@ -0,0 +1,4 @@
+object Test {
+ type Hui = Nil.type
+ val n: Hui = Nil
+} \ No newline at end of file