Skip to content

Commit 19d57f6

Browse files
committed
Fix #2088: Test for simple cycle in type aliases
1 parent e639043 commit 19d57f6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ object Checking {
206206
def isInteresting(prefix: Type): Boolean = prefix.stripTypeVar match {
207207
case NoPrefix => true
208208
case prefix: ThisType => sym.owner.isClass && prefix.cls.isContainedIn(sym.owner)
209-
case prefix: NamedType => !prefix.symbol.isStaticOwner && isInteresting(prefix.prefix)
209+
case prefix: NamedType =>
210+
!prefix.symbol.isStaticOwner &&
211+
(pre.derivesFrom(sym.owner) || isInteresting(prefix.prefix))
210212
case SuperType(thistp, _) => isInteresting(thistp)
211213
case AndType(tp1, tp2) => isInteresting(tp1) || isInteresting(tp2)
212214
case OrType(tp1, tp2) => isInteresting(tp1) && isInteresting(tp2)

tests/neg/i2088.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Base {
2+
type A = { // error
3+
val m: Foo.A
4+
}
5+
}
6+
7+
object Foo extends Base

0 commit comments

Comments
 (0)