Skip to content

Commit f30c438

Browse files
committed
Make abstract pattern error into an error message
1 parent 1eb1d93 commit f30c438

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public enum ErrorMessageID {
5656
CyclicReferenceInvolvingID,
5757
CyclicReferenceInvolvingImplicitID,
5858
SuperQualMustBeParentID,
59+
ErasedTypeID,
5960
;
6061

6162
public int errorNumber() {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,4 +1221,12 @@ object messages {
12211221
|Attempting to define a field in a method signature after a varargs field is an error.
12221222
|""".stripMargin
12231223
}
1224+
1225+
case class ErasedType()(implicit ctx: Context)
1226+
extends Message(ErasedTypeID) {
1227+
val kind = "Erased Type"
1228+
val msg =
1229+
i"abstract type pattern is unchecked since it is eliminated by erasure"
1230+
val explanation = ""
1231+
}
12241232
}

compiler/src/dotty/tools/dotc/transform/IsInstanceOfEvaluator.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import TreeTransforms.{MiniPhaseTransform, TransformerInfo}
66
import core._
77
import Contexts.Context, Types._, Constants._, Decorators._, Symbols._
88
import TypeUtils._, TypeErasure._, Flags._
9+
import reporting.diagnostic.messages._
910

1011
/** Implements partial evaluation of `sc.isInstanceOf[Sel]` according to:
1112
*
@@ -149,8 +150,8 @@ class IsInstanceOfEvaluator extends MiniPhaseTransform { thisTransformer =>
149150
val inMatch = s.qualifier.symbol is Case
150151

151152
if (valueClassesOrAny) {
152-
if (selector eq defn.ObjectType)
153-
ctx.warning(i"abstract type pattern is unchecked since it is eliminated by erasure", tree.pos)
153+
if ((selector eq defn.ObjectType))
154+
ctx.uncheckedWarning(ErasedType(), tree.pos)
154155
tree
155156
} else if (knownStatically)
156157
handleStaticallyKnown(s, scrutinee, selector, inMatch, tree.pos)

0 commit comments

Comments
 (0)