@@ -332,21 +332,8 @@ object Denotations {
332
332
}
333
333
334
334
/** Handle merge conflict by throwing a `MergeError` exception */
335
- private def mergeConflict (tp1 : Type , tp2 : Type , that : Denotation )(implicit ctx : Context ): Type = {
336
- def showSymbol (sym : Symbol ): String = if (sym.exists) sym.showLocated else " [unknown]"
337
- def showType (tp : Type ) = tp match {
338
- case ClassInfo (_, cls, _, _, _) => cls.showLocated
339
- case bounds : TypeBounds => i " type bounds $bounds"
340
- case _ => tp.show
341
- }
342
- val msg =
343
- s """ cannot merge
344
- | ${showSymbol(this .symbol)} of type ${showType(tp1)} and
345
- | ${showSymbol(that.symbol)} of type ${showType(tp2)}
346
- """
347
- if (true ) throw new MergeError (msg, tp1, tp2)
348
- else throw new Error (msg) // flip condition for debugging
349
- }
335
+ private def mergeConflict (tp1 : Type , tp2 : Type , that : Denotation )(implicit ctx : Context ): Type =
336
+ throw new MergeError (this .symbol, that.symbol, tp1, tp2, NoPrefix )
350
337
351
338
/** Merge parameter names of lambda types. If names in corresponding positions match, keep them,
352
339
* otherwise generate new synthetic names.
@@ -537,8 +524,7 @@ object Denotations {
537
524
else if (pre.widen.classSymbol.is(Scala2x ) || ctx.scala2Mode)
538
525
info1 // follow Scala2 linearization -
539
526
// compare with way merge is performed in SymDenotation#computeMembersNamed
540
- else
541
- throw new MergeError (s " ${ex.getMessage} as members of type ${pre.show}" , ex.tp1, ex.tp2)
527
+ else throw new MergeError (ex.sym1, ex.sym2, ex.tp1, ex.tp2, pre)
542
528
}
543
529
new JointRefDenotation (sym, jointInfo, denot1.validFor & denot2.validFor)
544
530
}
@@ -1136,21 +1122,15 @@ object Denotations {
1136
1122
def doubleDefError (denot1 : Denotation , denot2 : Denotation , pre : Type = NoPrefix )(implicit ctx : Context ): Nothing = {
1137
1123
val sym1 = denot1.symbol
1138
1124
val sym2 = denot2.symbol
1139
- def fromWhere = if (pre == NoPrefix ) " " else i " \n when seen as members of $pre"
1140
- val msg =
1141
- if (denot1.isTerm)
1142
- i """ cannot merge
1143
- | $sym1: ${sym1.info} and
1144
- | $sym2: ${sym2.info};
1145
- |they are both defined in ${sym1.owner} but have matching signatures
1146
- | ${denot1.info} and
1147
- | ${denot2.info}$fromWhere"""
1148
- else
1149
- i """ cannot merge
1150
- | $sym1 ${denot1.info}
1151
- | $sym2 ${denot2.info}
1152
- |they are conflicting definitions $fromWhere"""
1153
- throw new MergeError (msg, denot2.info, denot2.info)
1125
+ if (denot1.isTerm)
1126
+ throw new MergeError (sym1, sym2, sym1.info, sym2.info, pre) {
1127
+ override def addendum (implicit ctx : Context ) =
1128
+ i """
1129
+ |they are both defined in ${sym1.owner} but have matching signatures
1130
+ | ${denot1.info} and
1131
+ | ${denot2.info}${super .addendum}"""
1132
+ }
1133
+ else throw new MergeError (sym1, sym2, denot1.info, denot2.info, pre)
1154
1134
}
1155
1135
1156
1136
// --- Overloaded denotations and predenotations -------------------------------------------------
0 commit comments