Skip to content

Commit 68d9657

Browse files
committed
Fixed problem with ensureSingleton
Need to also ensure that the singleton is stable. This makes compound.scala pass.
1 parent b914fb7 commit 68d9657

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/dotty/tools/dotc/core/Skolemization.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ trait Skolemization {
2020

2121
protected var skolemsOutstanding = false
2222

23-
def ensureSingleton(tp: Type): SingletonType = tp.stripTypeVar match {
24-
case tp: SingletonType =>
23+
def ensureStableSingleton(tp: Type): SingletonType = tp.stripTypeVar match {
24+
case tp: SingletonType if tp.isStable =>
2525
tp
2626
case tp: ValueType =>
2727
skolemsOutstanding = true
2828
SkolemType(tp)
2929
case tp: TypeProxy =>
30-
ensureSingleton(tp.underlying)
30+
ensureStableSingleton(tp.underlying)
3131
}
3232

3333
/** Approximate a type `tp` with a type that does not contain skolem types.

src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi
527527
val saved = skolemsOutstanding
528528
try {
529529
val rebindNeeded = tp2.refinementRefersToThis
530-
val base = if (rebindNeeded) ensureSingleton(tp1) else tp1
530+
val base = if (rebindNeeded) ensureStableSingleton(tp1) else tp1
531531
val rinfo2 = if (rebindNeeded) tp2.refinedInfo.substSkolem(tp2, base) else tp2.refinedInfo
532532
def qualifies(m: SingleDenotation) = isSubType(m.info, rinfo2)
533533
def memberMatches(mbr: Denotation): Boolean = mbr match { // inlined hasAltWith for performance

tests/pending/pos/compound.scala renamed to tests/pos/compound.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// There's still a problem with var's here, presumably because they are not paths.
2-
// Needs some more investigation.
31
abstract class A { type T }
42

53
abstract class B { val xz: Any }
@@ -11,6 +9,6 @@ abstract class Test {
119
}
1210

1311
abstract class Test2 {
14-
val yy: A with B { type T; val xz: T } = null;
12+
var yy: A with B { type T; val xz: T } = null;
1513
val xx: A with B { type T; val xz: T } = yy
1614
}

0 commit comments

Comments
 (0)