Skip to content

Commit d7d4f21

Browse files
Fix Missing error message on FailureToEliminateExistential
1 parent 3eff831 commit d7d4f21

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import scala.collection.{ mutable, immutable }
2929
import scala.collection.mutable.ListBuffer
3030
import scala.annotation.switch
3131
import reporting.trace
32+
import dotty.tools.dotc.reporting.diagnostic.messages.FailureToEliminateExistential
3233

3334
object Scala2Unpickler {
3435

@@ -627,7 +628,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
627628
*/
628629
def elimExistentials(boundSyms: List[Symbol], tp: Type)(implicit ctx: Context): Type = {
629630
// Need to be careful not to run into cyclic references here (observed when
630-
// comiling t247.scala). That's why we avoiud taking `symbol` of a TypeRef
631+
// compiling t247.scala). That's why we avoid taking `symbol` of a TypeRef
631632
// unless names match up.
632633
val isBound = (tp: Type) => {
633634
def refersTo(tp: Type, sym: Symbol): Boolean = tp match {
@@ -677,11 +678,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
677678
val anyTypes = boundSyms map (_ => defn.AnyType)
678679
val boundBounds = boundSyms map (_.info.bounds.hi)
679680
val tp2 = tp1.subst(boundSyms, boundBounds).subst(boundSyms, anyTypes)
680-
ctx.warning(s"""failure to eliminate existential
681-
|original type : $tp forSome {${ctx.dclsText(boundSyms, "; ").show}
682-
|reduces to : $tp1
683-
|type used instead: $tp2
684-
|proceed at own risk.""".stripMargin)
681+
ctx.warning(FailureToEliminateExistential(tp, tp1, tp2, boundSyms))
685682
tp2
686683
} else tp1
687684
}

compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public enum ErrorMessageID {
105105
ExpectedTypeBoundOrEqualsID,
106106
ClassAndCompanionNameClashID,
107107
TailrecNotApplicableID,
108+
FailureToEliminateExistentialID
108109
;
109110

110111
public int errorNumber() {

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,9 +1821,21 @@ object messages {
18211821

18221822
case class TailrecNotApplicable(method: Symbol)(implicit ctx: Context)
18231823
extends Message(TailrecNotApplicableID) {
1824-
val kind = "Syntax"
1825-
val msg = hl"TailRec optimisation not applicable, $method is neither ${"private"} nor ${"final"}."
1826-
val explanation =
1827-
hl"A method annotated ${"@tailrec"} must be declared ${"private"} or ${"final"} so it can't be overridden."
1824+
val kind = "Syntax"
1825+
val msg = hl"TailRec optimisation not applicable, $method is neither ${"private"} nor ${"final"}."
1826+
val explanation =
1827+
hl"A method annotated ${"@tailrec"} must be declared ${"private"} or ${"final"} so it can't be overridden."
1828+
}
1829+
1830+
case class FailureToEliminateExistential(tp: Type, tp1: Type, tp2: Type, boundSyms: List[Symbol])(implicit ctx: Context)
1831+
extends Message(FailureToEliminateExistentialID) {
1832+
val kind = "Compatibility"
1833+
val msg = hl"Failure to eliminate existential type. Proceed at own risk."
1834+
private val originalType = ctx.dclsText(boundSyms, "; ").show
1835+
val explanation =
1836+
hl"""original type : $tp forSome {${originalType}
1837+
|reduces to : $tp1
1838+
|type used instead: $tp2
1839+
|"""
18281840
}
18291841
}

0 commit comments

Comments
 (0)