Skip to content

Commit 1931538

Browse files
committed
Fix #10980
1 parent bfa32a4 commit 1931538

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1955,9 +1955,11 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
19551955
isSubInfo(info1, tp2.refinedInfo.widenExpr, m.symbol.info.orElse(info1))
19561956
|| matchAbstractTypeMember(m.info)
19571957

1958-
tp1.member(name) match // inlined hasAltWith for performance
1958+
def memberQualifies = tp1.member(name) match // inlined hasAltWith for performance
19591959
case mbr: SingleDenotation => qualifies(mbr)
19601960
case mbr => mbr hasAltWith qualifies
1961+
1962+
memberQualifies || (tp1.isStable && isSub(TermRef(tp1, name), tp2.refinedInfo))
19611963
}
19621964

19631965
final def ensureStableSingleton(tp: Type): SingletonType = tp.stripTypeVar match {

tests/pos/i10980.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class A:
2+
val x: AnyRef = Object()
3+
4+
@main def m: Unit =
5+
val a = new A
6+
val b: a.x.type = a.x
7+
val c: A { val x: a.x.type } = a

0 commit comments

Comments
 (0)