diff options
author | Martin Odersky <odersky@gmail.com> | 2015-12-13 15:32:17 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-12-13 15:32:17 +0100 |
commit | dba4b94443a8066df23ee7ccdb890ad048a06a2c (patch) | |
tree | c0fc5b9084cc8426d70f922f5b4cd6c1ec048cc0 /src/dotty/tools | |
parent | 2703543fb6e86603bae040fa4cf1ddf93498ef3f (diff) | |
download | dotty-dba4b94443a8066df23ee7ccdb890ad048a06a2c.tar.gz dotty-dba4b94443a8066df23ee7ccdb890ad048a06a2c.tar.bz2 dotty-dba4b94443a8066df23ee7ccdb890ad048a06a2c.zip |
Avoid cycle when computing sets
The tightened subtyping algorithm led to a cycle in baseTypeRef when
compiling sets.scala. This commit fixes the problem.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index a7c457d8f..f65633595 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -447,7 +447,18 @@ object Types { if (rinfo.isAlias) rinfo else if (pdenot.info.isAlias) pdenot.info else if (ctx.pendingMemberSearches.contains(name)) safeAnd(pdenot.info, rinfo) - else pdenot.info & rinfo + else + try pdenot.info & rinfo + catch { + case ex: CyclicReference => + // happens for tests/pos/sets.scala. findMember is called from baseTypeRef. + // The & causes a subtype check which calls baseTypeRef again with the same + // superclass. In the observed case, the superclass was Any, and + // the special shortcut for Any in derivesFrom was as yet absent. To reproduce, + // remove the special treatment of Any in derivesFrom and compile + // sets.scala. + safeAnd(pdenot.info, rinfo) + } pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, jointInfo) } else pdenot & (new JointRefDenotation(NoSymbol, rinfo, Period.allInRun(ctx.runId)), pre) @@ -1562,6 +1573,15 @@ object Types { case _ => false } + + /* A version of toString which also prints aliases. Can be used for debugging + override def toString = + if (isTerm) s"TermRef($prefix, $name)" + else s"TypeRef($prefix, $name)${ + if (lastDenotation != null && lastDenotation.infoOrCompleter.isAlias) + s"@@@ ${lastDenotation.infoOrCompleter.asInstanceOf[TypeAlias].hi}" + else ""}" + */ } abstract case class TermRef(override val prefix: Type, name: TermName) extends NamedType with SingletonType { |