@@ -58,11 +58,11 @@ object Formatting {
58
58
}
59
59
}
60
60
61
- /** The d string interpolator works like the i string interpolator, but marks nonsensical errors
61
+ /** The `em` string interpolator works like the `i` string interpolator, but marks nonsensical errors
62
62
* using `<nonsensical>...</nonsensical>` tags.
63
63
* Note: Instead of these tags, it would be nicer to return a data structure containing the message string
64
64
* and a boolean indicating whether the message is sensical, but then we cannot use string operations
65
- * like concatenation, stripMargin etc on the values returned by d "...", and in the current error
65
+ * like concatenation, stripMargin etc on the values returned by em "...", and in the current error
66
66
* message composition methods, this is crucial.
67
67
*/
68
68
class ErrorMessageFormatter (sc : StringContext ) extends StringFormatter (sc) {
@@ -85,8 +85,15 @@ object Formatting {
85
85
86
86
override def default (key : String ) = Nil
87
87
88
- def record (str : String , entry : Recorded ): String = {
89
- var alts = apply(str).dropWhile(entry ne _)
88
+ def record (str : String , entry : Recorded )(implicit ctx : Context ): String = {
89
+ def followAlias (e1 : Recorded ): Recorded = e1 match {
90
+ case e1 : Symbol if e1.isAliasType =>
91
+ val underlying = e1.typeRef.underlyingClassRef(refinementOK = false ).typeSymbol
92
+ if (underlying.name == e1.name) underlying else e1
93
+ case _ => e1
94
+ }
95
+ lazy val dealiased = followAlias(entry)
96
+ var alts = apply(str).dropWhile(alt => dealiased ne followAlias(alt))
90
97
if (alts.isEmpty) {
91
98
alts = entry :: apply(str)
92
99
update(str, alts)
@@ -135,13 +142,6 @@ object Formatting {
135
142
case param : PolyParam =>
136
143
s " is a type variable ${addendum(" constraint" , ctx.typeComparer.bounds(param))}"
137
144
case sym : Symbol =>
138
- val ownerStr =
139
- if (! sym.exists) " "
140
- else {
141
- var owner = sym.effectiveOwner
142
- if (owner.isLocalDummy) i " locally defined in ${owner.owner}"
143
- else i " in $owner"
144
- }
145
145
s " is a ${ctx.printer.kindString(sym)}${sym.showExtendedLocation}${addendum(" bounds" , sym.info)}"
146
146
}
147
147
}
0 commit comments