From 3476bab33e9509963fd02aab10b4db3b891c9a85 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 10 Dec 2015 15:37:37 +0100 Subject: Better diagnostics for clashing classes We do not allow same-named class members in supertraits of a mixin composition anymore. This commit gives a better error message and avoids a crash in RefChecks. --- src/dotty/tools/dotc/typer/RefChecks.scala | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/dotty/tools/dotc/typer/RefChecks.scala') diff --git a/src/dotty/tools/dotc/typer/RefChecks.scala b/src/dotty/tools/dotc/typer/RefChecks.scala index 3ffbb8079..416a2cb92 100644 --- a/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/src/dotty/tools/dotc/typer/RefChecks.scala @@ -15,6 +15,7 @@ import TreeTransforms._ import util.DotClass import scala.util.{Try, Success, Failure} import config.{ScalaVersion, NoScalaVersion} +import Decorators._ import typer.ErrorReporting._ import DenotTransformers._ import ValueClasses.isDerivedValueClass @@ -340,10 +341,20 @@ object RefChecks { }*/ } - val opc = new OverridingPairs.Cursor(clazz) - while (opc.hasNext) { - checkOverride(opc.overriding, opc.overridden) - opc.next() + try { + val opc = new OverridingPairs.Cursor(clazz) + while (opc.hasNext) { + checkOverride(opc.overriding, opc.overridden) + opc.next() + } + } catch { + case ex: MergeError => + val addendum = ex.tp1 match { + case tp1: ClassInfo => + "\n(Note that having same-named member classes in types of a mixin composition is no longer allowed)" + case _ => "" + } + ctx.error(ex.getMessage + addendum, clazz.pos) } printMixinOverrideErrors() -- cgit v1.2.3