Skip to content

Commit ec1e057

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

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
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/cycles.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class C {
2323

2424
class E {
2525
class F {
26-
type T <: x.type // old-error: not stable
26+
type T <: x.type // error
2727
val z: x.type = ??? // old-error: not stable
2828
}
2929
lazy val x: F#T = ???

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)