aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala2
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala2
-rw-r--r--src/dotty/tools/dotc/core/Types.scala2
-rw-r--r--src/dotty/tools/dotc/typer/RefChecks.scala19
4 files changed, 18 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index b6519e1cd..fcd60ef16 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -324,7 +324,7 @@ object Denotations {
info1 // follow Scala2 linearization -
// compare with way merge is performed in SymDenotation#computeMembersNamed
else
- throw new MergeError(s"${ex.getMessage} as members of type ${pre.show}")
+ throw new MergeError(s"${ex.getMessage} as members of type ${pre.show}", ex.tp1, ex.tp2)
}
new JointRefDenotation(sym, jointInfo, denot1.validFor & denot2.validFor)
}
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index f8ff84ba1..71dede951 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -1168,7 +1168,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
case bounds: TypeBounds => i"type bounds $bounds"
case _ => tp.show
}
- throw new MergeError(s"cannot merge ${showType(tp1)} with ${showType(tp2)}")
+ throw new MergeError(s"cannot merge ${showType(tp1)} with ${showType(tp2)}", tp1, tp2)
}
/** Merge two lists of names. If names in corresponding positions match, keep them,
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 159e776b4..0691d979a 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -3318,7 +3318,7 @@ object Types {
}
}
- class MergeError(msg: String) extends TypeError(msg)
+ class MergeError(msg: String, val tp1: Type, val tp2: Type) extends TypeError(msg)
// ----- Debug ---------------------------------------------------------
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()