Skip to content

Commit 06b234e

Browse files
committed
Make abstract pattern error into an error message
1 parent 758db16 commit 06b234e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,8 @@ object messages {
901901
val explanation = ""
902902
}
903903

904-
case class ExistentialTypesNoLongerSupported()(implicit ctx: Context) extends Message(34) {
904+
case class ExistentialTypesNoLongerSupported()(implicit ctx: Context)
905+
extends Message(34) {
905906
val kind = "Syntax"
906907
val msg =
907908
hl"""|Existential types are no longer supported -
@@ -923,4 +924,11 @@ object messages {
923924
|"""
924925
}
925926

927+
case class ErasedType()(implicit ctx: Context)
928+
extends Message(35) {
929+
val kind = "Erased Type"
930+
val msg =
931+
i"abstract type pattern is unchecked since it is eliminated by erasure"
932+
val explanation = ""
933+
}
926934
}

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

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

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

0 commit comments

Comments
 (0)