File tree 2 files changed +18
-2
lines changed
compiler/src/dotty/tools/dotc
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,11 @@ object Config {
108
108
*/
109
109
final val checkMethodTypes = false
110
110
111
+ /** If this flag is set, it is checked that TypeRefs don't refer directly
112
+ * to themselves.
113
+ */
114
+ final val checkTypeRefCycles = false
115
+
111
116
/** The recursion depth for showing a summarized string */
112
117
final val summarizeDepth = 2
113
118
Original file line number Diff line number Diff line change @@ -1527,7 +1527,18 @@ object Types {
1527
1527
}
1528
1528
1529
1529
/** Hook for adding debug check code when denotations are assigned */
1530
- final def checkDenot ()(implicit ctx : Context ) = {}
1530
+ final def checkDenot ()(implicit ctx : Context ) =
1531
+ if (Config .checkTypeRefCycles)
1532
+ lastDenotation match {
1533
+ case d : SingleDenotation =>
1534
+ d.infoOrCompleter match {
1535
+ case TypeBounds (lo, hi) =>
1536
+ assert(lo ne this , this )
1537
+ assert(hi ne this , this )
1538
+ case _ =>
1539
+ }
1540
+ case _ =>
1541
+ }
1531
1542
1532
1543
/** A second fallback to recompute the denotation if necessary */
1533
1544
private def computeDenot (implicit ctx : Context ): Denotation = {
@@ -1563,9 +1574,9 @@ object Types {
1563
1574
1564
1575
// Don't use setDenot here; double binding checks can give spurious failures after erasure
1565
1576
lastDenotation = d
1566
- checkDenot()
1567
1577
lastSymbol = d.symbol
1568
1578
checkedPeriod = ctx.period
1579
+ checkDenot()
1569
1580
}
1570
1581
d
1571
1582
}
You can’t perform that action at this time.
0 commit comments