diff options
author | Martin Odersky <odersky@gmail.com> | 2015-09-24 16:16:22 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-10-01 19:33:25 +0200 |
commit | 7352fc4a6fd7b3637bb7eb5f79f8a14f4e46a2b1 (patch) | |
tree | 745f7322d3edea08aa96a46b9ba84581c7e55524 /src/dotty | |
parent | 22417e217d7e5656af3ded79411db29589239f27 (diff) | |
download | dotty-7352fc4a6fd7b3637bb7eb5f79f8a14f4e46a2b1.tar.gz dotty-7352fc4a6fd7b3637bb7eb5f79f8a14f4e46a2b1.tar.bz2 dotty-7352fc4a6fd7b3637bb7eb5f79f8a14f4e46a2b1.zip |
underlyingChain -> underlyingIterator
make successive underlying values an iterator (so that we
do not run into a stackoverflow in case of cycles).
Diffstat (limited to 'src/dotty')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 8ad694ea2..e4f228915 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -806,12 +806,18 @@ object Types { case _ => NoType } - /** The chain of underlying types as long as type is a TypeProxy. + /** The iterator of underlying types as long as type is a TypeProxy. * Useful for diagnostics */ - def underlyingChain(implicit ctx: Context): List[Type] = this match { - case tp: TypeProxy => tp :: tp.underlying.underlyingChain - case _ => Nil + def underlyingIterator(implicit ctx: Context): Iterator[Type] = new Iterator[Type] { + var current = Type.this + var hasNext = true + def next = { + val res = current + hasNext = current.isInstanceOf[TypeProxy] + if (hasNext) current = current.asInstanceOf[TypeProxy].underlying + res + } } /** A prefix-less refined this or a termRef to a new skolem symbol |