Skip to content

Commit

Permalink
Backport "Disallow overloading from breaking stable patterns" to LTS (#…
Browse files Browse the repository at this point in the history
…19163)

Backports #18327 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
Kordyjan authored Dec 8, 2023
2 parents 96af022 + c43d387 commit 0e01547
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
if ctx.mode.is(Mode.Pattern)
&& !tree.isType
&& !pt.isInstanceOf[ApplyingProto]
&& !tree.tpe.isStable
&& !tree.tpe.match
case tp: NamedType => tp.denot.hasAltWith(_.symbol.isStableMember && tp.prefix.isStable || tp.info.isStable)
case tp => tp.isStable
&& !isWildcardArg(tree)
then
report.error(StableIdentPattern(tree, pt), tree.srcPos)
Expand Down
10 changes: 10 additions & 0 deletions tests/pos/i18247.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sealed trait Op
object Op {
case object `==` extends Op
}

def t1(a: Op): true = {
a match {
case Op.`==` => true // was: won't compile
}
}

0 comments on commit 0e01547

Please sign in to comment.