diff options
author | Paul Phillips <paulp@improving.org> | 2011-10-19 17:19:08 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-10-19 17:19:08 +0000 |
commit | 8fc7a72a2b7765b6f5c6c5feb2bcaae58e735396 (patch) | |
tree | 26f3154d1ff9fb8d90f842f3c39fcf35b964a790 /src/compiler/scala/reflect/internal/Types.scala | |
parent | fb2353db6cc296289092ffa948e2e1c5f06c0d59 (diff) | |
download | scala-8fc7a72a2b7765b6f5c6c5feb2bcaae58e735396.tar.gz scala-8fc7a72a2b7765b6f5c6c5feb2bcaae58e735396.tar.bz2 scala-8fc7a72a2b7765b6f5c6c5feb2bcaae58e735396.zip |
Cycle defense.
Notice when a typeref's info creates an obvious cycle, so we can see an
error instead of a stack overflow. Closes SI-5093, review by moors.
Diffstat (limited to 'src/compiler/scala/reflect/internal/Types.scala')
-rw-r--r-- | src/compiler/scala/reflect/internal/Types.scala | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index e85dc6de95..7b77c8addf 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -1772,7 +1772,13 @@ trait Types extends api.Types { self: SymbolTable => val symInfo = sym.info if (thisInfoCache == null || (symInfo ne symInfoCache)) { symInfoCache = symInfo - thisInfoCache = transformInfo(symInfo) + thisInfoCache = transformInfo(symInfo) match { + // If a subtyping cycle is not detected here, we'll likely enter an infinite + // loop before a sensible error can be issued. SI-5093 is one example. + case x: SubType if x.supertype eq this => + throw new TypeError("illegal cyclic reference involving " + sym) + case tp => tp + } } thisInfoCache } |