aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-01-28 19:01:09 +0100
committerMartin Odersky <odersky@gmail.com>2015-01-28 19:03:55 +0100
commit70e55d26100199b99502705233786bbdc15c4c6b (patch)
tree97fbfa865286a60ad90230b868179c3e61143eec
parent37918e5d1eb53014b1116ea65381a56e93a3c855 (diff)
downloaddotty-70e55d26100199b99502705233786bbdc15c4c6b.tar.gz
dotty-70e55d26100199b99502705233786bbdc15c4c6b.tar.bz2
dotty-70e55d26100199b99502705233786bbdc15c4c6b.zip
Fixed problem with ensureSingleton
Need to also ensure that the singleton is stable. This makes compound.scala pass.
-rw-r--r--src/dotty/tools/dotc/core/Skolemization.scala6
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala2
-rw-r--r--tests/pos/compound.scala (renamed from tests/pending/pos/compound.scala)4
3 files changed, 5 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/Skolemization.scala b/src/dotty/tools/dotc/core/Skolemization.scala
index 8bc5c815f..2832a3bad 100644
--- a/src/dotty/tools/dotc/core/Skolemization.scala
+++ b/src/dotty/tools/dotc/core/Skolemization.scala
@@ -20,14 +20,14 @@ trait Skolemization {
protected var skolemsOutstanding = false
- def ensureSingleton(tp: Type): SingletonType = tp.stripTypeVar match {
- case tp: SingletonType =>
+ def ensureStableSingleton(tp: Type): SingletonType = tp.stripTypeVar match {
+ case tp: SingletonType if tp.isStable =>
tp
case tp: ValueType =>
skolemsOutstanding = true
SkolemType(tp)
case tp: TypeProxy =>
- ensureSingleton(tp.underlying)
+ ensureStableSingleton(tp.underlying)
}
/** Approximate a type `tp` with a type that does not contain skolem types.
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index 1d0ea03c1..9826a23ea 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -517,7 +517,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi
val saved = skolemsOutstanding
try {
val rebindNeeded = tp2.refinementRefersToThis
- val base = if (rebindNeeded) ensureSingleton(tp1) else tp1
+ val base = if (rebindNeeded) ensureStableSingleton(tp1) else tp1
val rinfo2 = if (rebindNeeded) tp2.refinedInfo.substSkolem(tp2, base) else tp2.refinedInfo
def qualifies(m: SingleDenotation) = isSubType(m.info, rinfo2)
def memberMatches(mbr: Denotation): Boolean = mbr match { // inlined hasAltWith for performance
diff --git a/tests/pending/pos/compound.scala b/tests/pos/compound.scala
index 16dbf9a08..24a936f13 100644
--- a/tests/pending/pos/compound.scala
+++ b/tests/pos/compound.scala
@@ -1,5 +1,3 @@
-// There's still a problem with var's here, presumably because they are not paths.
-// Needs some more investigation.
abstract class A { type T }
abstract class B { val xz: Any }
@@ -11,6 +9,6 @@ abstract class Test {
}
abstract class Test2 {
- val yy: A with B { type T; val xz: T } = null;
+ var yy: A with B { type T; val xz: T } = null;
val xx: A with B { type T; val xz: T } = yy
}