File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,11 @@ object Config {
108108 */
109109 final val checkMethodTypes = false
110110
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+
111116 /** The recursion depth for showing a summarized string */
112117 final val summarizeDepth = 2
113118
Original file line number Diff line number Diff line change @@ -1527,7 +1527,18 @@ object Types {
15271527 }
15281528
15291529 /** 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+ }
15311542
15321543 /** A second fallback to recompute the denotation if necessary */
15331544 private def computeDenot (implicit ctx : Context ): Denotation = {
@@ -1563,9 +1574,9 @@ object Types {
15631574
15641575 // Don't use setDenot here; double binding checks can give spurious failures after erasure
15651576 lastDenotation = d
1566- checkDenot()
15671577 lastSymbol = d.symbol
15681578 checkedPeriod = ctx.period
1579+ checkDenot()
15691580 }
15701581 d
15711582 }
You can’t perform that action at this time.
0 commit comments