Skip to content

Commit

Permalink
Fix #10980
Browse files Browse the repository at this point in the history
  • Loading branch information
mbovel committed Oct 3, 2022
1 parent bfa32a4 commit 1eee2e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1955,9 +1955,11 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
isSubInfo(info1, tp2.refinedInfo.widenExpr, m.symbol.info.orElse(info1))
|| matchAbstractTypeMember(m.info)

tp1.member(name) match // inlined hasAltWith for performance
def memberQualifies = tp1.member(name) match // inlined hasAltWith for performance
case mbr: SingleDenotation => qualifies(mbr)
case mbr => mbr hasAltWith qualifies

memberQualifies || (tp1.isStable && isSub(TermRef(tp1, name), tp2.refinedInfo))
}

final def ensureStableSingleton(tp: Type): SingletonType = tp.stripTypeVar match {
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/i10980.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class A:
val x: AnyRef = Object()
val y: AnyRef = Object()

@main def m: Unit =
val a = new A
val b: a.x.type = a.x
val c: A { val x: a.x.type } = a
val d: A { val x: a.x.type; val y: a.y.type } = a

0 comments on commit 1eee2e0

Please sign in to comment.