Skip to content

Commit 302973e

Browse files
committed
Make abstract pattern error into an error message
1 parent 3694aa9 commit 302973e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,4 +901,12 @@ object messages {
901901
val msg = hl"trying to define package with same name as `$existing`"
902902
val explanation = ""
903903
}
904+
905+
case class ErasedType()(implicit ctx: Context)
906+
extends Message(34) {
907+
val kind = "Erased Type"
908+
val msg =
909+
i"abstract type pattern is unchecked since it is eliminated by erasure"
910+
val explanation = ""
911+
}
904912
}

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)