Skip to content

Commit 5eaa143

Browse files
committed
Merge pull request #195 from smarter/fix/singleton-cycles
Detect cycles involving types bounded by singleton types
2 parents 8c73426 + 3d6534f commit 5eaa143

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ object Checking {
105105
}
106106

107107
def apply(tp: Type) = tp match {
108+
case tp: TermRef =>
109+
this(tp.info)
110+
mapOver(tp)
108111
case tp @ RefinedType(parent, name) =>
109112
val parent1 = this(parent)
110113
val saved = cycleOK

test/dotc/tests.scala

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ class tests extends CompilerTest {
100100
@Test def neg_badAuxConstr = compileFile(negDir, "badAuxConstr", xerrors = 2)
101101
@Test def neg_typetest = compileFile(negDir, "typetest", xerrors = 1)
102102
@Test def neg_t1569_failedAvoid = compileFile(negDir, "t1569-failedAvoid", xerrors = 1)
103+
@Test def neg_cycles = compileFile(negDir, "cycles", xerrors = 6)
104+
103105
@Test def dotc = compileDir(dotcDir + "tools/dotc", twice)(allowDeepSubtypes)
104106
@Test def dotc_ast = compileDir(dotcDir + "tools/dotc/ast", twice)
105107
@Test def dotc_config = compileDir(dotcDir + "tools/dotc/config", twice)

tests/neg/cycles.scala

+25
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,28 @@ class Foo[T <: U, U <: T]
22

33
class Bar[T >: T]
44

5+
class A {
6+
val x: T = ???
7+
type T <: x.type
8+
}
9+
10+
class B {
11+
type T <: x.type
12+
val x: T = ???
13+
}
14+
15+
class C {
16+
val x: D#T = ???
17+
class D {
18+
type T <: x.type
19+
val z: x.type = ???
20+
}
21+
}
22+
23+
class E {
24+
class F {
25+
type T <: x.type
26+
val z: x.type = ???
27+
}
28+
val x: F#T = ???
29+
}

0 commit comments

Comments
 (0)