aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/transform
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2017-01-30 12:05:02 +1100
committerGitHub <noreply@github.com>2017-01-30 12:05:02 +1100
commitd087448fdffff8f64a23d9db39445455cddc2fc6 (patch)
treec1e01cce8a76a5e66ba2a54472bc899ae41ca405 /compiler/src/dotty/tools/dotc/transform
parent6e8933ccc40bbfe1a92c32c2d8314fd6facef12a (diff)
parent56fb15888fb98e3a6a535f5734bb8ce82fcd76c3 (diff)
downloaddotty-d087448fdffff8f64a23d9db39445455cddc2fc6.tar.gz
dotty-d087448fdffff8f64a23d9db39445455cddc2fc6.tar.bz2
dotty-d087448fdffff8f64a23d9db39445455cddc2fc6.zip
Merge pull request #1913 from dotty-staging/fix-#1750
Fix #1750: Alternative fix for cyclic references due to illegal class overrides
Diffstat (limited to 'compiler/src/dotty/tools/dotc/transform')
-rw-r--r--compiler/src/dotty/tools/dotc/transform/OverridingPairs.scala17
1 files changed, 13 insertions, 4 deletions
diff --git a/compiler/src/dotty/tools/dotc/transform/OverridingPairs.scala b/compiler/src/dotty/tools/dotc/transform/OverridingPairs.scala
index 650a03054..1f1f371a6 100644
--- a/compiler/src/dotty/tools/dotc/transform/OverridingPairs.scala
+++ b/compiler/src/dotty/tools/dotc/transform/OverridingPairs.scala
@@ -6,6 +6,7 @@ import Flags._, Symbols._, Contexts._, Types._, Scopes._, Decorators._
import util.HashSet
import collection.mutable
import collection.immutable.BitSet
+import typer.ErrorReporting.cyclicErrorMsg
import scala.annotation.tailrec
/** A module that can produce a kind of iterator (`Cursor`),
@@ -122,10 +123,18 @@ object OverridingPairs {
if (nextEntry ne null) {
nextEntry = decls.lookupNextEntry(nextEntry)
if (nextEntry ne null) {
- overridden = nextEntry.sym
- if (overriding.owner != overridden.owner && matches(overriding, overridden)) {
- visited += overridden
- if (!hasCommonParentAsSubclass(overriding.owner, overridden.owner)) return
+ try {
+ overridden = nextEntry.sym
+ if (overriding.owner != overridden.owner && matches(overriding, overridden)) {
+ visited += overridden
+ if (!hasCommonParentAsSubclass(overriding.owner, overridden.owner)) return
+ }
+ }
+ catch {
+ case ex: CyclicReference =>
+ // See neg/i1750a for an example where a cyclic error can arise.
+ // The root cause in this example is an illegal "override" of an inner trait
+ ctx.error(cyclicErrorMsg(ex), base.pos)
}
} else {
curEntry = curEntry.prev