aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/sbt
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-01-29 17:54:30 +1100
committerGuillaume Martres <smarter@ubuntu.com>2017-01-29 14:44:30 +0100
commit56fb15888fb98e3a6a535f5734bb8ce82fcd76c3 (patch)
treec1e01cce8a76a5e66ba2a54472bc899ae41ca405 /compiler/src/dotty/tools/dotc/sbt
parent6e8933ccc40bbfe1a92c32c2d8314fd6facef12a (diff)
downloaddotty-56fb15888fb98e3a6a535f5734bb8ce82fcd76c3.tar.gz
dotty-56fb15888fb98e3a6a535f5734bb8ce82fcd76c3.tar.bz2
dotty-56fb15888fb98e3a6a535f5734bb8ce82fcd76c3.zip
Fix #1750: Handle illegal class overrides better
Illegal class overrides are fundamentally at odds with the way dotty represents types and therefore can cause lots of low-level problems. Two measures in this commit First, we detect direct illegal class overrides on completion instead of during RefChecks. Break the override by making the previously overriding type private. This fixes i1750.scala, but still fails for indirect overrides between two unrelated outer traits/classes that are inherited by the same class or trait. We fix this by catching the previously thrown ClassCastException in both ExtractAPI and RefChecks. Test case for indirect overrides is in i1750a.scala.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/sbt')
-rw-r--r--compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala12
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala b/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala
index 1fffe6841..7f44af486 100644
--- a/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala
+++ b/compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala
@@ -6,6 +6,7 @@ import core._, core.Decorators._
import Annotations._, Contexts._, Flags._, Phases._, Trees._, Types._, Symbols._
import Names._, NameOps._, StdNames._
import typer.Inliner
+import typer.ErrorReporting.cyclicErrorMsg
import dotty.tools.io.Path
import java.io.PrintWriter
@@ -190,7 +191,16 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
def apiClassStructure(csym: ClassSymbol): api.Structure = {
val cinfo = csym.classInfo
- val bases = linearizedAncestorTypes(cinfo)
+ val bases =
+ try linearizedAncestorTypes(cinfo)
+ 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), csym.pos)
+ defn.ObjectType :: Nil
+ }
+
val apiBases = bases.map(apiType)
// Synthetic methods that are always present do not affect the API