Skip to content

Commit bdef0bc

Browse files
authored
Merge pull request #474 from scala/backport-lts-3.3-23354
Backport "Unhelpful error message when trying to use named extraction, when not matching case class or named tuple" to 3.3 LTS
2 parents f055afc + 17a89d4 commit bdef0bc

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMe
228228
case OnlyFullyDependentAppliedConstructorTypeID // errorNumber: 212
229229
case PointlessAppliedConstructorTypeID // errorNumber: 213
230230
case IllegalContextBoundsID // errorNumber: 214
231+
case NamedPatternNotApplicableID // errorNumber: 215
231232

232233
def errorNumber = ordinal - 1
233234

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3262,4 +3262,8 @@ final class IllegalContextBounds(using Context) extends SyntaxMsg(IllegalContext
32623262

32633263
override protected def explain(using Context): String = ""
32643264

3265-
end IllegalContextBounds
3265+
final class NamedPatternNotApplicable(selectorType: Type)(using Context) extends PatternMatchMsg(NamedPatternNotApplicableID):
3266+
override protected def msg(using Context): String =
3267+
i"Named patterns cannot be used with $selectorType, because it is not a named tuple or case class"
3268+
3269+
override protected def explain(using Context): String = ""

0 commit comments

Comments
 (0)